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/327a33bd-c47e-4c23-835a-4674b0c987de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to