# apt module reporting changes when there are none

**URL:** <https://forum.ansible.com/t/apt-module-reporting-changes-when-there-are-none/16026>\
**Category:** Ansible Project\
**Tags:** ubuntu, galaxy-ng\
**Created:** [August 25, 2014, 3:37am UTC](https://forum.ansible.com/t/apt-module-reporting-changes-when-there-are-none/16026 "2014-08-25T03:37:11Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Geerling](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@Jeff\_Geerling](https://forum.ansible.com/u/Jeff_Geerling)\
**Post date:** [August 25, 2014, 3:37am UTC](https://forum.ansible.com/t/apt-module-reporting-changes-when-there-are-none/16026/1 "2014-08-25T03:37:11Z")

</div>

In my [Git](https://galaxy.ansible.com/list#/roles/431) role on Galaxy, I have the following task to install certain packages on Debian hosts:

- name: Ensure git’s dependencies are installed (Debian).  
apt: “pkg={{ item }} state=installed”  
with\_items:
- libcurl4-gnutls-dev
- libexpat1-dev
- gettext
- libz-dev
- libssl-dev
- build-essential

This task always reports a change, even when no new packages are installed… below is the full output when running the playbook with -vvvv (you can see the full playbook run, twice, on an Ubuntu 12.04 host, over [on Travis CI](https://travis-ci.org/geerlingguy/ansible-role-git/jobs/33459628)):

```auto

TASK: [ansible-role-git | Ensure git's dependencies are installed (Debian).] *** 

<localhost> REMOTE_MODULE apt pkg=libcurl4-gnutls-dev,libexpat1-dev,gettext,libz-dev,libssl-dev,build-essential state=installed

<localhost> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1408937381.71-7455986615578 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1408937381.71-7455986615578 && echo $HOME/.ansible/tmp/ansible-tmp-1408937381.71-7455986615578']

<localhost> PUT /tmp/tmpUu6LUb TO /home/travis/.ansible/tmp/ansible-tmp-1408937381.71-7455986615578/apt

<localhost> EXEC /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, key=ptpgbfvujharlyicgqvfprtxbyzstkfo] password: " -u root /bin/sh -c '"'"'echo SUDO-SUCCESS-ptpgbfvujharlyicgqvfprtxbyzstkfo; LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /home/travis/.ansible/tmp/ansible-tmp-1408937381.71-7455986615578/apt; rm -rf /home/travis/.ansible/tmp/ansible-tmp-1408937381.71-7455986615578/ >/dev/null 2>&1'"'"''

changed: [localhost] => (item=libcurl4-gnutls-dev,libexpat1-dev,gettext,libz-dev,libssl-dev,build-essential) => {"changed": true, "item": "libcurl4-gnutls-dev,libexpat1-dev,gettext,libz-dev,libssl-dev,build-essential", "stderr": "", "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nzlib1g-dev is already the newest version.\nThe following packages were automatically installed and are no longer required:\n git-man rsync liberror-perl libgeos-3.2.2\nUse 'apt-get autoremove' to remove them.\n0 upgraded, 0 newly installed, 0 to remove and 128 not upgraded.\n"}

```

Any ideas as to why Ansible would be setting “changed” to true for this? Nothing was upgraded/installed/removed… Other apt tasks seem to work just fine.

---

<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 25, 2014, 4:43am UTC](https://forum.ansible.com/t/apt-module-reporting-changes-when-there-are-none/16026/2 "2014-08-25T04:43:43Z")

</div>

check if any of the packages is 'virtual’​

---

<div class="post-metadata">

**Author:** ![Jeff\_Geerling](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@Jeff\_Geerling](https://forum.ansible.com/u/Jeff_Geerling)\
**Post date:** [August 26, 2014, 2:48pm UTC](https://forum.ansible.com/t/apt-module-reporting-changes-when-there-are-none/16026/3 "2014-08-26T14:48:13Z")

</div>

That was exactly the problem; the `libz-dev` package was causing the false ‘changed’ status.

$ aptitude search libz-dev  
v libz-dev -  
v libz-dev:i386 -

Thanks!

---

<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 26, 2014, 5:39pm UTC](https://forum.ansible.com/t/apt-module-reporting-changes-when-there-are-none/16026/4 "2014-08-26T17:39:51Z")

</div>

I've been looking at a good way to detect and prevent this, but end up with  
circular dependencies, if you have an idea on how to make detection work  
'correctly' I'm willing to code it.

---

<div class="post-metadata">

**Author:** ![Jeff\_Geerling](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@Jeff\_Geerling](https://forum.ansible.com/u/Jeff_Geerling)\
**Post date:** [August 26, 2014, 5:42pm UTC](https://forum.ansible.com/t/apt-module-reporting-changes-when-there-are-none/16026/5 "2014-08-26T17:42:07Z")

</div>

Short of adding in some regular expressions to detect whether there were changes in the apt stdout, I’m not sure of a way that you could do this easily—and without introducing a host of other bugs 😕

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 26, 2014, 10:57pm UTC](https://forum.ansible.com/t/apt-module-reporting-changes-when-there-are-none/16026/6 "2014-08-26T22:57:38Z")

</div>

Perhaps there’s a log to tail?

---

<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 27, 2014, 7:13pm UTC](https://forum.ansible.com/t/apt-module-reporting-changes-when-there-are-none/16026/7 "2014-08-27T19:13:49Z")

</div>

both of those would require major refactoring of the code, it only tries to install if it already considers a change as needed.

Brian Coca

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 27, 2014, 7:20pm UTC](https://forum.ansible.com/t/apt-module-reporting-changes-when-there-are-none/16026/8 "2014-08-27T19:20:58Z")

</div>

Timestamp the rpmdb… no, wait 🙂

---

<div class="post-metadata">

**Author:** ![Neech\_WORTHINGTON](https://avatars.discourse-cdn.com/v4/letter/n/e95f7d/32.png) [@Neech\_WORTHINGTON](https://forum.ansible.com/u/Neech_WORTHINGTON)\
**Post date:** [August 10, 2015, 2:10pm UTC](https://forum.ansible.com/t/apt-module-reporting-changes-when-there-are-none/16026/9 "2015-08-10T14:10:07Z")

</div>

Did anybody find a solution to this, or was there an issue raised at all?

I think I might be experiencing this and would like to work around it if possible.
