On 2/16/21 9:04 AM, Vikram S wrote: > 1st playbook uses ios_command module and gets executed as intended (to > display the output when hostname of device > contains router1). > > However 2nd playbook uses ios_config module and fails when i use the 'when' > conditional. Am i do something wrong or is > it that 'when' conditional is not supposed to work with ios_config module? > (please ignore the formatting) >
First of all output.stdout is not a list but a string.
Can you provide sample output?
Regards
Racke
> ---
>
> - name: show hostname
>
> hosts: R1
>
>
> tasks:
>
> - name: show hostname
>
> ios_command:
>
> commands: "show run | i hostname"
>
>
>
> register: output
>
>
>
> - debug:
>
> var: output
>
> when: "'router1' in output.stdout[0]"
>
> -------------------------------------------------
>
> ---
>
> - name: show hostname
>
> hosts: R1
>
>
> tasks:
>
> - name: show hostname
>
> ios_config:
>
> lines:
>
> - hostname router1
>
>
>
> register: output
>
>
>
> - debug:
>
> var: output
>
> when: "'router1' in output.stdout[0]"
>
> -------------------------------------------------
>
>
> --
> 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]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/8bb51686-7f9a-4c88-8148-b94063103649n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/8bb51686-7f9a-4c88-8148-b94063103649n%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.
--
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/05ecb757-2a31-ab4b-0b8e-d28796f89072%40linuxia.de.
OpenPGP_signature
Description: OpenPGP digital signature
