Hi,
I am running ansible on centos 7.4.1708 . Not sure what I am doing wrong but the dictionary variables are not completely written by the copy module.
Here is my complete YAML file :
---
- hosts: localhost
gather_facts: False
vars:
var_dict1:
127.0.0.1: localhost
10.10.10.10: hostnameinternal1
10.20.10.10: hostnameinternal2
tasks:
- name: Copy the contents of var_dict1 to output1
copy:
content: |
{% for key in var_dict1 %}
{{ item.key}} {{item.value}}
{% endfor %}
dest: "/usershome/output1"
run_once: yes
with_dict: "{{ var_dict1 }}"
and here is the file /usershome/output1
127.0.0.1 localhost
127.0.0.1 localhost
127.0.0.1 localhost
my version
ansible 2.3.2.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.5 (default, Aug 4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
The first entry in the file is correct but the rest are duplicates of the first entry . I can correctly see that in verbose the item key and value are different inside the loop but not in the output file.
What is going wrong here?
Regards,
Abey