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.