I'm trying to run molecule converge on a newly-created Molecule role (created by running molecule init role shahradr.srx_config --driver-name docker), but I'm getting the following error when running the converge step:
fatal: [instance]: FAILED! => {
"ansible_facts": {},
"changed": false,
"failed_modules": {
"ansible.legacy.setup": {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"failed": true,
"module_stderr": "",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 0
}
},
"msg": "The following modules failed to execute: ansible.legacy.setup\n"
}
I've tried different container images, but they all give me the same error. The ansible.legacy.setup task seems to be the culprit, judging from the value in msg, but it looks like it was able to find the Python interpreter, the return code is 0, and there are no errors in stderr/stdout. I'm wondering if anyone has ever seen anything similar before?
Here are some of the relevant files—let me know what you all think!
molecule.yml
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: instance
image: python # also tried quay.io/quay/ubuntu and quay.io/centos/centos:stream8, but no dice
provisioner:
name: ansible
env:
ANSIBLE_VERBOSITY: 4
verifier:
name: ansible
converge.yml
---
- name: Converge
hosts: all
tasks:
- name: "Include shahradr.srx_config"
include_role:
name: "shahradr.srx_config"
molecule converge output
PLAYBOOK: converge.yml *********************************************************
Positional arguments: /workspaces/playbook-srx/molecule/default/converge.yml
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
skip_tags: ('notest', 'molecule-notest')
inventory: ('/home/vscode/.cache/molecule/playbook-srx/default/inventory',)
forks: 50
1 plays in /workspaces/playbook-srx/molecule/default/converge.yml
PLAY [Converge] ****************************************************************
TASK [Gathering Facts] *********************************************************
task path: /workspaces/playbook-srx/molecule/default/converge.yml:2
fatal: [instance]: FAILED! => {
"ansible_facts": {},
"changed": false,
"failed_modules": {
"ansible.legacy.setup": {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"failed": true,
"module_stderr": "",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 0
}
},
"msg": "The following modules failed to execute: ansible.legacy.setup\n"
}
Loading collection community.docker from /home/vscode/.cache/ansible-compat/874d52/collections/ansible_collections/community/docker
<instance> ESTABLISH DOCKER CONNECTION FOR USER: root
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', "/bin/sh -c 'echo ~ && sleep 0'"]
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', '/bin/sh -c \'( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1671693905.9801428-31004-54819707870645 `" && echo ansible-tmp-1671693905.9801428-31004-54819707870645="` echo /root/.ansible/tmp/ansible-tmp-1671693905.9801428-31004-54819707870645 `" ) && sleep 0\'']
<instance> Attempting python interpreter discovery
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', '/bin/sh -c \'echo PLATFORM; uname; echo FOUND; command -v \'"\'"\'python3.11\'"\'"\'; command -v \'"\'"\'python3.10\'"\'"\'; command -v \'"\'"\'python3.9\'"\'"\'; command -v \'"\'"\'python3.8\'"\'"\'; command -v \'"\'"\'python3.7\'"\'"\'; command -v \'"\'"\'python3.6\'"\'"\'; command -v \'"\'"\'python3.5\'"\'"\'; command -v \'"\'"\'/usr/bin/python3\'"\'"\'; command -v \'"\'"\'/usr/libexec/platform-python\'"\'"\'; command -v \'"\'"\'python2.7\'"\'"\'; command -v \'"\'"\'/usr/bin/python\'"\'"\'; command -v \'"\'"\'python\'"\'"\'; echo ENDFOUND && sleep 0\'']
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', "/bin/sh -c '/usr/local/bin/python3.11 && sleep 0'"]
Using module file /usr/local/python/3.10.9/lib/python3.10/site-packages/ansible/modules/setup.py
<instance> PUT /home/vscode/.ansible/tmp/ansible-local-30997q9s35pno/tmpkw2qa3kw TO /root/.ansible/tmp/ansible-tmp-1671693905.9801428-31004-54819707870645/AnsiballZ_setup.py
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', "/bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1671693905.9801428-31004-54819707870645/ /root/.ansible/tmp/ansible-tmp-1671693905.9801428-31004-54819707870645/AnsiballZ_setup.py && sleep 0'"]
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', "/bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1671693905.9801428-31004-54819707870645/AnsiballZ_setup.py && sleep 0'"]
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', "/bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1671693905.9801428-31004-54819707870645/ > /dev/null 2>&1 && sleep 0'"]
PLAY RECAP *********************************************************************
instance : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
ansible --version output
ansible [core 2.14.1]
config file = None
configured module search path = ['/home/vscode/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/python/3.10.9/lib/python3.10/site-packages/ansible
ansible collection location = /home/vscode/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/python/current/bin/ansible
python version = 3.10.9 (main, Dec 18 2022, 21:59:57) [GCC 10.2.1 20210110] (/usr/local/python/3.10.9/bin/python3.10)
jinja version = 3.1.2
libyaml = True
molecule --version output
molecule 4.0.4 using python 3.10
ansible:2.14.1
delegated:4.0.4 from molecule
docker:2.1.0 from molecule_docker requiring collections: community.docker>=3.0.2 ansible.posix>=1.4.0
Running with an older version of Ansible
ansible --version output
ansible [core 2.12.0]
config file = None
configured module search path = ['/home/vscode/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/python/3.8.16/lib/python3.8/site-packages/ansible
ansible collection location = /home/vscode/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/python/current/bin/ansible
python version = 3.8.16 (default, Dec 22 2022, 09:25:11) [GCC 10.2.1 20210110]
jinja version = 3.1.2
libyaml = True
molecule --version output
molecule 4.0.4 using python 3.8
ansible:2.12.0
delegated:4.0.4 from molecule
docker:2.1.0 from molecule_docker requiring collections: community.docker>=3.0.2 ansible.posix>=1.4.0
molecule converge output
PLAY [Converge] ****************************************************************
TASK [Gathering Facts] *********************************************************
task path: /workspaces/playbook-srx/molecule/default/converge.yml:2
Loading collection community.docker from /home/vscode/.cache/ansible-compat/874d52/collections/ansible_collections/community/docker
<instance> ESTABLISH DOCKER CONNECTION FOR USER: root
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', "/bin/sh -c 'echo ~ && sleep 0'"]
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', '/bin/sh -c \'( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1671797674.6429565-10250-103016948866633 `" && echo ansible-tmp-1671797674.6429565-10250-103016948866633="` echo /root/.ansible/tmp/ansible-tmp-1671797674.6429565-10250-103016948866633 `" ) && sleep 0\'']
<instance> Attempting python interpreter discovery
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', '/bin/sh -c \'echo PLATFORM; uname; echo FOUND; command -v \'"\'"\'python3.10\'"\'"\'; command -v \'"\'"\'python3.9\'"\'"\'; command -v \'"\'"\'python3.8\'"\'"\'; command -v \'"\'"\'python3.7\'"\'"\'; command -v \'"\'"\'python3.6\'"\'"\'; command -v \'"\'"\'python3.5\'"\'"\'; command -v \'"\'"\'/usr/bin/python3\'"\'"\'; command -v \'"\'"\'/usr/libexec/platform-python\'"\'"\'; command -v \'"\'"\'python2.7\'"\'"\'; command -v \'"\'"\'python2.6\'"\'"\'; command -v \'"\'"\'/usr/bin/python\'"\'"\'; command -v \'"\'"\'python\'"\'"\'; echo ENDFOUND && sleep 0\'']
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', "/bin/sh -c '/usr/bin/python3 && sleep 0'"]
Using module file /usr/local/python/3.8.16/lib/python3.8/site-packages/ansible/modules/setup.py
<instance> PUT /home/vscode/.ansible/tmp/ansible-local-10226yeg_lu0l/tmpg3_giq0y TO /root/.ansible/tmp/ansible-tmp-1671797674.6429565-10250-103016948866633/AnsiballZ_setup.py
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', "/bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1671797674.6429565-10250-103016948866633/ /root/.ansible/tmp/ansible-tmp-1671797674.6429565-10250-103016948866633/AnsiballZ_setup.py && sleep 0'"]
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', "/bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1671797674.6429565-10250-103016948866633/AnsiballZ_setup.py && sleep 0'"]
<instance> EXEC ['/usr/bin/docker', b'exec', b'-i', 'instance', '/bin/sh', '-c', "/bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1671797674.6429565-10250-103016948866633/ > /dev/null 2>&1 && sleep 0'"]
fatal: [instance]: FAILED! => {
"ansible_facts": {},
"changed": false,
"failed_modules": {
"ansible.legacy.setup": {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"failed": true,
"module_stderr": "",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 0
}
},
"msg": "The following modules failed to execute: ansible.legacy.setup\n"
}
I think I might have figured it out—it looks like the issue was caused by my devcontainer configuration. I had enabled both the docker-in-docker and docker-from-docker features at the same time, which resulted in the issue listed above.
If I disable either feature, then the
molecule convergecommand completes successfully, and I don't get theansible.legacy.setuperror detailed in this question..devcontainer/devcontainer.jsonmolecule convergeoutput with both the docker-in-docker and docker-from-docker features enabledmolecule convergeoutput with only the docker-in-docker feature enabledmolecule convergeoutput with only the docker-from-docker feature enabled