# template: shows change every time but no change?

**URL:** <https://forum.ansible.com/t/template-shows-change-every-time-but-no-change/21307>\
**Category:** Ansible Project\
**Created:** [April 28, 2016, 11:32pm UTC](https://forum.ansible.com/t/template-shows-change-every-time-but-no-change/21307 "2016-04-28T23:32:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bob\_Tanner](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Bob\_Tanner](https://forum.ansible.com/u/Bob_Tanner)\
**Post date:** [April 28, 2016, 11:32pm UTC](https://forum.ansible.com/t/template-shows-change-every-time-but-no-change/21307/1 "2016-04-28T23:32:30Z")

</div>

$ ansible --version  
ansible 2.2.0 (devel 7af47a3886) last updated 2016/04/28 13:40:56 (GMT -500)  
lib/ansible/modules/core: (detached HEAD e78ee3b128) last updated 2016/04/28 13:40:56 (GMT -500)  
lib/ansible/modules/extras: (detached HEAD ca310f3d15) last updated 2016/04/28 13:40:56 (GMT -500)  
config file =  
configured module search path = Default w/o overrides

The tasks

- name: configure IP address  
template: \>  
src=“etc/sysconfig/network/ifcfg.j2”  
dest=“/etc/sysconfig/network/ifcfg-{{ item.device }}”  
with\_items:
- “{{ network\_interfaces }}”

The network\_interfaces variable

network\_interfaces:

- device: “eth1”  
name: “[domain1.com](http://domain1.com)”  
bootproto: “static”  
address: “192.168.100.1”  
netmask: “255.255.255.0”  
gateway: “192.168.100.254”
- device: “eth2”

name: “[domain2.com](http://domain2.com)”  
bootproto: “static”  
address: “172.18.28.201”  
netmask: “255.255.0.0”

The template file (ifcfg.j2)

STARTMODE=‘auto’  
USERCONTROL=‘no’  
BOOTPROTO=‘{{ item.bootproto }}’  
IPADDR=‘{{ item.address }}’  
NETMASK=‘{{ item.netmask }}’  
{% if item.broadcast is defined %}  
BROADCAST=‘{{ item.broadcast }}’  
{% endif %}  
{% if item.ethool\_options is defined %}  
ETHTOOL\_OPTIONS=‘’  
{% endif %}  
{% if item.mtu is defined %}  
MTU=‘’  
{% endif %}  
{% if item.name is defined %}  
NAME=‘{{ item.name }}’  
{% endif %}  
{% if item.network is defined %}  
NETWORK=‘’  
{% endif %}  
{% if item.remote\_ipaddr is defined %}  
REMOTE\_IPADDR=‘’  
{% endif %}

Every run of Ansible says eth1 and eth2 have changed.

I copied the ifcfg-eth1 to ifcfg-eth1.bak and ran Ansible again. The diff of the files shows nothing different.

What determines if the file needs to be “changed”?

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [April 28, 2016, 11:35pm UTC](https://forum.ansible.com/t/template-shows-change-every-time-but-no-change/21307/2 "2016-04-28T23:35:28Z")

</div>

Have you tried running Ansible with --diff to see what it says is changing?

---

<div class="post-metadata">

**Author:** ![Bob\_Tanner](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Bob\_Tanner](https://forum.ansible.com/u/Bob_Tanner)\
**Post date:** [April 29, 2016, 4:16am UTC](https://forum.ansible.com/t/template-shows-change-every-time-but-no-change/21307/3 "2016-04-29T04:16:56Z")

</div>

Thank you for the advise.

It looks like it’s not an Ansible thing. It looks like only happens when I run the Ansible playbook via Vagrant.

Thanks again.
