playbook is pending when I execute reboot command. How to avoid the pending?

Hello all,

My playbook process is:

  1. disable selinux

  2. do core tasks

  3. enable selinux

  4. reboot

Reboot operation is the last task. When I execute my playbook, the reboot task is pending, just like this:
My task:

- name: reboot
command: /sbin/reboot -f

the task result is pending:

TASK: [reboot] ****************************************************************

How to avoid playbook pending in my case? Thank you.

BR
Rella

I use the wait_for module to handle reboots. http://www.ansibleworks.com/docs/modules.html#wait-for

Mine continues after a reboot so it may not fit your needs exactly.

My question is reboot task is pending. If I add wait_for task, my playbook is still pending in reboot task.
It seems reboot task is not completed. wait_for task doesn’t run.

My playbook:

  • name: reboot
    command: /sbin/reboot -f

  • name: wait reboot
    wait_for: port=8080 delay=10

The result is:

TASK: [reboot] ****************************************************************

Hi Rella.

Please test this code.
Reboot is background process.
So, not pending.

- name: reboot
  shell: sleep 2s && /sbin/reboot &

Hi Rella.

Please refer to it.
It is old thread that talking about reboot.
https://groups.google.com/forum/#!msg/ansible-project/9KVUY8yBKww/FHnX6FUvrH8J

And I wrote sample-code about reboot, But it’s japanese…
http://qiita.com/volanja/items/d38fe0678848bae6902f#2-6

volanja

2013年12月27日金曜日 9時05分58秒 UTC+9 @volanja:

Here’s how I do it:

https://github.com/analytically/hadoop-ansible/blob/master/roles/2_aggregated_links/tasks/main.yml