apt call always returns changed

53 views
Skip to first unread message

Francisco Reyes

unread,
Feb 18, 2015, 12:36:39 AM2/18/15
to ansible...@googlegroups.com
I have this in a playbook

- name: Install needed packages
    apt: pkg={{ item }} state=latest
    with_items:
    - libxml2-dev
    - libxslt-dev
    - memcached
    - uwsgi

Every single time it runs, it reports changed... 
output with -vvvv

TASK: [Install needed packages] *********************************************** 
<sp-web.clienthost.pw
<sp-web.clienthost.pw> state=latest pkg=libxml2-dev,libxslt-dev,memcached,uwsgi
<sp-web.clienthost.pw> ConnectTimeout=10 PasswordAuthentication=no KbdInteractiveAuthentication=no User=root ControlPath=/home/francisco/.ansible/cp/ansible-ssh-%h-%p-%r PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey ControlMaster=auto Port=2222 ControlPersist=60s
<sp-web.clienthost.pw
<sp-web.clienthost.pw> ConnectTimeout=10 PasswordAuthentication=no 'LANG=C LC_CTYPE=C /usr/bin/python /root/.ansible/tmp/ansible-tmp-1424237732.24-109662245491931/apt; rm -rf /root/.ansible/tmp/ansible-tmp-1424237732.24-109662245491931/ >/dev/null 2>&1' KbdInteractiveAuthentication=no User=root ControlPath=/home/francisco/.ansible/cp/ansible-ssh-%h-%p-%r PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey ControlMaster=auto Port=2222 ControlPersist=60s
changed: [sp-web.clienthost.pw] => (item=libxml2-dev,libxslt-dev,memcached,uwsgi) => {"changed": true, "item": "libxml2-dev,libxslt-dev,memcached,uwsgi", "stderr": "", "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nlibxslt1-dev is already the newest version.\n0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.\n"}


Any ideas why it keeps reporting "changed". 

I tried checking if apt upgrade even reports anything in the target machine and it doesn't.

Adam Hamsik

unread,
Feb 18, 2015, 8:08:07 AM2/18/15
to ansible...@googlegroups.com


On Wednesday, February 18, 2015 at 6:36:39 AM UTC+1, Francisco Reyes wrote:
I have this in a playbook

- name: Install needed packages
    apt: pkg={{ item }} state=latest
    with_items:
    - libxml2-dev
    - libxslt-dev
    - memcached
    - uwsgi



I can see same behaviour for following play which is quite similar

# TODO: This is marked as changed even if no package is installed
- name: Install dev ubuntu packages for jenkins
  sudo: yes
  apt:
    pkg={{item}}
    state=present
  with_items: ['libxml2-dev', 'libxslt-dev', 'zlib1g-dev']
  tags: install

funny thing is that it doesn't happen for other packages. only for these 3.

Adam Hamsik

unread,
Feb 18, 2015, 8:11:38 AM2/18/15
to ansible...@googlegroups.com


After some troubleshooting problem looks to be in libxslt-dev package

caracal:rsd_env_setup (master*) $ ansible -m apt -a 'pkg=libxslt-dev state=present' opsci-server -s -vvv
<opsci.rsd.com> ESTABLISH CONNECTION FOR USER: rsd
<opsci.rsd.com> REMOTE_MODULE apt pkg=libxslt-dev state=present
<opsci.rsd.com> EXEC ssh -C -tt -q -o ControlPersist=15m -F /Users/haad/.ansible/ssh_config -o ControlPath="/Users/haad/.ansible/cp/ansible-ssh-%h-%p-%r" -o StrictHostKeyChecking=no -o Port=22 -o IdentityFile="/Users/haad/.ssh/id_rsa" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=rsd -o ConnectTimeout=19 opsci.rsd.com /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1424265035.78-99667925086072 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1424265035.78-99667925086072 && echo $HOME/.ansible/tmp/ansible-tmp-1424265035.78-99667925086072'
<opsci.rsd.com> PUT /var/folders/yq/_h9bmb6x1qxb7p4_w5xhkgx80000gn/T/tmpg9KHmA TO /home/rsd/.ansible/tmp/ansible-tmp-1424265035.78-99667925086072/apt
<opsci.rsd.com> EXEC ssh -C -tt -q -o ControlPersist=15m -F /Users/haad/.ansible/ssh_config -o ControlPath="/Users/haad/.ansible/cp/ansible-ssh-%h-%p-%r" -o StrictHostKeyChecking=no -o Port=22 -o IdentityFile="/Users/haad/.ssh/id_rsa" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=rsd -o ConnectTimeout=19 opsci.rsd.com /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, key=cljxvustcsbxbaozbgaskderzvnjkymy] password: " -u root /bin/sh -c '"'"'echo SUDO-SUCCESS-cljxvustcsbxbaozbgaskderzvnjkymy; LANG=C LC_CTYPE=C /usr/bin/python /home/rsd/.ansible/tmp/ansible-tmp-1424265035.78-99667925086072/apt; rm -rf /home/rsd/.ansible/tmp/ansible-tmp-1424265035.78-99667925086072/ >/dev/null 2>&1'"'"''
opsci-server | success >> {
    "changed": true,
    "stderr": "",
    "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nlibxslt1-dev is already the newest version.\n0 upgraded, 0 newly installed, 0 to remove and 65 not upgraded.\n"
}

