Forum Discussion
Connecting to F5 using SSH via Ansible
I am in the process of writing a playbook which uses SSH to connect to F5 and run a bash command (ntpdate -d time_server) to confirm NTP connectivity across the environment. For SSH I am using root. Here is the task that I have in the playbook.
- name: "Check NTP on {{override_host}}"
vars:
ansible_connection: ssh
ansible_user: "root"
ansible_password: "{{root_pwd}}"
ansible_ssh_private_key_file: "~/.ssh/f5-ansible-ssh"
command:
cmd: ntpdate -d {{item}}
loop: "{{new_ntp_servers}}"
register: ntp_status
The error message that I get is as follows
MSG:
The module failed to execute correctly, you probably need to set the interpreter.
See stdout/stderr for the exact error
MODULE_STDOUT:
/bin/sh: /usr/local/bin/python3.9: No such file or directory
MODULE_STDERR:
******************************* IMPORTANT NOTE ******************************
Banner
*****************************************************************************
Shared connection to ltm closed.
Any help would be greatly appreciated...
- Leslie_HubertusRet. Employee
AHS This doesn't seem to be specific to F5 but to Ansible itself. The following article seems to have a similar issue and it revolves around the Ansible server not knowing the path for python3.9. If you read through the article it could help you get back on track.
- AHSNimbostratus
Paulius -- Apologies for the late reply. I was tied up with another engagement. Thank you for the suggestion. I did see that git-hub post & did try the stuff mentioned there before posting here. Unfortunately, it did not help. The issue started happening after I upgraded the f5-collections. I rolled back the f5-collections to 1.22, but that still did not fix the issue. I donot think the issue was with the collections itself but a combination of collection, ansible & python version. To get this working again, I had to create a virtual environment & use that for ansible. Here are the steps
mkdir ~/tmp mv ~/.ansible ~/tmp mv ~/.cache ~/tmp mv ~/.config ~/tmp mkdir -p ~/workspace/venv cd ~/workspace/venv /usr/local/bin/python3.9 -m venv ./ansible-2.9.17 Wait for the virtual environment to get created source ~/workspace/venv/ansible-2.9.17/bin/activate pip install --upgrade pip pip list This should show you default packages with pip pip install ansible==2.9.17 pip install paramiko pip list ansible-galaxy collection install -r requirements.yml
The requirements file is as follows
--- collections: # --- F5 Collections --- - name: f5networks.f5_modules version: 1.22.0 - name: f5networks.f5_bigip # --- Required for clean STDOUT --- - name: ansible.posix # --- Required for IP management --- - name: ansible.utils # --- Required for json_query --- - name: community.general ...
I also switched to paramiko for ssh connectivity instead of ansible's built in module.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com