--- - name: Version Lock hosts: temp become: false gather_facts: false vars: lock_pkgs: - httpd-2.4.57-5.el9 - httpd-tools-2.4.57-5.el9 # - httpd-2.4.6-18.el7_0 # - httpd-tools-2.4.6-18.el7_0 # lock_pkgs: # - 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 tasks: - name: Check if versionlock.list exists ansible.builtin.stat: path: /etc/yum/pluginconf.d/versionlock.list register: r_versionlock_list - name: Touch versionlock.list if it doesn't exist ansible.builtin.file: path: /etc/yum/pluginconf.d/versionlock.list state: touch mode: "0644" when: - not r_versionlock_list['stat']['exists'] | bool - name: Install yum-plugin-versionlock ansible.builtin.package: name: yum-plugin-versionlock state: present - name: Check list of packages and lock their version if needed ansible.builtin.include_tasks: tasks/lock_pkg.yml loop: "{{ lock_pkgs }}"