redhat-cop / infra.leapp

Collection of Ansible roles for automating RHEL in-place upgrades using Leapp.
MIT License
43 stars 33 forks source link

remediate role fails due to reusing variable #190

Closed myllynen closed 1 month ago

myllynen commented 1 month ago

In remediate/tasks/main.yml the requested remediations are executed with:

- name: Remediate the system
  ansible.builtin.include_tasks: "{{ remediation }}.yml"
  loop: "{{ remediation_playbooks }}"
  loop_control:
    loop_var: remediation
  when: remediation in remediation_todo

But in remediate/tasks/leapp_missing_pkg.yml there are assumptions that remediation could be unset which can't be the case due to the above:

    - name: leapp_missing_pkg | End execution of playbook if no entry found in leapp report
      ansible.builtin.meta: end_host
      when: remediation is not defined

    - name: leapp_missing_pkg | Install the missing package via remediation command
      ansible.builtin.command: "{{ remediation.context | join(' ') }}"
      when: remediation is defined
      register: remediation_result
      changed_when: remediation_result.rc == 0

I'd change the variable in main.yml to something less generic and also would recommend to avoid the meta: end_host which a) duplicates the when check in the next task b) doesn't allow using this role in playbooks using more than just this role. Thanks.