I think you want "in" rather than "==" to verify if your OS release is in the corresponding list.
On Tue, 10 Oct 2023, 17:51 Veera, <[email protected]> wrote: > 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 > <https://groups.google.com/d/msgid/ansible-project/c2457c47-2460-47d4-86d0-4e872f7c5dd9n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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/CAKtKohQJ%2BfnUXVr8B7Ou9qjSAPa9w4ULbTCkixXauYXaAbh0HQ%40mail.gmail.com.
