I am wondering how it's possible to compare two lists in ansible with jinja2 templating and just get the difference between the lists.
Let's say we have two lists: customers and exclude_customers
customers:
- name: A
git: true
version: 7.2.8
- name: B
git: true
- name: components
git: true
- name: Editor
git: true
exclude_customers:
- name: components
- name: Editor
In this example, I would expect a result with the values A and B.
{% for customer in customers| difference(['exclude_customers']) | map (attribute='name') %}
{{ customer.name }}
{% endfor %}
But I got this error:
AnsibleUndefinedVariable: 'ansible.parsing.yaml.objects.AnsibleUnicode object' has no attribute 'name'
Thanks