The task is still being skipped even though the VLAN 200 is present in the 
variable test.

Can I confirm the syntax is correct? I have written it like:

        lines: 

          - switchport access vlan 200

          - description nan

          - no shutdown

        parents: 

          - interface e01

      when: "'200' in test.stdout"


thanks


On Friday, March 3, 2017 at 3:33:57 PM UTC, [email protected] wrote:
>
> Hello,
>
> I am trying to enforce a conditional match to check if a VLAN is 
> configured on a switch before applying changes
>
> I can see that the variable is being recorded, but the match against it 
> always results in the skipping of the task 'interface e01' even though the 
> vlan number is present.
>
>
> PLAY [arista] 
> ******************************************************************
>
>
> TASK [check VLAN] 
> **************************************************************
>
> ok: [arista]
>
>
> TASK [debug] 
> *******************************************************************
>
> ok: [arista] => {
>
>     "msg": "test: [u'VLAN  Name                             Status    
> Ports\\n----- -------------------------------- --------- 
> -------------------------------\\n1     default                          
> active    Et2, Et3\\n100   VLAN0100                         active    
> Et1\\n200   VLAN0200                         active   \\n']"
>
> }
>
>
> TASK [interface e01] 
> ***********************************************************
>
> skipping: [arista]
>
>
>
> playbook file:
>
>
> ---
>
>
> - hosts: arista
>
>   gather_facts: no
>
>   connection: local
>
>   strategy: free
>
>   tasks:
>
>     - name: check VLAN
>
>       ignore_errors: yes
>
>       eos_command:
>
>         host: arista
>
>         username: admin
>
>         password: ccc
>
>         commands:
>
>           - show vlan
>
>       register: test
>
>     - debug:
>
>         msg: "test: {{ test.stdout }}"
>
>     - name: interface e01
>
>       ignore_errors: yes
>
>       eos_config:
>
>         host: arista
>
>         username: admin
>
>         password: ccc
>
>         authorize: yes 
>
>         lines: 
>
>           - switchport access vlan 200
>
>           - no shutdown
>
>         parents: 
>
>           - interface Ethernet1
>
>       when: '"200" in test'
>

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/949e8dce-ce8a-454d-89c7-dab53223418e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to