--- # base-config — Minimal post-deploy configuration for new instances # # Variables (passed from post-deploy.yml): # hostname — desired hostname # deploy_environment — dev/staging/prod # deploy_owner — owner tag # packages — list of packages to install - name: Set hostname ansible.builtin.hostname: name: "{{ hostname }}" - name: Add hostname to /etc/hosts ansible.builtin.lineinfile: path: /etc/hosts regexp: '^127\.0\.1\.1' line: "127.0.1.1 {{ hostname }}" - name: Update apt cache ansible.builtin.apt: update_cache: true cache_valid_time: 3600 when: ansible_os_family == "Debian" - name: Install base packages ansible.builtin.apt: name: "{{ packages }}" state: present when: ansible_os_family == "Debian" - name: Set timezone to UTC community.general.timezone: name: UTC - name: Enable unattended security upgrades ansible.builtin.copy: dest: /etc/apt/apt.conf.d/20auto-upgrades content: | APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1"; mode: "0644" when: ansible_os_family == "Debian" - name: Add deployment metadata to /etc/deploy-info ansible.builtin.copy: dest: /etc/deploy-info content: | hostname={{ hostname }} environment={{ deploy_environment }} owner={{ deploy_owner }} deployed={{ ansible_date_time.iso8601 }} mode: "0644"