{"action":"closed","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/19013","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/19013/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/19013/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/19013/events","html_url":"https://github.com/ansible/ansible/issues/19013","id":194461298,"number":19013,"title":"[Ubuntu 16.04 - ansible 2.2.0.0] apt-module throws KeyError: 'changed'","user":{"login":"xiongchiamiov","id":23369,"avatar_url":"https://avatars.githubusercontent.com/u/23369?v=3","gravatar_id":"","url":"https://api.github.com/users/xiongchiamiov","html_url":"https://github.com/xiongchiamiov","followers_url":"https://api.github.com/users/xiongchiamiov/followers","following_url":"https://api.github.com/users/xiongchiamiov/following{/other_user}","gists_url":"https://api.github.com/users/xiongchiamiov/gists{/gist_id}","starred_url":"https://api.github.com/users/xiongchiamiov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiongchiamiov/subscriptions","organizations_url":"https://api.github.com/users/xiongchiamiov/orgs","repos_url":"https://api.github.com/users/xiongchiamiov/repos","events_url":"https://api.github.com/users/xiongchiamiov/events{/privacy}","received_events_url":"https://api.github.com/users/xiongchiamiov/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2016-12-08T22:26:02Z","updated_at":"2016-12-09T07:21:52Z","closed_at":"2016-12-09T07:21:52Z","body":"_From @JeffreyDevloo on November 2, 2016 13:43_\n\n##### ISSUE TYPE\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\napt\r\n\r\n##### ANSIBLE VERSION\r\n<!--- Paste verbatim output from “ansible --version” between quotes below -->\r\n```\r\nansible 2.2.0.0\r\n  config file = /etc/ansible/ansible.cfg\r\n  configured module search path = ['/usr/lib/ansible/']\r\n```\r\n\r\n##### CONFIGURATION\r\nChanged the path.\r\n\r\n##### OS / ENVIRONMENT\r\nUbuntu 16.04\r\n\r\n##### SUMMARY\r\nCannot install packages using apt-modules.\r\n\r\n##### STEPS TO REPRODUCE\r\n- Setup playbook with apt\r\n- Run playbook\r\n\r\n<!--- Paste example playbooks or commands between quotes below -->\r\n```\r\n- hosts: cluster\r\n  gather_facts: false\r\n  any_errors_fatal: true\r\n  tasks:\r\n    - name: check hosts their availability\r\n      ping:\r\n      tags:\r\n         - cluster\r\n\r\n    - name: add openvstorage apt-repo\r\n      shell: echo \"deb http://apt.openvstorage.org {{ hostvars[inventory_hostname].ovs_version }} main\" > /etc/apt/sources.list.d/ovsaptrepo.list\r\n      tags:\r\n         - cluster\r\n\r\n    - name: install required packages\r\n      apt: update_cache=yes name=ntp state=present force=yes\r\n      tags:\r\n         - cluster\r\n\r\n    - name: add performance settings to cluster\r\n      shell: echo 1 > /proc/sys/vm/swappiness; echo 'vm.swappiness=1' >> /etc/sysctl.conf; echo '134217728' > /proc/sys/vm/dirty_background_bytes; echo 'vm.dirty_background_bytes = 134217728' >> /etc/sysctl.conf\r\n      tags:\r\n         - cluster\r\n```\r\n\r\n##### EXPECTED RESULTS\r\nModule will throw a python KeyError causing the playbook to fail.\r\n\r\n##### ACTUAL RESULTS\r\n```\r\nUsing module file /usr/lib/python2.7/dist-packages/ansible/modules/core/packaging/os/apt.py\r\n<10.100.199.151> ESTABLISH SSH CONNECTION FOR USER: root\r\nUsing module file /usr/lib/python2.7/dist-packages/ansible/modules/core/packaging/os/apt.py\r\n<10.100.199.152> ESTABLISH SSH CONNECTION FOR USER: root\r\n<10.100.199.151> SSH: EXEC sshpass -d22 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=root -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 10.100.199.151 '/bin/sh -c '\"'\"'( umask 77 && mkdir -p \"` echo $HOME/.ansible/tmp/ansible-tmp-1478093295.66-261469675321647 `\" && echo ansible-tmp-1478093295.66-261469675321647=\"` echo $HOME/.ansible/tmp/ansible-tmp-1478093295.66-261469675321647 `\" ) && sleep 0'\"'\"''\r\nUsing module file /usr/lib/python2.7/dist-packages/ansible/modules/core/packaging/os/apt.py\r\n<10.100.199.153> ESTABLISH SSH CONNECTION FOR USER: root\r\n<10.100.199.152> SSH: EXEC sshpass -d23 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=root -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 10.100.199.152 '/bin/sh -c '\"'\"'( umask 77 && mkdir -p \"` echo $HOME/.ansible/tmp/ansible-tmp-1478093295.66-189382284835995 `\" && echo ansible-tmp-1478093295.66-189382284835995=\"` echo $HOME/.ansible/tmp/ansible-tmp-1478093295.66-189382284835995 `\" ) && sleep 0'\"'\"''\r\n<10.100.199.153> SSH: EXEC sshpass -d24 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=root -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 10.100.199.153 '/bin/sh -c '\"'\"'( umask 77 && mkdir -p \"` echo $HOME/.ansible/tmp/ansible-tmp-1478093295.67-152913268375999 `\" && echo ansible-tmp-1478093295.67-152913268375999=\"` echo $HOME/.ansible/tmp/ansible-tmp-1478093295.67-152913268375999 `\" ) && sleep 0'\"'\"''\r\n<10.100.199.151> PUT /tmp/tmpgRGqlV TO /root/.ansible/tmp/ansible-tmp-1478093295.66-261469675321647/apt.py\r\n<10.100.199.151> SSH: EXEC sshpass -d22 sftp -o BatchMode=no -b - -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=root -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r '[10.100.199.151]'\r\n<10.100.199.153> PUT /tmp/tmpH7GQ9Q TO /root/.ansible/tmp/ansible-tmp-1478093295.67-152913268375999/apt.py\r\n<10.100.199.153> SSH: EXEC sshpass -d24 sftp -o BatchMode=no -b - -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=root -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r '[10.100.199.153]'\r\n<10.100.199.152> PUT /tmp/tmpDGKfbU TO /root/.ansible/tmp/ansible-tmp-1478093295.66-189382284835995/apt.py\r\n<10.100.199.152> SSH: EXEC sshpass -d23 sftp -o BatchMode=no -b - -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=root -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r '[10.100.199.152]'\r\n<10.100.199.151> ESTABLISH SSH CONNECTION FOR USER: root\r\n<10.100.199.151> SSH: EXEC sshpass -d22 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=root -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 10.100.199.151 '/bin/sh -c '\"'\"'chmod u+x /root/.ansible/tmp/ansible-tmp-1478093295.66-261469675321647/ /root/.ansible/tmp/ansible-tmp-1478093295.66-261469675321647/apt.py && sleep 0'\"'\"''\r\n<10.100.199.153> ESTABLISH SSH CONNECTION FOR USER: root\r\n<10.100.199.153> SSH: EXEC sshpass -d24 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=root -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 10.100.199.153 '/bin/sh -c '\"'\"'chmod u+x /root/.ansible/tmp/ansible-tmp-1478093295.67-152913268375999/ /root/.ansible/tmp/ansible-tmp-1478093295.67-152913268375999/apt.py && sleep 0'\"'\"''\r\n<10.100.199.152> ESTABLISH SSH CONNECTION FOR USER: root\r\n<10.100.199.152> SSH: EXEC sshpass -d23 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=root -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 10.100.199.152 '/bin/sh -c '\"'\"'chmod u+x /root/.ansible/tmp/ansible-tmp-1478093295.66-189382284835995/ /root/.ansible/tmp/ansible-tmp-1478093295.66-189382284835995/apt.py && sleep 0'\"'\"''\r\n<10.100.199.151> ESTABLISH SSH CONNECTION FOR USER: root\r\n<10.100.199.151> SSH: EXEC sshpass -d22 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=root -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r -tt 10.100.199.151 '/bin/sh -c '\"'\"'/usr/bin/python /root/.ansible/tmp/ansible-tmp-1478093295.66-261469675321647/apt.py; rm -rf \"/root/.ansible/tmp/ansible-tmp-1478093295.66-261469675321647/\" > /dev/null 2>&1 && sleep 0'\"'\"''\r\n<10.100.199.153> ESTABLISH SSH CONNECTION FOR USER: root\r\n<10.100.199.152> ESTABLISH SSH CONNECTION FOR USER: root\r\n<10.100.199.152> SSH: EXEC sshpass -d23 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=root -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r -tt 10.100.199.152 '/bin/sh -c '\"'\"'/usr/bin/python /root/.ansible/tmp/ansible-tmp-1478093295.66-189382284835995/apt.py; rm -rf \"/root/.ansible/tmp/ansible-tmp-1478093295.66-189382284835995/\" > /dev/null 2>&1 && sleep 0'\"'\"''\r\n<10.100.199.153> SSH: EXEC sshpass -d24 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=root -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r -tt 10.100.199.153 '/bin/sh -c '\"'\"'/usr/bin/python /root/.ansible/tmp/ansible-tmp-1478093295.67-152913268375999/apt.py; rm -rf \"/root/.ansible/tmp/ansible-tmp-1478093295.67-152913268375999/\" > /dev/null 2>&1 && sleep 0'\"'\"''\r\nfatal: [ctl03]: FAILED! => {\r\n    \"changed\": false, \r\n    \"failed\": true, \r\n    \"invocation\": {\r\n        \"module_name\": \"apt\"\r\n    }, \r\n    \"module_stderr\": \"Shared connection to 10.100.199.153 closed.\\r\\n\", \r\n    \"module_stdout\": \"Traceback (most recent call last):\\r\\n  File \\\"/tmp/ansible_LtFRMb/ansible_module_apt.py\\\", line 909, in <module>\\r\\n    main()\\r\\n  File \\\"/tmp/ansible_LtFRMb/ansible_module_apt.py\\\", line 892, in main\\r\\n    if updated_cache and not retvals['changed']:\\r\\nKeyError: 'changed'\\r\\n\", \r\n    \"msg\": \"MODULE FAILURE\"\r\n}\r\nfatal: [ctl02]: FAILED! => {\r\n    \"changed\": false, \r\n    \"failed\": true, \r\n    \"invocation\": {\r\n        \"module_name\": \"apt\"\r\n    }, \r\n    \"module_stderr\": \"Shared connection to 10.100.199.152 closed.\\r\\n\", \r\n    \"module_stdout\": \"Traceback (most recent call last):\\r\\n  File \\\"/tmp/ansible_A4al9W/ansible_module_apt.py\\\", line 909, in <module>\\r\\n    main()\\r\\n  File \\\"/tmp/ansible_A4al9W/ansible_module_apt.py\\\", line 892, in main\\r\\n    if updated_cache and not retvals['changed']:\\r\\nKeyError: 'changed'\\r\\n\", \r\n    \"msg\": \"MODULE FAILURE\"\r\n}\r\nfatal: [ctl01]: FAILED! => {\r\n    \"changed\": false, \r\n    \"failed\": true, \r\n    \"invocation\": {\r\n        \"module_name\": \"apt\"\r\n    }, \r\n    \"module_stderr\": \"Shared connection to 10.100.199.151 closed.\\r\\n\", \r\n    \"module_stdout\": \"Traceback (most recent call last):\\r\\n  File \\\"/tmp/ansible_DLpMnw/ansible_module_apt.py\\\", line 909, in <module>\\r\\n    main()\\r\\n  File \\\"/tmp/ansible_DLpMnw/ansible_module_apt.py\\\", line 892, in main\\r\\n    if updated_cache and not retvals['changed']:\\r\\nKeyError: 'changed'\\r\\n\", \r\n    \"msg\": \"MODULE FAILURE\"\r\n}\r\n\r\n```\r\n\n\n_Copied from original issue: ansible/ansible-modules-core#5459_"}}
{"actor":{"display_login":"resmo"}}