--- - name: Version Lock hosts: temp become: false gather_facts: false vars: lock_pkgs: - httpd-2.4.6-17.el7 - httpd-tools-2.4.6-17.el7 - leapp-0.17.0-2.el7_9 - leapp-upgrade-el7toel8-0.20.0-13.el7_9 - leapp-upgrade-el7toel8-deps-0.20.0-13.el7_9 - leapp-deps-0.17.0-2.el7_9 - python2-leapp-0.17.0-2.el7_9 # - broken-pkg-foo-1.2.3.el7 all_pkgs: - httpd-* - leapp-* - python2-leapp tasks: - name: Ensure dependencies and verionlocks are removed for fresh install when: - remove_deps | default(false) | bool block: - name: Ensure dependencies are removed for fresh install ansible.builtin.yum: name: "{{ all_pkgs }}" state: absent autoremove: true - name: Ensure versionlocks are removed # noqa: command-instead-of-module ansible.builtin.command: "yum versionlock delete '{{ item }}'" failed_when: r_versionlock_delete['rc'] not in [0, 1] changed_when: r_versionlock_delete['rc'] == 0 ignore_errors: true register: r_versionlock_delete loop: "{{ all_pkgs }}" - name: End host ansible.builtin.meta: end_host - name: Ensure yum-plugin-versionlock is present ansible.builtin.yum: name: yum-plugin-versionlock state: present - name: Check provided list of packages and versionlock as needed ansible.builtin.include_tasks: tasks/lock_pkg.yml loop: "{{ lock_pkgs }}" - name: Ensure dependencies are installed ansible.builtin.yum: name: "{{ lock_pkgs }}" state: present allow_downgrade: true