I am trying to user variables in the below example described here 
<http://docs.ansible.com/ansible/playbooks_loops.html#standard-loops>.


- name: add several users 
  user: name={{ item.name }} 
  state=present groups={{ item.groups }} 
  with_items: 
    - { name: 'testuser1', groups: 'wheel' } 
    - { name: 'testuser2', groups: 'root' }


This works fine, but when I try to infuse variables, it does not works as 
intended. I am sure, I am doing something wrong.

I've defined two lists in my playbook
  vars:
    - old:
        - ens155
        - ens160
    - new:
        - eth0
        - eth1


I am trying to make below code work like *ens155 is eth0* and *ens160 is 
eth1*, but this code shows this message - *[ens155, ens160] is [eth0, eth1]*

- shell: echo {{ item.old }} is {{ item.new }}
    with_items:
      - { old: '{{ old }}', new: '{{ new }}' }

How can I make this work ? If required, I am happy to change the way my 
variables are defined.

Regards.

-- 
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/5de25029-3e8e-45ca-9903-d74efb4f2bbe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to