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?
推荐答案
收集事实等同于运行 setup
模块.您可以通过运行它来手动收集事实.它没有记录,只是添加一个像这样的任务:
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屋!