Ansible - actions BEFORE gathering facts

前端 未结 3 987
旧巷少年郎
旧巷少年郎 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:25

    Something like this should work:

    - 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...
    

    The wait_for will execute locally on your ansible host, waiting for the servers to respond on port 22, then the setup module will perform fact gathering, after which you can do whatever else you need to do.

提交回复
热议问题