apt module reporting changes when there are none

570 views
Skip to first unread message

Jeff Geerling

unread,
Aug 24, 2014, 11:37:11 PM8/24/14
to ansible...@googlegroups.com
In my Git 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):

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.

Brian Coca

unread,
Aug 25, 2014, 12:43:48 AM8/25/14
to ansible...@googlegroups.com
check if any of the packages is 'virtual'​

Jeff Geerling

unread,
Aug 26, 2014, 10:48:14 AM8/26/14
to ansible...@googlegroups.com
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!

Brian Coca

unread,
Aug 26, 2014, 1:39:54 PM8/26/14
to ansible...@googlegroups.com
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.


--
Brian Coca
Stultorum infinitus est numerus
0110000101110010011001010110111000100111011101000010000001111001011011110111010100100000011100110110110101100001011100100111010000100001
Pedo mellon a minno

Jeff Geerling

unread,
Aug 26, 2014, 1:42:07 PM8/26/14
to ansible...@googlegroups.com
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 :/

Michael DeHaan

unread,
Aug 26, 2014, 6:57:42 PM8/26/14
to ansible...@googlegroups.com
Perhaps there's a log to tail?




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7aa18456-912c-43c6-98c6-961a5bcebf6f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Brian Coca

unread,
Aug 27, 2014, 3:13:52 PM8/27/14
to ansible...@googlegroups.com

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

Michael DeHaan

unread,
Aug 27, 2014, 3:21:01 PM8/27/14
to ansible...@googlegroups.com
Timestamp the rpmdb... no, wait :)




On Wed, Aug 27, 2014 at 3:13 PM, Brian Coca <bria...@gmail.com> wrote:

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

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Neech WORTHINGTON

unread,
Aug 10, 2015, 10:10:07 AM8/10/15
to Ansible Project
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.
Reply all
Reply to author
Forward
0 new messages