具有动态组名的Ansible嵌套循环

具有动态组名的Ansible嵌套循环,ansible,ansible-playbook,Ansible,Ansible Playbook,我的vars文件: applications: - name: server_1 deploy: True branch: master group: frontend - name: server_2 deploy: True branch: master group: backend 我的任务是 - name: deploy boxer command: "curl http://example.com?hosts={{item.

我的vars文件:

applications:
  - name: server_1
    deploy: True
    branch: master
    group: frontend
  - name: server_2
    deploy: True
    branch: master
    group: backend
我的任务是

- name: deploy boxer
  command: "curl http://example.com?hosts={{item.1}}"
  with_subelements:
    - applications
    - "{{ groups[group] }}" # This is not working.
存货清单

[frontend]
host1.example.com
host2.example.com

[backend]
host11.example.com
host12.example.com
我希望遍历应用程序,并循环遍历组中的每个主机(一次仅一个主机)以将其传递给curl命令

我想把这个放在最后

curl http://example.com?hosts=host1.example.com
curl http://example.com?hosts=host2.example.com
curl http://example.com?hosts=host11.example.com
curl http://example.com?hosts=host12.example.com
你想用它吗


我犯了这个错误。失败!=>{“failed”:true,“msg”:“ERROR!条件检查'item.0.group==item.1'失败。错误是:ERROR!计算条件时出错(item.0.group==item.1):ERROR!None'没有属性'group'\n\nOh是的,
与_嵌套的
是真的。item.1没有给我主机名。我想遍历所有主机名。
 with_nested:
   - "{{ applications }}"
   - "{{ groups }}"
 when: item.0.group == item.1