We have the playbook below to copy an updated script to our servers. The copy works to all RHEL 8 servers, but all RHEL 7 servers fails. I know that the RHEL 7 servers has Python 2.7.5, could that be the issue? I don’t think that we can update Python on RHEL 7.
Maybe throw a few "-v"s on the command line and give us the job log? Whether Python 2.7.5 is an issue will also depend on what version of Ansible you are using, and we don’t know that either. With the limited info you’ve given, the only solution is to upgrade all your RHEL 7 servers to at least RHEL 8, which isn’t what you were asking I don’t think.
Well, the controller I’m running the playbook from is RHEL 8 and has the following version:
ansible [core 2.14.6]
config file = /etc/ansible/ansible.cfg
configured module search path = [‘/root/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python3.9/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /bin/ansible
python version = 3.9.16 (main, May 31 2023, 12:21:58) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)] (/usr/bin/python3.9)
jinja version = 3.1.2
libyaml = True
I tweaked the playbook to only try to run to one host, and the -vvv does show this:
(127, b’/bin/sh: /usr/bin/python3: No such file or directory\r\n’
server1 is the RHEL 7 target, and /etc/ansible/hosts doesn’t specify the ansible_interpreter. I have “ansible_interpreter=/usr/bin/python3” on our RHEL 8 boxes in /etc/ansible/hosts. So do I need to specify something specific for python 2.7.5 on those RHEL 7 hosts?
Thanks,
Harry
OK, what I ended up doing was adding “ansible_python_interpreter=/bin/python” on all RHEL 7 hosts in /etc/ansible/hosts, and the file copy worked.
Thanks,
Harry
Hi Harry,
Have a read here https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html maybe set to auto_legacy. I have a mixed fleet and had issues with the copy command, I ended up using jinja templates to push the scripts out to the appropriate place across all platforms.
Cheers
David
I don’t think that we can update Python on RHEL 7.
We are running python3-3.6.8-19.el7_9.x86_64 on our few remaining RHEL 7 hosts.
Use "/usr/bin/python3" for clarity. The "platform python" craziness
for some RHEL releases is pretty nasty and unwelcome for ansible
users.