1

ansible 2.3.0.0 和 python 版本 2.7.5

host_vars:

manager: Tom
asst_managers:
    - Gail
    - Susan
    - Larry

hotels:
   hotel1:
      address: 1113 Mockingbird ln
      rooms: 40
   hotel2:
      address: 2222 BlueJay Ln
      rooms: 20


task

- name: hot hotels
  template:
     src: hothotels.j2
     dest: /abc
  with_items: "{{ asst_manager }}"
  with_dict: "{{ hotels }}"

**ERROR! duplicate loop in task: items**   

template: hothotels.j2

"{{ manager }}"

assistant managers:
{% for asst in asst_managers %}
"{{ asst }}"

{% endfor %}

{% for (key,value) in hotels.iteritems(() %)
{{ item.key }}
address: {{ item.value.address }}
rooms: {{ item.value.address }}

{% endfor % }

如果我在没有“with_items”的情况下运行任务并且在没有经理和助理经理信息的情况下运行模板,它会运行但hotel2 在文件中两次,而hotel1 就是它。

谢谢

4

0 回答 0