Have a look at async/poll
<http://docs.ansible.com/ansible/playbooks_async.html>. This isn't what it
was designed for, but it will likely solve your issue... You'll probably
want to do a sleep 5 && in front of the ifdown/ifup just to make sure that
the async daemonization has occurred and returned the jid to Ansible before
bouncing the interface (if it happens too quickly, you'll see the same
issue).
I'd suggest an initial async value of 30 and poll 10. It'll be a little
slower than it probably needs to be, but should be very safe from any races
that way.
On Thursday, May 5, 2016 at 7:44:07 AM UTC-7, Carl Wainwright wrote:
>
> Hello,
>
> I am using Ansible to update templated VM machines with correct
> networking. My inventory contains the templated hosts [nos5] and the
> deployed host [nos6]. It should be noted that the interface I am changing
> is the one I'm using in Ansible .
>
> The Ansible playbook successfully updates the ifcfg-eth0 file and restarts
> the network. However, it hangs for about 1-2 minutes before returning a
> failure code.
>
> fatal: [nos5]: FAILED! => {"changed": false, "failed": true, "invocation":
>> {"module_name": "command"}, "module_stderr": "", "module_stdout": "\r\n",
>> "msg": "MODULE FAILURE", "parsed": false}
>>
>
> The tasks I'm executing are as follows.
>
> - name: Update Networking for NOS
>> lineinfile:
>> dest: /etc/sysconfig/network-scripts/ifcfg-eth0
>> regexp: "^IPADDR"
>> line: "IPADDR=10.157.{{ VDC_Number }}.100"
>> when: target_vm == "NOS"
>> register: network_nos_ok
>>
>> - name: Bounce the interface
>> shell: ifdown eth0; ifup eth0
>> when: target_vm == "NOS" and network_nos_ok is defined
>>
>
> The starting IP is 10.157.5.100, and the changed IP is 10.157.6.100.
>
> Is there a way to make this happen without the excessive delaty and report
> success?
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/c09f9762-6f2a-48cb-8a71-32039fdb4aea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.