ansible-junos-stdlib
ansible-junos-stdlib copied to clipboard
AttributeError: 'Connection' object has no attribute 'nonetype' (ansible-core >=2.12.9)
Issue Type
- Bug Report
Module Name
juniper.device.config
juniper.device collection and Python libraries version
containeruser@acm-qalab-nre01:/data$ ansible --version
ansible [core 2.12.9]
config file = /data/ansible.cfg
configured module search path = ['/home/containeruser/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible
ansible collection location = /home/containeruser/.ansible/collections:/usr/share/ansible/collections
executable location = /home/containeruser/.pyenv/versions/3.9.16/bin/ansible
python version = 3.9.16 (main, Dec 14 2022, 17:40:20) [GCC 10.2.1 20210110]
jinja version = 3.1.2
libyaml = True
containeruser@acm-qalab-nre01:/data$ pip freeze
ansible==5.10.0
ansible-core==2.12.9
bcrypt==4.0.1
cffi==1.15.1
colorama==0.4.6
configparser==5.3.0
cryptography==38.0.4
future==0.18.2
icdiff==2.0.5
Jinja2==3.1.2
jsnapy==1.3.6
junos-eznc==2.6.0
jxmlease==1.0.1
lxml==4.9.1
MarkupSafe==2.1.1
ncclient==0.6.9
netaddr==0.8.0
packaging==22.0
paramiko==2.12.0
pycparser==2.21
PyNaCl==1.5.0
pyparsing==3.0.9
pyserial==3.5
PyYAML==6.0
resolvelib==0.5.4
scp==0.14.4
six==1.16.0
transitions==0.9.0
xmltodict==0.13.0
yamlordereddictloader==0.4.0
OS / Environment
Juniper MX960 running JUNOS 20.4R3-S3.4
Summary
- Bug occurs regardless of Python versions tested (3.7, 3.8, 3.9, 3.10)
- Bug occurs upon installation of ansible-core version 2.12.9 or greater
- Bug only occurs while using 'juniper.device.pyez' connection type. 'local' connection type works as expected.
Steps to reproduce
- name: backup, configure, rollback
hosts: acm-lab-core1.custcbb.local
collections:
- juniper.device
connection: juniper.device.pyez
gather_facts: no
tasks:
- juniper.device.config:
check: false
commit: false
dest: "backup/{{ lookup('pipe','date +%Y-%m-%d-%H-%M-%S') }}_{{ inventory_hostname_short }}.config"
diff: false
retrieve: "committed"
Expected results
For the juniper.device.config task to execute successfully and report an "ok" status
Actual results
Successfully built ansible-core
Installing collected packages: ansible-core
Attempting uninstall: ansible-core
Found existing installation: ansible-core 2.12.8
Uninstalling ansible-core-2.12.8:
Successfully uninstalled ansible-core-2.12.8
Successfully installed ansible-core-2.12.9
containeruser@acm-qalab-nre01:/data$ ansible-playbook -e "@creds.json" pb.load-config.yaml
PLAY [backup, configure, rollback] *********************************************
TASK [juniper.device.config] ***************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'Connection' object has no attribute 'nonetype'
fatal: [acm-lab-core1.custcbb.local]: FAILED! => {"msg": "Unexpected failure during module execution.", "stdout": ""}
Fully verbose (-vvvv) output for the final task:
TASK [juniper.device.config] ***************************************************
task path: /data/pb.load-config.yaml:9
Loading collection ansible.netcommon from /home/containeruser/.ansible/collections/ansible_collections/ansible/netcommon
The full traceback is:
Traceback (most recent call last):
File "/home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible/plugins/connection/__init__.py", line 262, in __getattr__
return self.__dict__[name]
KeyError: '_nonetype'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 985, in _set_plugin_options
plugin = getattr(self._connection, '_%s' % plugin_type)
File "/home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible/plugins/connection/__init__.py", line 270, in __getattr__
raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, name))
AttributeError: 'Connection' object has no attribute '_nonetype'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible/plugins/connection/__init__.py", line 262, in __getattr__
return self.__dict__[name]
KeyError: 'nonetype'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 159, in run
res = self._execute()
File "/home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 550, in _execute
plugin_vars = self._set_connection_options(cvars, templar)
File "/home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 1067, in _set_connection_options
varnames.extend(self._set_plugin_options(plugin_type, variables, templar, task_keys))
File "/home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 988, in _set_plugin_options
plugin = getattr(self._connection, plugin_type)
File "/home/containeruser/.pyenv/versions/3.9.16/lib/python3.9/site-packages/ansible/plugins/connection/__init__.py", line 270, in __getattr__
raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, name))
AttributeError: 'Connection' object has no attribute 'nonetype'
fatal: [acm-lab-core1.custcbb.local]: FAILED! => {
"msg": "Unexpected failure during module execution.",
"stdout": ""
}