caracal:rsd_env_setup (master*) $ ansible -m apt -a 'pkg=libxml2-dev state=present' opsci-server -s -vvv
<opsci.rsd.com> ESTABLISH CONNECTION FOR USER: rsd
<opsci.rsd.com> REMOTE_MODULE apt pkg=libxml2-dev state=present
<opsci.rsd.com> EXEC ssh -C -tt -q -o ControlPersist=15m -F /Users/haad/.ansible/ssh_config -o ControlPath="/Users/haad/.ansible/cp/ansible-ssh-%h-%p-%r" -o StrictHostKeyChecking=no -o Port=22 -o IdentityFile="/Users/haad/.ssh/id_rsa" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=rsd -o ConnectTimeout=19 opsci.rsd.com /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1424265055.72-134679118481702 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1424265055.72-134679118481702 && echo $HOME/.ansible/tmp/ansible-tmp-1424265055.72-134679118481702'
<opsci.rsd.com> PUT /var/folders/yq/_h9bmb6x1qxb7p4_w5xhkgx80000gn/T/tmpR6qy_K TO /home/rsd/.ansible/tmp/ansible-tmp-1424265055.72-134679118481702/apt
<opsci.rsd.com> EXEC ssh -C -tt -q -o ControlPersist=15m -F /Users/haad/.ansible/ssh_config -o ControlPath="/Users/haad/.ansible/cp/ansible-ssh-%h-%p-%r" -o StrictHostKeyChecking=no -o Port=22 -o IdentityFile="/Users/haad/.ssh/id_rsa" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=rsd -o ConnectTimeout=19 opsci.rsd.com /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, key=dlcbjvxflyxkbuoiaomhxeyyczmpstws] password: " -u root /bin/sh -c '"'"'echo SUDO-SUCCESS-dlcbjvxflyxkbuoiaomhxeyyczmpstws; LANG=C LC_CTYPE=C /usr/bin/python /home/rsd/.ansible/tmp/ansible-tmp-1424265055.72-134679118481702/apt; rm -rf /home/rsd/.ansible/tmp/ansible-tmp-1424265055.72-134679118481702/ >/dev/null 2>&1'"'"''
opsci-server | success >> {
    "changed": false
}

Adam Hamsik

unread,
Feb 18, 2015, 8:16:59 AM2/18/15
to ansible...@googlegroups.com


So I'm sorry for spaming but I cracked it problem is that there is no package called libxslt-dev that's just an alias to libxslt1-dev and if you use former name it will print a node to stdout. Which will trigger the change.

opsci:~ $ sudo apt-get install libxslt-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libxslt1-dev' instead of 'libxslt-dev' <<<< note

libxslt1-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 65 not upgraded.

opsci:~ $ sudo apt-get install libxslt1-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done

libxslt1-dev is already the newest version.

Brian Coca

unread,
Feb 18, 2015, 9:50:39 AM2/18/15
to ansible...@googlegroups.com
this happens with virtual packages, as they do not appear as
installed, but then when apt runs the package that provides the
virtual slot is found and no change is made, but it was detected as
such.



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages