The async wrapper is notoriously slow about daemonizing the module process 
and capturing its output, so you'll need to increase the sleep delay to 
probably at least 5s to reliably get this working. You'll also definitely 
want async: 0 (which makes it "fire and forget" instead of polling for a 
result, which will never succeed). Then you'll need to use wait_for on the 
next task and watch for the ssh port to come back up before continuing your 
playbook. Even this is not 100% reliable- there are several different 
shutdown/startup races involved that can make it flaky, depending on what 
your target OS is.

I wrote the windows reboot action (win_reboot), and I just finished 
(re)writing a *nix-friendly version that will likely ship in Ansible 2.3- 
I've tested against several popular distros with success... Unfortunately 
to work properly, it needs a change to the base connection layer, so you 
won't be able to just drop the action plugin into Ansible 2.2.x and have it 
work.

-Matt


On Monday, December 19, 2016 at 12:17:30 PM UTC-8, Chris Parish wrote:
>
> Hi,
>
> I am trying to get my remote machine to reboot using the following code
>
> - name: restart machine
>   shell: sleep 2 && shutdown -r now "Ansible updates triggered"
>   async: 1
>   poll: 0
>   sudo: true
>   ignore_errors: true
>
> - name: waiting for server to come back
>   local_action: wait_for host={{ static_ip }} state=started delay=30 
> timeout=300
>   sudo: false
>
> No matter what I try I keep getting the following error:
>
>
> fatal: [192.168.0.11]: FAILED! => {
>     "changed": false,
>     "failed": true,
>     "module_stderr": "Shared connection to 192.168.0.11 closed.\r\n",
>     "module_stdout": "\r\n/bin/sh: 1: 
> /home/pi/.ansible/tmp/ansible-tmp-1481969769.79-144484795431651/async_wrapper.py:
>  
> not found\r\n",
>     "msg": "MODULE FAILURE"
> }
>
> I cannot find any information about this and I have no idea where to start.
> I have tried:
>
>
>    - changing the shell command
>    - increasing the async value
>
> If you set async to 0 then it doesn't generate the error, but you get a 
> different error because you can't reboot on a synchronous command.
>
>
> Ideas?
>

-- 
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/a71b56d6-60a8-4315-8044-463cea0f63bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to