I have written below script that will end the playbook if IOS version
running on router satisfies below conditions:
1.
Version is greater than or is 16.12.02 AND
2.
Version is NOT certain versions like 16.12.05 OR 16.09.06 OR 17.03.02',
etc as mentioned below.
But script does not work. When i run this for a device with version
16.12.05, script fails though it shouldn't be as per the condition.
But when i test the 'AND' and 'OR' condition separately, they work. It's
just that when i combine them, it doesn't seem to. What should i change?
tasks:
- name: GATHER DEVICE FACTS
ios_facts:
- name: END THIS PLAYBOOK IF DEVICE IS ALREADY RUNNING NEW IMAGE OR
HIGHER VERSION THAN THAT
fail:
msg: DEVICE IS ALREADY RUNNING NEW IMAGE OR HIGHER VERSION THAN
THAT. HENCE UPGRADE IS NOT NECESSARY
when:
- ansible_net_version is version('16.12.06', '>=')
- "ansible_net_version is version('16.12.05', '!=') or
ansible_net_version is version('16.09.06', '!=') or
ansible_net_version is version('17.03.02', '!=') or
ansible_net_version is version('17.03.03', '!=') or
ansible_net_version is version('17.05.01', '!=') or
ansible_net_version is version('17.07.01', '!=')"
I modified OR syntax and tried below syntax but didn't work:
- name: END THIS PLAYBOOK IF DEVICE IS ALREADY RUNNING NEW IMAGE OR HIGHER
VERSION THAN THAT
fail:
msg: DEVICE IS ALREADY RUNNING NEW IMAGE OR HIGHER VERSION THAN
THAT. HENCE UPGRADE IS NOT NECESSARY
when:
- ansible_net_version is version('16.12.04', '>=')
- (ansible_net_version is version('16.12.05', '!=') or
ansible_net_version is version('16.09.06', '!=') or ansible_net_version is
version('17.03.02', '!=') or ansible_net_version is version('17.03.03',
'!='))
Thanks,
Vikram
--
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/f3bd2d53-f445-4b30-89c1-1eb2ec41ba4dn%40googlegroups.com.