Hi,
I am trying with the first task of the playbook with assert module to
validate the supported versions. If Assert is success, then only the next
tasks will be executed .
- name: Playbook to test the conditional
hosts: localhost
vars:
rhel_ver:
- 9
- 8
- 7
centos_ver:
- 8
- 7
tasks:
- name: Check the OS version and proceed based on the OS
ansible.builtin.assert:
that:
- ansible_distribution == "CentOS" and
ansible_distribution_major_version == "{{ centos_ver }}"
- ansible_distribution == "RedHat" and
ansible_distribution_major_version == "{{ rhel_ver }}"
fail_msg: "Unsupported OS version. Exiting ..... "
success_msg: "Supported OS version and proceeding to next task"
- debug:
msg: "Completed"
The Asset have to be Success with multiple conditions .. If either the
distribution is RedHat or CentOS(not both conditions need to be true) and
the major version is atleast one of the value from the variables(of its OS
distro).
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/c2457c47-2460-47d4-86d0-4e872f7c5dd9n%40googlegroups.com.