Ansible-收集事实之前的行动 [英] Ansible - actions BEFORE gathering facts

查看:86
本文介绍了Ansible-收集事实之前的行动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何做事(例如等待受管节点的端口/启动)吗?之前收集事实?我知道我可以关闭收集的事实

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