# apt module has error "failed to execute setup

**URL:** <https://forum.ansible.com/t/apt-module-has-error-failed-to-execute-setup/30922>\
**Category:** Ansible Project\
**Created:** [July 31, 2019, 7:19pm UTC](https://forum.ansible.com/t/apt-module-has-error-failed-to-execute-setup/30922 "2019-07-31T19:19:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Keith\_Mills](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@Keith\_Mills](https://forum.ansible.com/u/Keith_Mills)\
**Post date:** [July 31, 2019, 7:19pm UTC](https://forum.ansible.com/t/apt-module-has-error-failed-to-execute-setup/30922/1 "2019-07-31T19:19:37Z")

</div>

I have Ansible 2.8.0 and Python 2.7.5. I tried to run the following playbook to upgrade the packages on a Debian host which has Python 2.7.3. I got the ““The following modules failed to execute: setup\n setup: MODULE FAILURE\nSee stdout/stderr for the exact error\n”}” in the Gathering facts part. Please advice. Thanks in advance.  
name: Update and upgrade apt packages

new-buildserver.yaml:

`

---

<div class="post-metadata">

**Author:** ![Keith\_Mills](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@Keith\_Mills](https://forum.ansible.com/u/Keith_Mills)\
**Post date:** [July 31, 2019, 7:27pm UTC](https://forum.ansible.com/t/apt-module-has-error-failed-to-execute-setup/30922/2 "2019-07-31T19:27:43Z")

</div>

Here is the -vvv

ansible-playbook -i buildservers-agd new-buildserver.yaml --check --limit abldeb7ex6405 -vvv  
`  
ansible-playbook 2.8.0  
config file = /etc/ansible/ansible.cfg  
configured module search path = [u’/home/jamekeit/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python2.7/site-packages/ansible  
executable location = /usr/bin/ansible-playbook  
python version = 2.7.5 (default, May 31 2018, 09:41:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]  
Using /etc/ansible/ansible.cfg as config file  
host\_list declined parsing /home/jamekeit/ds9/buildservers-agd as it did not pass it’s verify\_file() method  
script declined parsing /home/jamekeit/ds9/buildservers-agd as it did not pass it’s verify\_file() method  
auto declined parsing /home/jamekeit/ds9/buildservers-agd as it did not pass it’s verify\_file() method  
Parsed /home/jamekeit/ds9/buildservers-agd inventory source with ini plugin  
statically imported: /home/jamekeit/ds9/roles/buildservers/tasks/regular-packages.yaml  
statically imported: /home/jamekeit/ds9/roles/buildservers/tasks/git.yaml

PLAYBOOK: new-buildserver.yaml \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
1 plays in new-buildserver.yaml

PLAY [buildservers] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /home/jamekeit/ds9/new-buildserver.yaml:13  
 Attempting python interpreter discovery  
 ESTABLISH SSH CONNECTION FOR USER: root  
 SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o ‘IdentityFile=“/etc/ansible/id\_rsa”’ -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ‘User=“root”’ -o ConnectTimeout=10 -o ControlPath=/home/jamekeit/.ansible/cp/67246c2bc6 abldeb7ex6405 ‘/bin/sh -c ‘"’“'echo PLATFORM; uname; echo FOUND; command -v '”’“'”‘"’“'”‘"’“‘/usr/bin/python’”‘"’“'”‘"’“'”‘"’; command -v ‘"’“'”‘"’“'”‘"’“‘python3.7’”‘"’“'”‘"’“'”‘"’; command -v ‘"’“'”‘"’“'”‘"’“‘python3.6’”‘"’“'”‘"’“'”‘"’; command -v ‘"’“'”‘"’“'”‘"’“‘python3.5’”‘"’“'”‘"’“'”‘"’; command -v ‘"’“'”‘"’“'”‘"’“‘python2.7’”‘"’“'”‘"’“'”‘"’; command -v ‘"’“'”‘"’“'”‘"’“‘python2.6’”‘"’“'”‘"’“'”‘"’; command -v ‘"’“'”‘"’“'”‘"’“‘/usr/libexec/platform-python’”‘"’“'”‘"’“'”‘"’; command -v ‘"’“'”‘"’“'”‘"’“‘/usr/bin/python3’”‘"’“'”‘"’“'”‘"’; command -v ‘"’“'”‘"’“'”‘"’“‘python’”‘"’“'”‘"’“'”‘"’; echo ENDFOUND && sleep 0’“'”‘’  
 (0, ‘PLATFORM\nLinux\nFOUND\n/usr/bin/python\n/usr/bin/python2.7\n/usr/bin/python2.6\n/usr/bin/python\nENDFOUND\n’, ‘’)  
 ESTABLISH SSH CONNECTION FOR USER: root  
 SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o ‘IdentityFile=“/etc/ansible/id\_rsa”’ -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ‘User=“root”’ -o ConnectTimeout=10 -o ControlPath=/home/jamekeit/.ansible/cp/67246c2bc6 abldeb7ex6405 ‘/bin/sh -c ‘"’"’/usr/bin/python && sleep 0’“'”‘’  
 (1, ‘’, ‘Traceback (most recent call last):\n File “”, line 10, in \nImportError: No module named json\n’)  
 Failed to connect to the host via ssh: Traceback (most recent call last):  
File “”, line 10, in   
ImportError: No module named json  
[WARNING]: Unhandled error in Python interpreter discovery for host abldeb7ex6405: No JSON object could be decoded

Interpreter discovery remote stderr:  
Traceback (most recent call last):  
File “”, line 10, in   
ImportError: No module named json

Using module file /usr/lib/python2.7/site-packages/ansible/modules/system/setup.py  
Pipelining is enabled.  
 ESTABLISH SSH CONNECTION FOR USER: root  
 SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o ‘IdentityFile=“/etc/ansible/id\_rsa”’ -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ‘User=“root”’ -o ConnectTimeout=10 -o ControlPath=/home/jamekeit/.ansible/cp/67246c2bc6 abldeb7ex6405 ‘/bin/sh -c ‘"’"’/usr/bin/python && sleep 0’“'”‘’  
 (1, ‘’, ‘Traceback (most recent call last):\n File “”, line 114, in \n File “”, line 21, in \_ansiballz\_main\nImportError: No module named zipfile\n’)  
 Failed to connect to the host via ssh: Traceback (most recent call last):  
File “”, line 114, in   
File “”, line 21, in \_ansiballz\_main  
ImportError: No module named zipfile  
fatal: [abldeb7ex6405]: FAILED! =\> {  
“ansible\_facts”: {},  
“changed”: false,  
“msg”: “The following modules failed to execute: setup\n setup: MODULE FAILURE\nSee stdout/stderr for the exact error\n”  
}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
abldeb7ex6405 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0  
`

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 31, 2019, 7:46pm UTC](https://forum.ansible.com/t/apt-module-has-error-failed-to-execute-setup/30922/3 "2019-07-31T19:46:37Z")

</div>

Your installation is seriously broken, json module is included in Python 2.6 and newer  
[https://docs.python.org/2/library/json.html](https://docs.python.org/2/library/json.html)

---

<div class="post-metadata">

**Author:** ![Keith\_Mills](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@Keith\_Mills](https://forum.ansible.com/u/Keith_Mills)\
**Post date:** [July 31, 2019, 8:03pm UTC](https://forum.ansible.com/t/apt-module-has-error-failed-to-execute-setup/30922/4 "2019-07-31T20:03:29Z")

</div>

Is there a way to fix this?
