--- # OS package management: refresh metadata, upgrade, enable EPEL on RedHat, then # install the common and family-specific package sets. - name: "Update apt package cache" ansible.builtin.apt: update_cache: true # Skip the refresh (and the spurious "changed") when the cache is recent. cache_valid_time: 3600 when: ansible_facts["os_family"] == "Debian" - name: "Upgrade all packages to the latest version (Debian)" ansible.builtin.apt: upgrade: dist when: ansible_facts["os_family"] == "Debian" - name: "Upgrade all packages to the latest version (RedHat)" ansible.builtin.dnf: name: "*" state: latest # EL9 ships curl-minimal; allow replacing it so the full curl can be installed. allowerasing: true nobest: true when: ansible_facts["os_family"] == "RedHat" - name: "Enable EPEL repository (provides libuser, python3-virtualenv, rdiff-backup)" ansible.builtin.dnf: name: "{{ epel_release_rpm }}" state: present disable_gpg_check: "{{ epel_disable_gpg_check }}" when: ansible_facts["os_family"] == "RedHat" - name: "Install common packages (RedHat)" ansible.builtin.dnf: name: "{{ list_of_packages }}" state: latest # allowerasing: curl replaces EL9's curl-minimal. skip_broken: tolerate EPEL # packages with unmet deps on some arches (e.g. python3-virtualenv on aarch64). allowerasing: true nobest: true skip_broken: true when: ansible_facts["os_family"] == "RedHat" - name: "Install common packages (non-RedHat)" ansible.builtin.package: name: "{{ list_of_packages }}" state: latest when: ansible_facts["os_family"] != "RedHat" - name: "Remove packages" ansible.builtin.package: name: "{{ list_of_packages_to_remove }}" state: absent - name: "Install RedHat packages" ansible.builtin.dnf: name: "{{ list_of_redhat_packages }}" state: latest allowerasing: true nobest: true skip_broken: true when: ansible_facts["os_family"] == "RedHat" - name: "Install Debian packages" ansible.builtin.apt: name: "{{ list_of_debian_packages }}" force_apt_get: true state: latest when: ansible_facts["os_family"] == "Debian" - name: "Link python3 to python since Ubuntu 22.04 doesn't create python" ansible.builtin.file: src: /usr/bin/python3 dest: /usr/bin/python state: link failed_when: false