try this:
- name: Restart server
shell: sleep 3; shutdown -r now
async: 1
poll: 0
ignore_errors: true
On Mon, Jun 8, 2015 at 1:14 PM, Konstantin Šuvakin
konstantin.suva...@gmail.com wrote:
Thank you Mikhail, working on Debian 8 too ( same issue with reboot -
playbook stale on server reboot ).
Dňa pondelok, 13. apríla 2015 18:20:49 UTC+2 Mikhail Koshelev napísal(-a):
That is because systemd in CentOS 7 is usually quite fast to stop the
system. In my experience modules don't get a chance to complete and return
the results (even with async) in this case. As couple of minutes delay
wasn't a big deal in the particular scenario, I ended up with added delay
in shutdown for CentOS 7, like this (replace 'osid' with whatever proper
Ansible variables):
# note - centos7 shutdown do scheduling and returns immediately,
centos5/6 shutdown blocks till the actual reboot time
# use 1 min delay for centos7 or else systemd stops the host before
task returns
- name: Reboot system because of kernel update
raw: /sbin/shutdown -r {{ '1' if osid == 'centos7' else 'now' }}
changed_when: True
- name: Wait for system to complete reboot (5 min max / 90 sec delay)
wait_for: host={{ ansible_default_ipv4.address }} port=22 timeout={{ 5
* 60 }} delay=90 state=started
delegate_to: 127.0.0.1
Regards,
Mikhail
On Sunday, April 12, 2015 at 4:57:19 AM UTC-7, Giovanni Tirloni wrote:
On Thursday, March 26, 2015 at 6:57:01 AM UTC-3, codfather wrote:
Here is the working one.
You say it's working but do you continue playbook execution after the
restart?
I'm also trying to use a task to restart my servers but I would like to
wait_for them to come back and continue executing other tasks.
I've tried all variations of the above task (changing async, poll,
ignore_errors, switch command/shell modules, etc) but I always get the
following error:
fatal: [server] = SSH Error: Shared connection to 1.2.3.4 closed.
It is sometimes useful to re-run the command using -, which prints
SSH debug output to help diagnose the issue.
It seems that the connection is closed too fast and Ansible doesn't
understand what is happening.
Can anyone confirm this is the right way to reboot a server and continue
playbook execution in Ansible 1.9.0.1?
- name: Restart server
shell: shutdown -r now
async: 0
poll: 0
ignore_errors: true
It doesn't even reach the local_action tasks with the wait_for module.
This is on CentOS 7.1 x86_64 running on a Digital Ocean VM.
Thanks,
Giovanni
--
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/43e640c8-c723-4b11-b1aa-d63e3839b83b%40googlegroups.com
https://groups.google.com/d/msgid/ansible-project/43e640c8-c723-4b11-b1aa-d63e3839b83b%40googlegroups.com?utm_medium=emailutm_source=footer
.
For more options, visit https://groups.google.com/d/optout.
--
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAFUV_d5bpxGYTJCJ5cg0ABtkCs%3Do%3DcS%2Bez%2B%3DfawD35w7YV%2Bn-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.