Trying to use wait_for to sequence a set of reboots

48 views
Skip to first unread message

leam hall

unread,
Oct 3, 2017, 11:14:31 AM10/3/17
to Ansible Project
Not doing well.

It starts here:   https://github.com/LeamHall/Ansible_Test/blob/master/playbooks/reboot_nodes.yml

- hosts: b2532_vms
   become: True

  vars:
     hosts:
       - genesis
       - exodus

   roles:
    - reboot

Which should call playbooks/roles/reboot/tasks/main.yml:  https://github.com/LeamHall/Ansible_Test/blob/master/playbooks/roles/reboot/tasks/main.yml

- name: reboot_and_wait_for
   include: reboot_node.yml
   include: wait_for.yml
   include: debug.yml

   with_items:
     - "{{ hosts }}"


Which should call:  https://github.com/LeamHall/Ansible_Test/blob/master/playbooks/roles/reboot/tasks/reboot_node.yml

- name: reboot
   command: /sbin/reboot

But doesn't. It does call the debug.yml file which just says "Hello there!"

Ideas? The goal is to reboot and wait_for each host in turn.

Leam

Kai Stian Olstad

unread,
Oct 3, 2017, 11:31:57 AM10/3/17
to ansible...@googlegroups.com
On 03. okt. 2017 17:14, leam hall wrote:
> Which should call playbooks/roles/reboot/tasks/main.yml:
> https://github.com/LeamHall/Ansible_Test/blob/master/playbooks/roles/reboot/tasks/main.yml
>
> - name: reboot_and_wait_for
> include: reboot_node.yml
> include: wait_for.yml
> include: debug.yml
>
> with_items:
> - "{{ hosts }}"
You can't have 3 includes in 1 task, you will need to split them into 3
separate tasks.


--
Kai Stian Olstad

leam hall

unread,
Oct 3, 2017, 11:37:06 AM10/3/17
to Ansible Project

Kai, thanks! The issue is that I'm really struggling to get the "wait_for" to work. I need to have the rebooted machine up before I boot the next one. Any good pointers to docs? Ansible docs say it can be done but don't seem to show you how.

 Leam

leam hall

unread,
Oct 3, 2017, 12:31:15 PM10/3/17
to Ansible Project


This is about the best I have so far. When I tried to put the duplicate tasks into a role it didn't work. May try an "include_tasks" after a nap.

https://github.com/LeamHall/Ansible_Test/blob/master/playbooks/reboot_nodes.yml

 

Philippe Eveque

unread,
Oct 3, 2017, 12:48:41 PM10/3/17
to ansible...@googlegroups.com
what I'm using as part of a (multi-hosts) play:

Task one is to async trigger the reboot
Task two the wait for ssh to come back (for each host in the play) 

    - name: Reboot the system
      shell: sleep 2 && shutdown -r now "Ansible reboot triggered"
      become: True
      async: 1
      poll: 0
      ignore_errors: true

    # FixMe: Trigger the wait for ssh on all the targets (long operation)
    - name: waiting for server to come back
      wait_for:
        host: "{{ inventory_hostname }}"
        port: 22
        delay: 15
        timeout: 1200
        connect_timeout: 15
        state: started
      delegate_to: localhost


--
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+unsubscribe@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/75ef60bc-c45d-49d0-ac97-03c0ee26e86c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages