Hello Everyone,
I've a task -
- name: Device Description
uri:
url: "{{ URL }}/api-db?username={{ USERNAME }};password={{
PASSWORD }};cmds=mget+*+{{ display_name }}+sys+SNMPv2-MIB.sysDescr"
validate_certs: no
method: GET
return_content: yes
register: get_descriptions
Debug Output
- debug: msg="{{ get_descriptions.content }}"
ok: [localhost] =>
msg: |-
sw01 sys SNMPv2-MIB.sysDescr = Cisco IOS C2960S (C2960S-UNIVERSALK9-M)
Version 12.2(55)SE7 RELEASE (fc1)
I'm able to configure the when to run only when - Cisco IOS C2960S found in
the output
- debug: msg="{{ get_descriptions.content }}"
when: "'Cisco IOS C2960S' in get_descriptions.content"
I've created a devices.yml
---
cisco10g:
- C2960S
- c2960x
- c3560x
- debug: msg="{{ cisco10g }}"
Output-
TASK [debug]
********************************************************************************************************************************************************
ok: [localhost] =>
msg:
- C2960S
- c2960x
- c3560x
- ct5520
I want to check the entries of devices from the file and only run when it's
found. Like below -
- debug: msg="{{ get_descriptions.content }}"
when: get_descriptions.content in cisco10g
When I'm writing the code this way. It is always skipping.
please advise
Thanks in advance.
--
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/a830c2ec-14df-43ab-ba03-1abbfd9bd114n%40googlegroups.com.