在特定主机组中的Ansible中检查wait_for不起作用 [英] Checking wait_for in Ansible in a particular host group does not work
本文介绍了在特定主机组中的Ansible中检查wait_for不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一本类似
---
- name: testplaybook
hosts:
gather_facts: yes
roles:
-role: samplerole
角色:
- name: checking for port open
wait-for:
timeout: 3
host: groups['git_groups']
port: 7809
ignore_error: yes
register: port_check
对于上面的代码,主机: groups ['git_groups']
在这里不能作为输入.当我运行剧本时,它将检查主机的整个列表,而不是特定的组.
For the above code the host: groups['git_groups']
doesn't work as an input here. When I run the playbook, it checks for the entire lists of hosts rather than that particular group.
推荐答案
您不能将任意数据结构(以您的情况为列表)提供给需要字符串的模块参数("
You cannot feed an arbitrary data structure (list in your case) to an argument of a module which requires a string ("A resolvable hostname or IP address to wait for").
您应该使用 with_items
循环:
You should use a with_items
loop:
- name: checking for port open
wait_for:
timeout: 3
host: "{{ item }}"
port: 7809
ignore_error: yes
register: port_check
with_items: "{{ groups['git_groups'] }}"
您还有两个任务指令的缩进错误.
这篇关于在特定主机组中的Ansible中检查wait_for不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文