I have an Ansible playbook for creating [Linode](
https://linode.com) servers. The problem I'm having is that my playbook isn't able to determine when the new server is up. I'm using Ansible 2.8.4. My playbook is as follows:
---
hosts: 127.0.0.1
gather_facts: False
- name: create server
linode_v4:
label: "{{ host_name }}_{{ 100 | random }}"
access_token: "{{ linode_api4_key }}"
type: "{{ plan_1GB }}"
region: "{{ region_us_central }}"
image: "{{ image_debian_10 }}"
root_pass: "{{ linode_root_password }}"
authorized_keys: "{{ my_ssh_public_key }}"
tags: "inventory.ini"
state: present
register: linode
- name: save new server's ip address to a fact
set_fact: ip_addr={{ linode.instance.ipv4 }}
tags: always
- debug:
var: ip_addr
- name: wait until new server is up
wait_for:
state: started
host: "{{ ip_addr }}"
port: 22
delay: 2
timeout: 600
msg: "Server port is not listening"
tags: always
I also tried it this way:
- name: wait until new server is up
local_action:
module: wait_for
state: started
host: "{{ ip_addr }}"
port: 22
delay: 1
timeout: 100
I've tried doing it using a wait_for and also via local_action but neither one is working. The playbook never returns from the wait for task. I monitor my Linode dashboard as the playbook runs and I can see that that IP address I'm feeding to the task via "ip_addr" is correct and the dashboard also shows me when the server is up. Can anyone see what I doing wrong? Thanks!