# command always says something changed, even when nothing actually changed?

**URL:** <https://forum.ansible.com/t/command-always-says-something-changed-even-when-nothing-actually-changed/13317>\
**Category:** Ansible Project\
**Created:** [August 15, 2013, 8:32pm UTC](https://forum.ansible.com/t/command-always-says-something-changed-even-when-nothing-actually-changed/13317 "2013-08-15T20:32:04Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Reagan](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@David\_Reagan](https://forum.ansible.com/u/David_Reagan)\
**Post date:** [August 15, 2013, 8:32pm UTC](https://forum.ansible.com/t/command-always-says-something-changed-even-when-nothing-actually-changed/13317/1 "2013-08-15T20:32:04Z")

</div>

I’m using command to run a2ensite, a2dissite, a2enmod, etc. Every time I run the playbook, those tasks come back as having changed something. Even when no site or module has been added or removed since the last time the playbook was run.

Is there a better way to run those tasks? Or should I just ignore the “changed” status?

Should I just make sure I know which symlinks to disable and use the file module to set their state to absent?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [August 15, 2013, 8:42pm UTC](https://forum.ansible.com/t/command-always-says-something-changed-even-when-nothing-actually-changed/13317/2 "2013-08-15T20:42:23Z")

</div>

use creates/removes= and point to the symlink that would exist or not

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 15, 2013, 8:53pm UTC](https://forum.ansible.com/t/command-always-says-something-changed-even-when-nothing-actually-changed/13317/3 "2013-08-15T20:53:57Z")

</div>

Also in 1.3, there is a “when\_changed” keyword you can use with register.

It’s in the docs if you want to read about it – Advanced playbooks page.

---

<div class="post-metadata">

**Author:** ![Kai\_Weber](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@Kai\_Weber](https://forum.ansible.com/u/Kai_Weber)\
**Post date:** [August 16, 2013, 9:04am UTC](https://forum.ansible.com/t/command-always-says-something-changed-even-when-nothing-actually-changed/13317/4 "2013-08-16T09:04:59Z")

</div>

❦ Michael DeHaan \<michael@ansibleworks.com\>:

> Also in 1.3, there is a "when\_changed" keyword you can use with register.  
> It's in the docs if you want to read about it -- Advanced playbooks page.

Do you mean changed\_when?  
[https://github.com/ansible/ansible/blob/devel/docsite/latest/rst/playbooks2.rst#overriding-changed-result](https://github.com/ansible/ansible/blob/devel/docsite/latest/rst/playbooks2.rst#overriding-changed-result)

This does not work in case of a2ensite, a2enmod etc. They do not provide an  
alternate exit code if a module/site is already enabled. They always return 0.

So in this case, creates= is the way to go.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 16, 2013, 11:55am UTC](https://forum.ansible.com/t/command-always-says-something-changed-even-when-nothing-actually-changed/13317/5 "2013-08-16T11:55:57Z")

</div>

Of course.

I’m just sharing the complete answer.

---

<div class="post-metadata">

**Author:** ![David\_Reagan](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@David\_Reagan](https://forum.ansible.com/u/David_Reagan)\
**Post date:** [August 16, 2013, 2:51pm UTC](https://forum.ansible.com/t/command-always-says-something-changed-even-when-nothing-actually-changed/13317/6 "2013-08-16T14:51:05Z")

</div>

It’s been a while since I checked, but do Redhat style distros like CentOS use a2en\* and a2dis\* commands? I’ve run into a couple that used the \*-enabled and \*-available directories, but I’m not sure that’s the default behavior.

The reason I ask is that I was just pondering about writing a module that would do what I want, and it’d be nice if it worked for both both Redhat and Debian style distros. Something like:

apache2\_vhost: name=vhostfilename state=enabled  
apache2\_mod: name=rewrite state=available

I don’t think I have enough Ansible knowledge to do that quite yet, but even just trying would be a good learning experience.

---

<div class="post-metadata">

**Author:** ![David\_Karban](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@David\_Karban](https://forum.ansible.com/u/David_Karban)\
**Post date:** [August 16, 2013, 2:56pm UTC](https://forum.ansible.com/t/command-always-says-something-changed-even-when-nothing-actually-changed/13317/7 "2013-08-16T14:56:09Z")

</div>

Hi David,

unfortunatelly these are debian-like distribution specific directories. Some control panels (know about ISPConfig) create and use them on RHEL like systems, but it is not native.

David

---

<div class="post-metadata">

**Author:** ![David\_Reagan](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@David\_Reagan](https://forum.ansible.com/u/David_Reagan)\
**Post date:** [August 16, 2013, 2:59pm UTC](https://forum.ansible.com/t/command-always-says-something-changed-even-when-nothing-actually-changed/13317/8 "2013-08-16T14:59:18Z")

</div>

Do Redhat style distros have a default behavior I could rely on in an ansible module that works the way I described?

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [August 16, 2013, 3:01pm UTC](https://forum.ansible.com/t/command-always-says-something-changed-even-when-nothing-actually-changed/13317/9 "2013-08-16T15:01:12Z")

</div>

I manage the sites-enabled directories with templates directly, and don’t use the symlink method here.  
Or you could just use the file module to manage the symlinks directly (which I do for the modules).

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 16, 2013, 6:28pm UTC](https://forum.ansible.com/t/command-always-says-something-changed-even-when-nothing-actually-changed/13317/10 "2013-08-16T18:28:24Z")

</div>

On Red Hat based distributions I just drop the vhosts files directly into conf.d and remove them when I don’t want them there.
