# changing network IP and network restart

**URL:** <https://forum.ansible.com/t/changing-network-ip-and-network-restart/18400>\
**Category:** Ansible Developer\
**Created:** [June 4, 2015, 9:34am UTC](https://forum.ansible.com/t/changing-network-ip-and-network-restart/18400 "2015-06-04T09:34:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Billy](https://avatars.discourse-cdn.com/v4/letter/b/ecd19e/32.png) [@Billy](https://forum.ansible.com/u/Billy)\
**Post date:** [June 4, 2015, 9:34am UTC](https://forum.ansible.com/t/changing-network-ip-and-network-restart/18400/1 "2015-06-04T09:34:58Z")

</div>

Hi,

We’re renumbering our network. I can’t seem to get networking restarted. If I try with “fire and forget” (async 10 & poll 0) it reports:

PLAY [test-net] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

ok: [ansible-nw-test.iedr.ie]

TASK: [network-project | Set resolv.conf] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

ok: [ansible-nw-test.iedr.ie]

TASK: [network-project | Remove route-eth0 networking file] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

ok: [ansible-nw-test.iedr.ie]

TASK: [network-project | Update eth0 networking file] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

changed: [ansible-nw-test.iedr.ie]

TASK: [network-project | Restart networking] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

\<job 471496875238.17610\> finished on ansible-nw-test.iedr.ie

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

ansible-nw-test.iedr.ie : ok=6 changed=1 unreachable=0 failed=0

and on the remote host:

Jun 4 05:34:48 ansible-nw-test ansible-setup: Invoked with filter=\* fact\_path=/etc/ansible/facts.d

Jun 4 05:35:04 ansible-nw-test ansible-file: Invoked with directory\_mode=None force=False remote\_src=None path=/etc/resolv.conf owner=root follow=True group=None state=None content=NOT\_LOGGING\_PARAMETER serole=None diff\_peek=None setype=None dest=/etc/resolv.conf selevel=None original\_basename=resolv.conf.j2 regexp=None validate=None src=None seuser=None recurse=False delimiter=None mode=664 backup=None

Jun 4 05:35:06 ansible-nw-test ansible-file: Invoked with directory\_mode=None force=False remote\_src=None path=/etc/sysconfig/network-scripts/route-eth0 owner=None follow=False group=None state=absent content=NOT\_LOGGING\_PARAMETER serole=None diff\_peek=None setype=None selevel=None original\_basename=None regexp=None validate=None src=None seuser=None recurse=False delimiter=None mode=None backup=None

Jun 4 05:35:07 ansible-nw-test ansible-copy: Invoked with src=/home/ansible/.ansible/tmp/ansible-tmp-1433409748.69-160995740642356/source directory\_mode=None force=True remote\_src=None dest=/etc/sysconfig/network-scripts/ifcfg-eth0 selevel=None seuser=None serole=None setype=None group=None content=NOT\_LOGGING\_PARAMETER delimiter=None original\_basename=ifcfg-eth0 mode=0644 follow=True owner=root regexp=None validate=None backup=False

Jun 4 05:35:08 ansible-nw-test ansible-async\_wrapper: Invoked with 471496875238 10 /home/ansible/.ansible/tmp/ansible-tmp-1433409750.05-94907608634475/command /home/ansible/.ansible/tmp/ansible-tmp-1433409750.05-94907608634475/arguments

… but networking isn’t restarted.

- name: Update eth0 networking file

template: src=roles/network-project/templates/ifcfg-eth0 dest=/etc/sysconfig/network-scripts/ifcfg-eth0 owner=root mode=0644

tags: netproj-rmroute

- name: Restart networking

shell: /etc/rc.d/init.d/network restart &

async: 10

poll: 0

tags: netproj-netrestart

i’ve tried “service: name=network state=restarted”, command. but with no success.

If I try without “fire and forget”, it restarts networking but my ansible SSH session hangs.

We need to do many VMs, so ideally, I’d like to fire and forget and continue to the next VM.

Any suggestions / corrections / help would be great.

Thanks in advance

Billy

---

<div class="post-metadata">

**Author:** ![benno\_joy](https://avatars.discourse-cdn.com/v4/letter/b/73ab20/32.png) [@benno\_joy](https://forum.ansible.com/u/benno_joy)\
**Post date:** [June 4, 2015, 9:49am UTC](https://forum.ansible.com/t/changing-network-ip-and-network-restart/18400/2 "2015-06-04T09:49:51Z")

</div>

Hi,

can you please try:

- name: Restart networking

shell: sleep 5 && /etc/rc.d/init.d/network restart &

async: 2

poll: 0

tags: netproj-netrestart

---

<div class="post-metadata">

**Author:** ![Billy](https://avatars.discourse-cdn.com/v4/letter/b/ecd19e/32.png) [@Billy](https://forum.ansible.com/u/Billy)\
**Post date:** [June 4, 2015, 9:57am UTC](https://forum.ansible.com/t/changing-network-ip-and-network-restart/18400/3 "2015-06-04T09:57:52Z")

</div>

Thanks. I tried that. The network didn’t restart.

$ ansible-playbook -i production test-net.yml --tags=netproj-netrestart

PLAY [test-net] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

ok: [ansible-nw-test.iedr.ie]

TASK: [network-project | Restart networking] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

\<job 256829590380.17751\> finished on ansible-nw-test.iedr.ie

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

ansible-nw-test.iedr.ie : ok=3 changed=0 unreachable=0 failed=0

On the remote host:

Jun 4 06:06:02 ansible-nw-test ansible-setup: Invoked with filter=\* fact\_path=/etc/ansible/facts.d

Jun 4 06:06:18 ansible-nw-test ansible-async\_wrapper: Invoked with 256829590380 2 /home/ansible/.ansible/tmp/ansible-tmp-1433411619.69-125657995582328/command /home/ansible/.ansible/tmp/ansible-tmp-1433411619.69-125657995582328/arguments

grep IPADDR /etc/sysconfig/network-scripts/ifcfg-eth0

IPADDR=193.1.32.56

# ifconfig | grep ‘inet addr:’

inet addr:193.1.32.55 Bcast:193.1.32.63 Mask:255.255.255.224

---

<div class="post-metadata">

**Author:** ![Billy](https://avatars.discourse-cdn.com/v4/letter/b/ecd19e/32.png) [@Billy](https://forum.ansible.com/u/Billy)\
**Post date:** [June 4, 2015, 10:58am UTC](https://forum.ansible.com/t/changing-network-ip-and-network-restart/18400/4 "2015-06-04T10:58:55Z")

</div>

The problem was mine. The ansible home dir was noexec. Thanks for looking at it.
