# vim: set ft=ansible: --- - import_tasks: ssh.yml ######################### Run a complete yum update and Reboot the VMs after - name: Update all Packages and Reboot VMs when: - update_packages|bool - not hostvars.localhost.skip_packer_tasks | d(false) | bool tags: packer block: - name: Update all packages register: ryum retries: 3 until: ryum is succeeded yum: name: '*' state: latest - name: Determine if reboot is needed command: needs-restarting -r register: needs_restarting failed_when: false changed_when: false - when: needs_restarting.rc == 1 block: - name: Reboot all VMs after updating to the latest packages (Ansible 2.6 version) include_tasks: reboot_26.yml when: ansible_version.full is version_compare("2.7", "<") - name: Reboot all VMs after updating to the latest packages (Ansible 2.7+ version) include_tasks: reboot_27.yml when: ansible_version.full is version_compare("2.7", ">=") - name: Update network facts after reboot setup: gather_subset: - 'network' - 'virtual' ######################## Install Basic Packages - name: Run setup if gather_facts hasn't been run setup: gather_subset: min when: ansible_distribution_major_version is not defined - name: Install common packages for RHEL 7 import_tasks: ./packages_el7.yml when: - ansible_distribution_major_version == "7" - not hostvars.localhost.skip_packer_tasks | d(false) tags: - install_basic_packages - packer - name: Install common packages for RHEL 8 import_tasks: ./packages_el8.yml when: - ansible_distribution_major_version == "8" - not hostvars.localhost.skip_packer_tasks | d(false) tags: - install_basic_packages - packer