Ansible - actions BEFORE gathering facts

前端 未结 3 985
旧巷少年郎
旧巷少年郎 2021-01-31 07:36

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

gathe         


        
3条回答
  •  后悔当初
    2021-01-31 08:06

    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:
    

    In combination with gather_facts: no on playbook level the facts will only be fetched when above task is executed.

    Both in an example playbook:

    - hosts: all
      gather_facts: no
      tasks:
    
        - name: Some task executed before gathering facts
          # whatever task you want to run
    
        - name: Gathering facts
          setup:
    

提交回复
热议问题