Ansible: restart networking on Ubuntu


If you need to restart the networking in the middle of a play on an Ubuntu server (12.04 in my case) you can’t use service:

The following works on the command line, but with Ansible (1.8.4) it locks you out:

ifdown takes down the interface, but ifup doesn’t run

How to restart the interface?


The solution is to run the command in a new shell:

You can also use the shell module:

Leave a Reply