Ansible Module Failure

Hello All,

I am running ansible from a MAC 2018, ansible version 2.8.3 and trying to update servers in AWS (Amazon Linux) . I can successfully ping all the servers, and can run my playbook on ALL server BUT on dev_FE and I don’t understand why.Please assist.

`

ansible-playbook -vvv -i inventory --limit=dev_FE main.yml
ansible-playbook 2.8.3
config file = /WALLETHUB/ansible/patch_server/ansible.cfg
configured module search path = [‘/var/root/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/local/lib/python3.7/site-packages/ansible
executable location = /usr/local/bin/ansible-playbook
python version = 3.7.4 (default, Jul 9 2019, 18:13:23) [Clang 10.0.1 (clang-1001.0.46.4)]
Using /WALLETHUB/ansible/patch_server/ansible.cfg as config file
host_list declined parsing /WALLETHUB/ansible/patch_server/inventory as it did not pass it’s verify_file() method
script declined parsing /WALLETHUB/ansible/patch_server/inventory as it did not pass it’s verify_file() method
auto declined parsing /WALLETHUB/ansible/patch_server/inventory as it did not pass it’s verify_file() method
Parsed /WALLETHUB/ansible/patch_server/inventory inventory source with ini plugin

PLAYBOOK: main.yml *************************************************************************************************************************************************************************************************************************************************************
1 plays in main.yml

PLAY [wallethub] ***************************************************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] *********************************************************************************************************************************************************************************************************************************************************
task path: /WALLETHUB/ansible/patch_server/main.yml:2
<3.220.249.184> ESTABLISH SSH CONNECTION FOR USER: andrewm
<3.220.249.184> SSH: EXEC sshpass -d41 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=43045 -o ‘IdentityFile=“/Users/confluencetrades/Desktop/andrewm.pem”’ -o ‘User=“andrewm”’ -o ConnectTimeout=10 -o ControlPath=/private/var/root/.ansible/cp/90ef5f326d 3.220.249.184 ‘/bin/sh -c ‘"’“‘echo ~andrewm && sleep 0’”’“‘’
<3.220.249.184> (0, b’/home/andrewm\n’, b’')
<3.220.249.184> ESTABLISH SSH CONNECTION FOR USER: andrewm
<3.220.249.184> SSH: EXEC sshpass -d41 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=43045 -o 'IdentityFile=”/Users/confluencetrades/Desktop/andrewm.pem"’ -o ‘User=“andrewm”’ -o ConnectTimeout=10 -o ControlPath=/private/var/root/.ansible/cp/90ef5f326d 3.220.249.184 ‘/bin/sh -c ‘"’"’( umask 77 && mkdir -p “echo /home/andrewm/.ansible/tmp/ansible-tmp-1566672582.347262-86980762832587” && echo ansible-tmp-1566672582.347262-86980762832587=“echo /home/andrewm/.ansible/tmp/ansible-tmp-1566672582.347262-86980762832587” ) && sleep 0’“'”‘’
<3.220.249.184> (0, b’ansible-tmp-1566672582.347262-86980762832587=/home/andrewm/.ansible/tmp/ansible-tmp-1566672582.347262-86980762832587\n’, b’‘)
<dev_FE> Attempting python interpreter discovery
<3.220.249.184> ESTABLISH SSH CONNECTION FOR USER: andrewm
<3.220.249.184> SSH: EXEC sshpass -d41 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=43045 -o ‘IdentityFile=“/Users/confluencetrades/Desktop/andrewm.pem”’ -o ‘User=“andrewm”’ -o ConnectTimeout=10 -o ControlPath=/private/var/root/.ansible/cp/90ef5f326d 3.220.249.184 ‘/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’”‘"’’
<3.220.249.184> (0, b’PLATFORM\nLinux\nFOUND\n/usr/bin/python\n/usr/bin/python2.7\n/usr/bin/python2.6\n/usr/bin/python\nENDFOUND\n’, b’‘)
<3.220.249.184> ESTABLISH SSH CONNECTION FOR USER: andrewm
<3.220.249.184> SSH: EXEC sshpass -d41 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=43045 -o ‘IdentityFile=“/Users/confluencetrades/Desktop/andrewm.pem”’ -o ‘User=“andrewm”’ -o ConnectTimeout=10 -o ControlPath=/private/var/root/.ansible/cp/90ef5f326d 3.220.249.184 ‘/bin/sh -c ‘"’"’/usr/bin/python && sleep 0’“'”‘’
<3.220.249.184> (0, b’{“osrelease_content”: “NAME=\“Amazon Linux AMI\”\nVERSION=\“2018.03\”\nID=\“amzn\”\nID_LIKE=\“rhel fedora\”\nVERSION_ID=\“2018.03\”\nPRETTY_NAME=\“Amazon Linux AMI 2018.03\”\nANSI_COLOR=\“0;33\”\nCPE_NAME=\“cpe:/o:amazon:linux:2018.03:ga\”\nHOME_URL=\“http://aws.amazon.com/amazon-linux-ami/\\“\\n”, “platform_dist_result”: [””, “”, “”]}\n’, b’‘)
<dev_FE> Python interpreter discovery fallback (unsupported Linux distribution: amzn)
Using module file /usr/local/lib/python3.7/site-packages/ansible/modules/system/setup.py
<3.220.249.184> PUT /var/root/.ansible/tmp/ansible-local-70345dl6qhmdh/tmpajfkdun5 TO /home/andrewm/.ansible/tmp/ansible-tmp-1566672582.347262-86980762832587/AnsiballZ_setup.py
<3.220.249.184> SSH: EXEC sshpass -d41 sftp -o BatchMode=no -b - -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=43045 -o ‘IdentityFile=“/Users/confluencetrades/Desktop/andrewm.pem”’ -o ‘User=“andrewm”’ -o ConnectTimeout=10 -o ControlPath=/private/var/root/.ansible/cp/90ef5f326d ‘[3.220.249.184]’
<3.220.249.184> (0, b’sftp> put /var/root/.ansible/tmp/ansible-local-70345dl6qhmdh/tmpajfkdun5 /home/andrewm/.ansible/tmp/ansible-tmp-1566672582.347262-86980762832587/AnsiballZ_setup.py\n’, b’‘)
<3.220.249.184> ESTABLISH SSH CONNECTION FOR USER: andrewm
<3.220.249.184> SSH: EXEC sshpass -d41 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=43045 -o ‘IdentityFile=“/Users/confluencetrades/Desktop/andrewm.pem”’ -o ‘User=“andrewm”’ -o ConnectTimeout=10 -o ControlPath=/private/var/root/.ansible/cp/90ef5f326d 3.220.249.184 ‘/bin/sh -c ‘"’“‘chmod u+x /home/andrewm/.ansible/tmp/ansible-tmp-1566672582.347262-86980762832587/ /home/andrewm/.ansible/tmp/ansible-tmp-1566672582.347262-86980762832587/AnsiballZ_setup.py && sleep 0’”’"’’
<3.220.249.184> (0, b’‘, b’‘)
<3.220.249.184> ESTABLISH SSH CONNECTION FOR USER: andrewm
<3.220.249.184> SSH: EXEC sshpass -d41 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=43045 -o ‘IdentityFile=“/Users/confluencetrades/Desktop/andrewm.pem”’ -o ‘User=“andrewm”’ -o ConnectTimeout=10 -o ControlPath=/private/var/root/.ansible/cp/90ef5f326d -tt 3.220.249.184 ‘/bin/sh -c ‘"’“'sudo -H -S -p “[sudo via ansible, key=odjslmmymcfjguanwabuzngyvowjxzsy] password:” -u root /bin/sh -c '”’"’“'”‘"’“'”‘“‘echo BECOME-SUCCESS-odjslmmymcfjguanwabuzngyvowjxzsy ; /usr/bin/python /home/andrewm/.ansible/tmp/ansible-tmp-1566672582.347262-86980762832587/AnsiballZ_setup.py’”’“'”‘"’“'”‘"’“’ && sleep 0’”‘"’’
Escalation succeeded
<3.220.249.184> (1, b’\r\n’, b’Shared connection to 3.220.249.184 closed.\r\n’)
<3.220.249.184> Failed to connect to the host via ssh: Shared connection to 3.220.249.184 closed.
<3.220.249.184> ESTABLISH SSH CONNECTION FOR USER: andrewm
<3.220.249.184> SSH: EXEC sshpass -d41 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=43045 -o ‘IdentityFile=“/Users/confluencetrades/Desktop/andrewm.pem”’ -o ‘User=“andrewm”’ -o ConnectTimeout=10 -o ControlPath=/private/var/root/.ansible/cp/90ef5f326d 3.220.249.184 ‘/bin/sh -c ‘"’“‘rm -f -r /home/andrewm/.ansible/tmp/ansible-tmp-1566672582.347262-86980762832587/ > /dev/null 2>&1 && sleep 0’”’"‘’
<3.220.249.184> (0, b’‘, b’')
fatal: [dev_FE]: FAILED! => {
“ansible_facts”: {},
“changed”: false,
“failed_modules”: {
“setup”: {
“ansible_facts”: {
“discovered_interpreter_python”: “/usr/bin/python”
},
“failed”: true,
“module_stderr”: “Shared connection to 3.220.249.184 closed.\r\n”,
“module_stdout”: “\r\n”,
“msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”,
“rc”: 1
}
},
“msg”: “The following modules failed to execute: setup\n”
}

PLAY RECAP *********************************************************************************************************************************************************************************************************************************************************************
dev_FE : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

`

