This is my configuration array.
tomcatsconfs:
- {instance: tc-p1_i01_3001, port: 30011, connector: ajp-nio-, connector_port: 30012}
- {instance: tc-p1_i02_3002, port: 30021, connector: ajp-nio-, connector_port: 30022}
- {instance: tc-p1_i03_3003, port: 30031, connector: ajp-nio-, connector_port: 30032}
Now I woul like to create a nrpe.cfg with a jinja2 template with these task:
- name: copy nrpe.conf from template
template: src=nrpe.cfg.j2 dest=/etc/nagios/nrpe.cfg mode=0644 owner=root group=root
with_items:
- tomcatsconfs
Ansible transfers this array as a dictionary.
+[{u'connector': u'ajp-nio-', u'instance': u'tc-p1_i01_3001', u'connector_port': 30012, u'port': 30011}, {u'connector': u'ajp-nio-', u'instance': u'tc-p1_i02_3002', u'connector_port': 30022, u'port': 30021}, {u'connector': u'ajp-nio-', u'instance': u'tc-p1_i03_3003', u'connector_port': 30032, u'port': 30031}]
And I try to iterate this dictionary with this loop
{% for key value in tomcatconfs.iteritems() %}
key value
{% endfor %}
But I get the error message:
failed: [host] (item=tomcatconfs) => {"failed": true, "item": "tomcatconfs", "msg": "AnsibleUndefinedVariable: 'list object' has no attribute 'iteritems'"}
How I can iterate this dictionary in this template?
Greetings niesel