Hi,
Le 15/03/2018 à 15:21,
rrak...@gmail.com a écrit :
> Hello Friends,
>
> Does anyone have experience using the reboot playbook on RHEL systems,
> i'm using below method and it reboots the systems but in between while
> system is rebooting it breaks the connection and does not wait for
> post reboot status like uptime, if someone already overcomed this
> please let me know , my play looks like below...
>
> ---
> - name: Reboot a host and wait for it to return
> hosts: postinstall
> remote_user: root
>
> tasks:
> - name: check automount
> service: name=autofs state=stopped
>
> - name: reboot host
> shell: sleep 10 && /sbin/shutdown -r now
> async: 360
> poll: 0
> become: true
Without any log of what's the problem exactly is, it's not so obvious to
help you... Did you try to add a sleep just after the shutdown (on the
shell line) like written in this article ?
https://stackoverflow.com/questions/23877781/how-to-wait-for-server-restart-using-ansible
>
> - name: waiting for server booting up
> local_action: wait_for host="{{ inventory_hostname }}" port=22
> delay=5 timeout=360
>
>
> - name: check uptime
> local_action: shell ansible -u {{ ansible_user_id }} -m ping {{
> inventory_hostname }}
> register: result
> until: result.rc == 0
> retries: 30
> delay: 10
Why using shell to do an ansible ping ?
You can use it directly.... Try to always avoid shell module
>
> # And finally, execute 'uptime' when the host is back.
> - shell: uptime
There's a fact for this :
ansible_uptime_seconds
Why not using it ?
Regards,
JYL