Thanks Jean-Yves!

On Tuesday, January 7, 2020 at 2:24:13 PM UTC-8, Jean-Yves LENHOF wrote:
>
>
> Le 07/01/2020 à 22:55, RobertF a écrit : 
> > 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! 
>
> Hi, 
>
> You should probably use "wait_for_connection" module instead of the one 
> you use 
>
> This is how I use it : 
>
> - hosts: newly_managed_vms 
>    become: yes 
>    become_user: root 
>    remote_user: ansible 
>    gather_facts: no   # servers could be not available yet 
>    tasks: 
>
>    - name: "Wait for server to power up" 
>      wait_for_connection: 
>        sleep: 5 
>        timeout: 600 
>
>    - name: "Gather facts for first time" 
>      setup: 
>
> Regards, 
>
> JYL 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/50297615-ae54-4998-aedd-69e6e3a186d6%40googlegroups.com.

Reply via email to