Ansible - 在收集事实之前采取的行动 [英] Ansible - actions BEFORE gathering facts
问题描述
有谁知道如何做一些事情(例如等待托管节点的端口/启动)之前收集事实?我知道我可以关闭收集事实
Does anyone know how to do something (like wait for port / boot of the managed node) BEFORE gathering facts? I know I can turn gathering facts off
gather_facts: no
和THEN等待端口但如果我需要事实同时还需要等到节点启动怎么办?
and THEN wait for port but what if I need the facts while also still need to wait until the node boots up?
推荐答案
收集事实相当于运行 <代码>设置代码>模块.您可以通过运行它来手动收集事实.它没有记录,只是简单地添加一个这样的任务:
Gathering facts is equivalent to running the setup
module. You can manually gather facts by running it. It's not documented, but simply add a task like this:
- name: Gathering facts
setup:
结合 gather_facts: no
在剧本级别,只有在执行上述任务时才会获取事实.
In combination with gather_facts: no
on playbook level the facts will only be fetched when above task is executed.
都在示例剧本中:
- hosts: all
gather_facts: no
tasks:
- name: Some task executed before gathering facts
# whatever task you want to run
- name: Gathering facts
setup:
这篇关于Ansible - 在收集事实之前采取的行动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!