1

I have below files csi.yaml file, it include the roles beased on the OS version. this work but if I run it on CentOS 8, its giving skipping: message all the task in RHEL7-CIS tasks.

roles:
   - { role: RHEL7-CIS, when: ansible_distribution == "CentOS" and ansible_distribution_major_version == '7' }
   - { role: RHEL8-CIS, when: ansible_distribution == "CentOS" and ansible_distribution_major_version == '8' }

try to include the role based on OS version this but its giving error also.

 gather_facts: True
roles:
 - "RHEL{{ ansible_distribution_major_version }}-CIS"

ERROR! 'ansible_distribution_major_version' is undefined

Is there an alternate way of including the role based on OS version?

Thanks SR

sfgroups
  • 18,151
  • 28
  • 132
  • 204

1 Answers1

1

You can just suppress output from skipped tasks using custom callback. See this answer for details.

Vladimir
  • 615
  • 5
  • 12