Hello, I am trying to learn about ansible and I was following the instructions provided in the documentation , but I am not understanding some behaviors.
I built the environment image with ansible-builder build --tag postgresql_ee --container-runtime docker
and defined my hosts.yaml with a vm and a docker container IPs:
all:
hosts:
docker:
ansible_host: 172.17.0.2
http_port: 2222
vm:
ansible_host: 192.4.124.58
http_port: 22
The playbook and image are equal as described in the documentation. But when I run ansible-navigator run test_remote.yml -i inventory --execution-environment-image postgresql_ee:latest --mode stdout --pull-policy missing --enable-prompts -u root -k -K --ce docker
it doesn’t work in the vm, but works with docker.
The error is:
fatal: [vm]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"ansible.legacy.setup": {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "failed": true, "module_stderr": "Shared connection to 192.4.124.58 closed.\r\n", "module_stdout": "/bin/sh: /usr/bin/python3: No such file or directory\r\n", "msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error", "rc": 127, "warnings": ["No python interpreters found for host vm (tried ['python3.12', 'python3.11', 'python3.10', 'python3.9', 'python3.8', 'python3.7', '/usr/bin/python3', 'python3'])"]}}, "msg": "The following modules failed to execute: ansible.legacy.setup\n"}
I understand this error is about the missing python3 dependency in the vm. Makes sense, the vm hasn’t python installed. However I don’t understand why some commands work and this one doesn’t .
if I run ansible-navigator run test_remote.yaml -i inventory --mode stdout --enable-prompts -u root --ce docker
it works
If I run ansible-playbook -i inventory/hosts.yaml test_remote.yaml
it also works
What is the difference that I don’t understand between the ansible-playbook command, the ansible-navigator run command without the --execution-environment-image flag and the ansible-navigator run command with the --execution-environment-image flag?
Why does python need to be installed on the target node in the first command and in the other two it does not need to be installed?
env:
wsl2 with ubuntu 22.04
Distributor ID: Ubuntu
Description: Ubuntu 22.04.4 LTS
Release: 22.04
Codename: jammy
ansible-playbook [core 2.16.6]
config file = None
configured module search path = ['/home/<user>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/<user>/.local/lib/python3.10/site-packages/ansible
ansible collection location = /home/<user>/.ansible/collections:/usr/share/ansible/collections
executable location = /home/<user>/.local/bin/ansible-playbook
python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
ansible-navigator 24.3.2
ansible [core 2.16.6]
config file = None
configured module search path = ['/home/<user>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/<user>/.local/lib/python3.10/site-packages/ansible
ansible collection location = /home/<user>/.ansible/collections:/usr/share/ansible/collections
executable location = /home/<user>/.local/bin/ansible
python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True