Question:
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
:
1 2 3 4 |
# service networking restart stop: Job failed while stopping start: Job is already running: networking |
The following works on the command line, but with Ansible (1.8.4) it locks you out:
1 2 |
command: ifdown eth0 && ifup eth0 |
ifdown
takes down the interface, but ifup
doesn’t run
How to restart the interface?
Answer:
The solution is to run the command in a new shell:
1 2 |
command: bash -c "ifdown eth0 && ifup eth0" |
You can also use the shell module:
1 2 |
shell: "ifdown eth0 && ifup eth0" |