Description
SUMMARY
When using the netcommon collection for connection purpose, sometimes values of variables such as, inventory_hostname, remote_user and password are somehow not being used correctly which results in the error:
[Errno -3] Temporary failure in name resolution
And I found the following entry in the ansible.log file
<inventory_hostname> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: None on PORT 22 TO inventory_hostname
I think this could be happening after this PR ansible/ansible#79704, was merged in ansible fix a very similar issue. In short the PR has changes in paramiko_ssh.py where references like connection._play_context("remote_addr")
were changed to connection.get_option("remote_addr")
, which is not retrieving the correct value. I think that is happening because in this following snippet, the variables
variable on on line 75, only contains ansible_command_timeout
:
ansible.netcommon/plugins/connection/persistent.py
Lines 64 to 82 in d28c8fc
When the I changed variables
to the following, I didn't get the error and it worked fine for me.
variables = {
"ansible_command_timeout": self.get_option(
"persistent_command_timeout"
),
"remote_addr": self.get_option("remote_addr"),
"remote_user": self.get_option("remote_user"),
"password": self.get_option("password"),
"port": self.get_option("port"),
"private_key_file": self.get_option("private_key_file")
}
ISSUE TYPE
- Bug Report
COMPONENT NAME
ansible.netcommon
ANSIBLE VERSION
ansible [core 2.15.12] and later
COLLECTION VERSION
ansible.netcommon v5.1.1
CONFIGURATION
OS / ENVIRONMENT
ubuntu
STEPS TO REPRODUCE
Run the below playbook with ansible version 2.15.12 or later, you do not need a bigip box, you can provide a random IP, username and password
---
- name: Test
hosts: bigip
gather_facts: true
connection: local
vars:
provider:
server: "1.2.3.4"
user: user
password: pass
validate_certs: no
transport: cli
server_port: 22
no_f5_teem: yes
tasks:
- name: test
bigip_command:
commands:
- show sys version
provider: "{{ provider }}"
You'll get the error, [Errno -3] Temporary failure in name resolution
and the below entry in ansible.log file
<inventory_hostname> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: None on PORT 22 TO inventory_hostname
EXPECTED RESULTS
It should not fail with the error, [Errno -3] Temporary failure in name resolution
ACTUAL RESULTS
It's failing with the error
The full traceback is:
Traceback (most recent call last):
File "/home/ubuntu/ansible_cfgs/py310/lib/python3.10/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
File "/home/ubuntu/ansible_cfgs/py310/lib/python3.10/site-packages/ansible/executor/task_executor.py", line 656, in _execute
result = self._handler.run(task_vars=vars_copy)
File "/home/ubuntu/f5-ansible/ansible_collections/f5networks/f5_modules/plugins/action/bigip.py", line 96, in run
out = conn.get_prompt()
File "/home/ubuntu/ansible_cfgs/py310/lib/python3.10/site-packages/ansible/module_utils/connection.py", line 200, in __rpc__
raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
ansible.module_utils.connection.ConnectionError: [Errno -3] Temporary failure in name resolution
fatal: [1.2.3.4]: FAILED! =>
msg: 'Unexpected failure during module execution: [Errno -3] Temporary failure in name resolution'
stdout: ''