有没有人知道如何做某事(比如等待受管节点的端口/启动) BEFORE 收集事实?我知道我可以关闭收集事实
-- open file
ignoring application responses -- don't wait for user input
tell application "Ableton Live 9 Suite" to open "Users:username:Desktop:LiveSet Project:LiveSet.als"
end ignoring
-- use delay if needed
-- delay 0.5
-- skip saving file
tell application "System Events"
set frontmost of process "Live" to true
key code 123 -- left
key code 123 -- left
keystroke return -- enter
end tell
和 THEN 等待端口,但是如果我还需要等到节点启动的话还需要等等?
答案 0 :(得分:52)
收集事实等同于运行setup
module。您可以通过运行来手动收集事实。它没有记录,只是添加这样的任务:
gather_facts: no
在playbook级别结合- hosts: all
gather_facts: no
tasks:
- name: Some task executed before gathering facts
# whatever task you want to run
- name: Gathering facts
setup:
,只有在执行上述任务时才会获取事实。
两者都在一个示例剧本中:
{{1}}
答案 1 :(得分:20)
这样的事情应该有效:
- hosts: my_hosts
gather_facts: no
tasks:
- name: wait for SSH to respond on all hosts
local_action: wait_for port=22
- name: gather facts
setup:
- continue with my tasks...
wait_for将在你的ansible主机上本地执行,等待服务器在端口22上响应,然后安装模块将执行事实收集,之后你可以做任何你需要做的事情。
答案 2 :(得分:1)
我试图弄清楚如何从ec2配置主机,等待ssh出现,然后针对它运行我的剧本。这与您的用例基本相同。我最终得到了以下内容:
- name: Provision App Server from Amazon
hosts: localhost
gather_facts: False
tasks:
# #### call ec2 provisioning tasks here ####
- name: Add new instance to host group
add_host: hostname="{{item.private_ip}}" groupname="appServer"
with_items: ec2.instances
- name: Configure App Server
hosts: appServer
remote_user: ubuntu
gather_facts: True
tasks: ----configuration tasks here----
我认为ansible术语是我在剧本中有两个剧本,每个剧集在不同的主机组(localhost和appServer组)上运行