I am attempting to create a unique list of values between two lists and I 
am creating a set based on the documentation described here 
http://docs.ansible.com/playbooks_variables.html#set-theory-filters



According to the documentation:

To get a union of two lists:

{{ list1 | union(list2) }}



Therefore I am attempting this in my playbook:

- name: A
  set_fact:
      listA: "{{test1.stdout.split()}}"
      listB: "{{test2.stdout.split()}}"

Test1 and Test2 output a list object and have been verified. The above 
produces two lists as an example lets assume:

listA = ['apple', 'orange', 'tree', 'pear']
listB = ['tree', 'orange']

Now I want to get a union of both listA and listB

- name: B
  set_fact: test="{{listA | union(listB) }}"

This produces the result below:

{"ansible_facts": {"test": "set(["tree", "orange"])"}, "item": ""}


My problem is the fact test is assigned a string value of "set(["tree", 
"orange"])" and not the set object, I need to operate on the set object. 
Can this be done?  If not is there any other way within Ansible to get a 
unique list from two lists?

-- 
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/caefc255-238c-4498-ad58-95b63fef4afa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to