`
TASK [Ping host] ***************************************************************************************************************************************************************************************************************************************************************

ok: [dev_FE]
`

Hello!

ansible-playbook 2.8.3
[...]
-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
[...]
<3.220.249.184> (0, b'{"osrelease_content": "NAME=\\"Amazon Linux
AMI\\"\\nVERSION=\\"2018.03\\"\\nID=\\"amzn\\"\\nID_LIKE=\\"rhel
fedora\\"\\nVERSION_ID=\\"2018.03\\"\\nPRETTY_NAME=\\"Amazon Linux AMI
2018.03\\"\\nANSI_COLOR=\\"0;33\\"\\nCPE_NAME=\\"cpe:/o:amazon:linux:2018.03:ga\\"\\nHOME_URL=\\"http://aws.amazon.com/amazon-linux-ami/\\\\&quot;\\\\n&quot;,
"platform_dist_result": ["", "", ""]}\n', b'')
<dev_FE> Python interpreter discovery fallback (unsupported Linux
distribution: amzn)
Using module file
/usr/local/lib/python3.7/site-packages/ansible/modules/system/setup.py
[...]
fatal: [dev_FE]: FAILED! => {
[...]
    "msg": "The following modules failed to execute: setup\n"

Set 'ansible_python_interpreter' to working version in the inventory and test
it. For example

        dev_FE ansible_python_interpreter=/usr/bin/python2.7

        $ ansible dev_FE -m ping

Ansible said "unsupported Linux distribution: amzn", picked python3.7 as a
fallback and crashed. For detailed explanation see the comment in
https://github.com/ansible/ansible/blob/devel/lib/ansible/executor/interpreter_discovery.py
See also 'Python 3 Support'
https://docs.ansible.com/ansible/latest/reference_appendices/python_3_support.html#python-3-support

Cheers,

  -vlado

Thank you for your response. I tried that, but still getting the same error. Further explaining my initial comment, I am able to ping all servers. But when running a playbook against the servers, the playbook works except against dev_fe, and the error is above. I have tried below but still the same error

dev_FE ansible_ssh_host=3.220.299.184 ansible_ssh_port=22 ansible_python_interpreter=/usr/bin/python2.7

Set INTERPRETER_PYTHON_FALLBACK and put '/usr/bin/python2.7' into the first
place
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#interpreter-python-fallback

If you still don't seen this

  Using module file
  /usr/local/lib/python2.7/site-packages/ansible/modules/system/setup.py

then you might want to consider to open an issue if you're sure the
configuration is all right
https://github.com/ansible/ansible/issues

Cheers,

  -vlado

Thank you for help. I am still seeing

`
sing module file /usr/local/lib/python3.7/site-packages/ansible/modules/system/setup.p

`

Maybe I am not setting the variable correctly.In my ansible.cfg I have

INTERPRETER_PYTHON_FALLBACK = '/usr/bin/python2.7'

Is this correct?

It's not configurable. Sorry for the noise.

Next option is to install only selected version
https://docs.aws.amazon.com/cli/latest/userguide/install-linux-python.html

Cheers,

  -vlado

Hi!

> > Set INTERPRETER_PYTHON_FALLBACK and put '/usr/bin/python2.7' into the
> > first place
> > https://docs.ansible.com/ansible/latest/reference_appendices/config.html#interpreter-python-fallback

> Thank you for help. I am still seeing
> module file /usr/local/lib/python3.7/site-packages/ansible/modules/
> system/setup.py
> Maybe I am not setting the variable correctly.In my ansible.cfg I have
> INTERPRETER_PYTHON_FALLBACK = '/usr/bin/python2.7'
> Is this correct?

It's not configurable. Sorry for the noise.
Next option is to install only selected version
https://docs.aws.amazon.com/cli/latest/userguide/install-linux-python.html

1) My assumption that that "ansible_python_interpreter" would affect the
version of the modul setup.py was wrong.

      module file /usr/local/lib/python3.7/site-packages/ansible/modules/

