Last active
          July 27, 2023 21:02 
        
      - 
      
- 
        Save sheldonh/7203512 to your computer and use it in GitHub Desktop. 
    Wait for SSH to come up in an Ansible playbook
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | --- | |
| - hosts: demo | |
| tags: wait | |
| gather_facts: no | |
| tasks: | |
| - name: Wait for SSH | |
| local_action: wait_for port=22 host={% if ansible_ssh_host is defined %}{{ ansible_ssh_host }}{% else %}{{ inventory_hostname }}{% endif %} | 
https://docs.ansible.com/ansible/2.5/modules/wait_for_connection_module.html could also be an option.
FYI I just found some awesome syntax which simplifies your host variable:
{{ ansible_ssh_host|default(inventory_hostname) }}
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Thanks for this! New to ansible and didnt't realize
gather_facts: noexisted!