Hi All, been tearing my hair out this AM on this one so I think Im just 
doing something wrong.  Long story short, I have two lists in my playbook.  
One that contains a set of commands from a device and another that contains 
the set of commands I wish to configure.  What I'd like to do is diff them 
to come up with which commands should not be present on the device.  In 
other words, Im comparing the active state of the device to the 
configuration and getting the delta.  This seems to be working well and Im 
able to generate both lists and compare them using the jinja filter 
'difference'.  Here's a sample playbook...

---
- hosts: 127.0.0.1
  connection: local
  gather_facts: false
  vars:
    device_config:
      - "set vlan name test1"
      - "set vlan name test2"
      - "set hostname testdevice4"
    intended_config:
      - "set vlan name test1"
      - "set vlan name test3"
      - "set hostname testdevice6"

  tasks:
    - name: debug list differences
      debug: 
        var: "{{item}}"
      with_items:
          device_config | difference(intended_config)


The output of this is a list of commands that are present in the 
device_config list, but not in the intended_config.  This works great!  
However, I want to filter this output to only include items that are of a 
particular type.  So for instance, assume that I change the task to look 
like this...
  tasks:
    - name: debug list differences
      debug: 
        var: "{{item}}"
      when: 
        '"vlan" in item'
      with_items:
          device_config | difference(intended_config)

In this case, I want to only return lines that are different, and include 
the string 'vlan'.  However, when I run this, the playbook comes back and 
tells me that the step was skipped...
"skip_reason": "Conditional check failed", 

So I can't sort this out.  I know that typically you use 'in' to search for 
an entire match of a list item, but I swear I've done this before and it 
works.  Any ideas on what Im doing wrong?

Thanks!


-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5e6fd7f8-806a-40d6-940e-db92ffc53776%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to