apt module has error "failed to execute setup

30 views
Skip to first unread message

Keith Mills

unread,
Jul 31, 2019, 3:19:37 PM7/31/19
to Ansible Project
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:

---


# Plan
# use a staging inventory file or specify individual hosts
# copy repos
# install packages
# copy configs for installed packages
# install cpan modules
# update all the things to appropriate levels
# install mxdk


- hosts: buildservers
  remote_user
: root
  roles
:
   
- buildservers


debian-7.yaml:

---


# 2018-07-02
# Vollmer
# Install required packages (and some perl modules) with_items using default package manager
- name: install required packages
 
package:
    name
: "{{ item }}"
    state
: present
  with_items
:
 
- alien
 
- apache2
 
- autofs
 
- bison
 
- createrepo
 
- dos2unix
 
- flex
#  - g++-multilib
 
- git
 
- html2text
 
- krb5-user
#  - libc6-dev-i386
#  - libevent-dev
 
- libmng1
#  - libxml++2.6-2v5
#  - libxml++2.6-dev
#  - libxml2-dev
 
- libxml++2.6-2
#  - libxml2-dev:i386
#  - lib64stdc++6:i386
 
- libxml2-utils
 
- lzma
 
- make
#  - smbfs
 
- nasm
 
- ntp
 
- pbuilder
 
- python-lxml
 
- rpm2cpio
 
- xsltproc
 
- zip
 
- libexpat1-dev
 
- libssl-dev
 
- zlib1g-dev
 
- cpanminus
#  - update
# The following never worked but were included in the original deployment scripts, kept here for reference
# - lib64stdc++6:i386
# - libxml2-dev:i386
# - smbfs
# It appears that Debian uses all CPAN provided modules so we do not need to install any from the package manager
- name: install required perl modules
 
package:
    name
: "{{ item }}"
    state
: present
#    type: package
  with_items
:
 
- libanydata-perl
 
- libapache-asp-perl
 
- libcrypt-rc4-perl
 
- libdigest-sha-perl
 
- libhttp-dav-perl
 
- liblog-log4perl-perl
 
- libsoap-lite-perl
 
- libterm-shell-perl
 
- libxml-dom-perl
 
- libxml-libxml-perl
 
- libxml-sax-perl
 
- libxml-xpath-perl


...



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

TASK [Gathering Facts] ***************************************************************************************************************************************************
 
[WARNING]: Unhandled error in Python interpreter discovery for host abldeb7ex6405: No JSON object could be decoded


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"}
ok
: [deb7ex6404]
ok
: [deb7ex6403]
ok
: [deb7ex6402]
ok
: [deb7ex6401]




Ansible Version:

ansible 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
  python version
= 2.7.5 (default, May 31 2018, 09:41:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]



OS Environment:

"Debian GNU/Linux 7 (wheezy)"

Ansible Controller:

Red Hat Enterprise Linux Server 7.5 (Maipo)"

EXPECTED RESULTS:

Output with the list of upgraded packages.

ACTUAL RESULTS:

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

TASK [Gathering Facts] ***************************************************************************************************************************************************
 
[WARNING]: Unhandled error in Python interpreter discovery for host abldeb7ex6405: No JSON object could be decoded


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"}
ok
: [deb7ex6404]
ok
: [deb7ex6403]
ok
: [deb7ex6402]
ok
: [deb7ex6401]

Keith Mills

unread,
Jul 31, 2019, 3:27:43 PM7/31/19
to Ansible Project
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
<abldeb7ex6405> Attempting python interpreter discovery
<abldeb7ex6405> ESTABLISH SSH CONNECTION FOR USER: root
<abldeb7ex6405> 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'"'"''
<abldeb7ex6405> (0, '
PLATFORM\nLinux\nFOUND\n/usr/bin/python\n/usr/bin/python2.7\n/usr/bin/python2.6\n/usr/bin/python\nENDFOUND\n', '')
<abldeb7ex6405> ESTABLISH SSH CONNECTION FOR USER: root
<abldeb7ex6405> 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'"'"''
<abldeb7ex6405> (1, '', '
Traceback (most recent call last):\n  File "<stdin>", line 10, in <module>\nImportError: No module named json\n')
<abldeb7ex6405> Failed to connect to the host via ssh: Traceback (most recent call last):
  File "<stdin>", line 10, in <module>
ImportError: No module named json

 [WARNING]: Unhandled error in Python interpreter discovery for host abldeb7ex6405: No JSON object could be decoded


<abldeb7ex6405> Interpreter discovery remote stderr:
Traceback (most recent call last):
  File "<stdin>", line 10, in <module>
ImportError: No module named json


Using module file /usr/lib/python2.7/site-packages/ansible/modules/system/setup.py
Pipelining is enabled.
<abldeb7ex6405> ESTABLISH SSH CONNECTION FOR USER: root
<abldeb7ex6405> 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'"'"''
<abldeb7ex6405> (1, '', '
Traceback (most recent call last):\n  File "<stdin>", line 114, in <module>\n  File "<stdin>", line 21, in _ansiballz_main\nImportError: No module named zipfile\n')
<abldeb7ex6405> Failed to connect to the host via ssh: Traceback (most recent call last):
  File "<stdin>", line 114, in <module>
  File "<stdin>", 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


Kai Stian Olstad

unread,
Jul 31, 2019, 3:46:55 PM7/31/19
to ansible...@googlegroups.com
On 31.07.2019 21:27, Keith Mills wrote:
> ControlPath=/home/jamekeit/.ansible/cp/67246c2bc6 abldeb7ex6405 '/bin/sh -c '"'"'/usr/bin/python
> && sleep 0'"'"''
> <abldeb7ex6405> (1, '', 'Traceback (most recent call last):\n File
> "<stdin>", line 10, in <module>\nImportError: No module named json\n')
> <abldeb7ex6405> Failed to connect to the host via ssh: Traceback (most
> recent call last):
> File "<stdin>", line 10, in <module>
> ImportError: No module named json
> [WARNING]: Unhandled error in Python interpreter discovery for host
> abldeb7ex6405: No JSON object could be decoded
>
>
> <abldeb7ex6405> Interpreter discovery remote stderr:
> Traceback (most recent call last):
> File "<stdin>", line 10, in <module>
> ImportError: No module named json

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

--
Kai Stian Olstad

Keith Mills

unread,
Jul 31, 2019, 4:04:14 PM7/31/19
to ansible...@googlegroups.com
Is there a way to fix this?

Keith James


--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/799c6829-2ced-240e-11c4-381c5ac022e9%40olstad.com.
Reply all
Reply to author
Forward
0 new messages