Closed mitchmahan closed 9 months ago
@mitchmahan hello, thanks for reporting the issue!
@privateip ,as its author, would you like to take a look?
If anyone else wants to fix this, there's the quick start guide.
I found a commit in ansible-core that may or may not be related to the underlying issue: https://github.com/ansible/ansible/commit/bf1ef5a1f3562c9a59168adbc78750304c3e4309
lib/ansible/executor/task_executor.py
Looks like the def _set_plugin_options(self, plugin_type, variables, templar, task_keys): method was updated:
sub = getattr(self._connection, '_sub_plugin', None)
if sub is not None and sub.get('type') != 'external':
plugin_type = get_plugin_class(sub.get("obj"))
varnames.extend(self._set_plugin_options(plugin_type, variables, templar, task_keys)) # This line explodes when plugin_type is “nonetype”
I am not sure where "_sub_plugin" should be coming from in regards to the SROS / community.network module? Perhaps something undefined? Would be curious what the solution is!
sub = getattr(self._connection, '_sub_plugin', None) # this returns "nonetype" and not just "None" which explodes task_executor.
@mitchmahan as the author does not respond, the issue would welcome any help from interested folks. Quick-start dev guide.
I'm trying to wrap my brain around this issue as I'm experiencing it with both the sros_command.py
and sros_config.py
As far I understand these modules use the network_cil.py
plugin.
You can see where it could get the _sub_plugin
information here: https://github.com/ansible-collections/ansible.netcommon/blob/main/plugins/connection/network_cli.py#L385
But my understanding is that the sros modules use terminal.sros.py
(I could wrong here, I'm struggling to grasp everything)
Looking at https://github.com/ansible-collections/ansible.netcommon/blob/main/plugins/connection/network_cli.py#L380 it looks like there is no _sub_plugin
for terminal plugins (maybe I'm misunderstanding this if statement)
This may be the root of the issue but if so are terminal connections suppose to have a _sub_plugin
?
I just don't know enough about ansible under the hood...
Looks like there may be a possible 'grandfathered-in' fix in the works but it appears to have grown stale :-( https://github.com/ansible/ansible/issues/79371
@JCTechSol thanks for trying to investigate the issue! was on PTO i, not being involved in development of network stuff, am not able to take part in the discussion efficiently. the reason can be some breaking changes introduced in ansible.netcommon. how about asking its devs directly in https://matrix.to/#/#network:ansible.com. it's very straightforward to join, see in the communication guide how
FYI if someone submits a fix for this issue, i can review (for general things like SemVer compliance and docs) and merge it
This PR should address this issue https://github.com/ansible-collections/ansible.netcommon/pull/569
@JCTechSol thanks for the info! do you think if we can close the issue here then?
https://github.com/ansible/ansible/issues/79371
This change may also address/fix this defect.
@mitchmahan thanks for closing the issue!
SUMMARY
Unable to call community.network.sros_command using ansible-core versions higher or equal to 2.13.4. When using ansible-core >=2.13.4 sros_command raises an exception.
The full traceback is: Traceback (most recent call last): File "/Users/mitchmahan/.ansible/collections/ansible_collections/ansible/netcommon/plugins/plugin_utils/connection_base.py", line 42, in getattr return self.dict[name] KeyError: '_nonetype'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/Users/mitchmahan/.local/share/virtualenvs/automation-gateway-tZUugwBO/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 1009, in _set_plugin_options plugin = getattr(self.connection, '%s' % plugin_type) File "/Users/mitchmahan/.ansible/collections/ansible_collections/ansible/netcommon/plugins/plugin_utils/connection_base.py", line 50, in getattr raise AttributeError( AttributeError: 'Connection' object has no attribute '_nonetype'
ISSUE TYPE
COMPONENT NAME
sros_command
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Reproduced in MacOS and Linux OS, multiple versions of community.network
STEPS TO REPRODUCE
Use sros_command with ansible-core==2.13.4 and the command will fail. Using sros_command with ansible-core==2.13.3 and the command runs successfully.
EXPECTED RESULTS
Show version command should run successfully.
ACTUAL RESULTS
Command fails with any version above 2.13.3. Works fine with 2.13.3. pip install ansible-core==2.13.4