Closed as not planned
Description
Describe the bug
Trying to execute a play with codeaffen.phpipam.address
and Python 3.13.1 and anbsible-core 2.18.2 in a Docker container.
Container is registry.fedoraproject.org/fedora-minimal:41
.
Currently I do not get further then:
TASK [Reserve an IP address] **************************************************
Tuesday 28 January 2025 14:31:23 +0000 (0:00:00.207) 0:00:02.189 *******
fatal: [haproxy_host -> localhost]: FAILED! => changed=false
module_stderr: |-
/bin/sh: line 1: /usr/bin/env python: No such file or directory
module_stdout: ''
msg: |-
The module failed to execute correctly, you probably need to set the interpreter.
See stdout/stderr for the exact error
rc: 127
To Reproduce
Steps to reproduce the behavior:
- Setup playbook
# testplaybook.yml
---
- name: Update IPAM entry
hosts: "localhost"
connection: local
gather_facts: false
tasks:
- name: Reserve an IP address
codeaffen.phpipam.address:
app_id: 'some app'
description: 'some description'
hostname: 'some hostname'
ipaddress: "192.0.2.1"
is_gateway: false
note: 'N/A'
owner: '[email protected];'
password: "some password"
section: 'some section'
server_url: 'https://ipam.com/'
state: present
subnet: "192.0.2.0/24"
username: "username"
validate_certs: false
- Set up environment for execution
# Run docker container
docker run -it --rm \
--mount type=bind,source="$(pwd)",dst=/root/workdir \
--workdir "/root/workdir" \
registry.fedoraproject.org/fedora-minimal:41
# Install dependencies
dnf check-update
dnf -y update
dnf -y install python3 python3-pip vim
pip install ansible inflection ipaddress phpypam
ansible-galaxy collection install codeaffen.phpipam
# Execute playbook
ansible-playbook -vvv testplaybook.yml
# Output
ansible-playbook [core 2.18.2]
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.13/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible-playbook
python version = 3.13.1 (main, Dec 9 2024, 00:00:00) [GCC 14.2.1 20240912 (Red Hat 14.2.1-3)] (/usr/bin/python3)
jinja version = 3.1.5
libyaml = True
No config file found; using defaults
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
yaml declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
ini declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
toml declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
PLAYBOOK: testplaybook.yml *********************************************
1 plays in testplaybook.yml
PLAY [Update IPAM entry] ***********************************************
TASK [Reserve an IP address] *******************************************
task path: /root/workdir/testplaybook.yml:8
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1738076008.5534654-58-15098037012827 `" && echo ansible-tmp-1738076008.5534654-58-15098037012827="` echo /root/.ansible/tmp/ansible-tmp-1738076008.5534654-58-15098037012827 `" ) && sleep 0'
Using module file /root/.ansible/collections/ansible_collections/codeaffen/phpipam/plugins/modules/address.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-55l1gqcjr6/tmp8bwal4bf TO /root/.ansible/tmp/ansible-tmp-1738076008.5534654-58-15098037012827/AnsiballZ_address.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1738076008.5534654-58-15098037012827/ /root/.ansible/tmp/ansible-tmp-1738076008.5534654-58-15098037012827/AnsiballZ_address.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c ''"'"'/usr/bin/env python'"'"' /root/.ansible/tmp/ansible-tmp-1738076008.5534654-58-15098037012827/AnsiballZ_address.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1738076008.5534654-58-15098037012827/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
"changed": false,
"module_stderr": "/bin/sh: line 1: /usr/bin/env python: No such file or directory\n",
"module_stdout": "",
"msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error",
"rc": 127
}
PLAY RECAP ************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
- Potential fix
When I adjust the file
vim /root/.ansible/collections/ansible_collections/codeaffen/phpipam/plugins/modules/address.py
from
#!/usr/bin/env python
...
to
#!/usr/bin/python
...
the playbook works like expected.
I've tried to setup the ansible_python_interpreter
variable but that was not working.
Expected behavior
Module works without the described error:
fatal: [localhost]: FAILED! => {
"changed": false,
"module_stderr": "/bin/sh: line 1: /usr/bin/env python: No such file or directory\n",
"module_stdout": "",
"msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error",
"rc": 127
}
Versions:
-
Ansible:
$ ansible --version ansible [core 2.18.2] config file = /root/workdir/ansible/ansible.cfg configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/local/lib/python3.13/site-packages/ansible ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections executable location = /usr/local/bin/ansible python version = 3.13.1 (main, Dec 9 2024, 00:00:00) [GCC 14.2.1 20240912 (Red Hat 14.2.1-3)] (/usr/bin/python3) jinja version = 3.1.5 libyaml = True
-
phpipam-ansible-modules:
$ ansible-galaxy collection list codeaffen.phpipam # /root/.ansible/collections/ansible_collections Collection Version ----------------- ------- codeaffen.phpipam 1.7.0
-
phpypam:
$ pip freeze | grep phpypam phpypam==1.0.2
-
phpIPAM:
$ Version from webUI
-
python version
$ python -V Python 3.13.1
-
list of python libraries:
$ pip freeze ansible==11.1.0 ansible-core==2.18.2 certifi==2024.12.14 cffi==1.17.1 charset-normalizer==3.4.1 cryptography==44.0.0 idna==3.10 inflection==0.5.1 ipaddress==1.0.23 Jinja2==3.1.5 MarkupSafe==3.0.2 packaging==24.2 phpypam==1.0.2 pycparser==2.22 PyYAML==6.0.2 requests==2.32.3 resolvelib==1.0.1 urllib3==2.3.0
Additional context
Add any other context about the problem here.