This is the version of Python at master Ansible is running with

      ansible-playbook -vvv -i inventory --limit=dev_FE main.yml
      ansible-playbook 2.8.3
      config file = /WALLETHUB/ansible/patch_server/ansible.cfg
      configured module search path = ['/var/root/.ansible/plugins/modules',
      '/usr/share/ansible/plugins/modules']
      ansible python module location =
      /usr/local/lib/python3.7/site-packages/ansible
      executable location = /usr/local/bin/ansible-playbook
      python version = 3.7.4 (default, Jul 9 2019, 18:13:23) [Clang 10.0.1
      (clang-1001.0.46.4)]

As a result, this Python version is not an indicator of what is going on at
remote host.

2) I've tested remote host FreeBSD 12.0 from the master Ubuntu 18.04. All is
working well with Ansible 2.8.3 and Python 2.7 at master

      ansible 2.8.3
      config
   file= /export/home/vlado.config/.ansible/ansible-examples/examples/example-155/ansible.cfg
      configured module search path =
      [u'/home/vlado/.ansible/plugins/modules',
      u'/usr/share/ansible/plugins/modules'] ansible python module location
      = /usr/lib/python2.7/dist-packages/ansible executable location
      = /usr/bin/ansible python version = 2.7.15+ (default, Nov 27 2018,
      23:36:35) [GCC 7.3.0]

both with Python 2.7

      test_01 | SUCCESS => {
             "ansible_facts": {
                 [...]
                 "ansible_python_version": "2.7.16",

and Python 3.6 at the remote host.

      test_01 | SUCCESS => {
             "ansible_facts": {
                 [...]
                 "ansible_python_version": "3.6.7",

3) It's left to find out if the problem is Ansible 2.8 with Python3 in
general, or if this is a distro problem.

Cheers,

  -vlado

Thank you for your assistance.I have checked and all servers are:

NAME="Amazon Linux AMI"
VERSION="2018.03"

and python  2.7.16 .Just not sure how else I could check why that one server fails to run the playbook