Thanks for the hint Serge - you put me on the right track to the solution.

As you rightly said there was more needed in the yml file

Here is the working one.

---
- hosts: all
  sudo: yes
  tasks:
    - name: restart server
      command: /sbin/reboot
      async: 0
      poll: 0
      ignore_errors: true
    - name: wait for the server to restart
      local_action: wait_for host={{ inventory_hostname }}
                    port=22
                    delay=1
                    timeout=300
                    state=started
      sudo: false 

Cheers


On Wednesday, 4 March 2015 17:02:46 UTC, codfather wrote:
>
> After much googling I haven't found a solution to this. I want to reboot a 
> single server from a group of servers in my hosts file. This is being done 
> on OSX, with ansible 1.8.
>
> Playbook:
>
> - name: restart server
>   command: /sbin/reboot
>
> - name: wait for the server to restart
>   local_action:
>     module: wait_for
>       host={{ inventory_hostname }}
>       port=22
>       delay=1
>       timeout=300
>     sudo: false
>
> The command being run:
>
> ansible-playbook -l <hostname-to-reboot> -i ~/ansible_hosts 
> ~/ans-reboot.yml --ask-sudo-pass
>
> Here is the result:
>
> ERROR: command is not a legal parameter at this level in an Ansible 
> Playbook
>
> I have tried substiting the command: with shell: with no improvement.
>
> I have also looked at the following site which seems to suggestion I'm on 
> the right track:
>
>
> https://support.ansible.com/hc/en-us/articles/201958037-Reboot-a-server-and-wait-for-it-to-come-back
>
> So any pointers and tips gratefully received.
>
> Nick
>

-- 
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/89926e71-a5d1-496a-ad20-25c7a30499f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to