opengear / opengear.om

Ansible Network Collection for Opengear OM
GNU General Public License v3.0
5 stars 7 forks source link

AttributeError: 'AnsibleUnicode' object has no attribute 'pop' #2

Closed allarm closed 2 years ago

allarm commented 2 years ago

Hi guys,

I am trying to get this collection running, have faced a couple of issues. At this point I want to understand if this collection is production ready or not (yet).

AttributeError: 'AnsibleUnicode' object has no attribute 'pop'

I'm getting this output trying to run the following playbook:

hosts

[lab]
10.10.10.10 ansible_connection=httpapi ansible_network_os=opengear.om.om

test.yml

---
- hosts: lab
  collections:
    - opengear_om
  gather_facts: false
  tasks:
    - name: Get system info
      opengear.om.om_facts:
        gather_subset: min
        gather_network_resources: system

ansible-playbook test.yml -i inventories/hosts -vvvvv

ansible-playbook 2.10.2
  config file = None
  configured module search path = ['/Users/allarm/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/allarm/.virtualenvs/default/lib/python3.8/site-packages/ansible
  executable location = /Users/allarm/.virtualenvs/default/bin/ansible-playbook
  python version = 3.8.2 (default, Aug 10 2020, 05:49:21) [Clang 12.0.0 (clang-1200.0.31.1)]
Using /Users/allarm/repos/opengear/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /Users/allarm/repos/opengear/inventories/hosts as it did not pass its verify_file() method
script declined parsing /Users/allarm/repos/opengear/inventories/hosts as it did not pass its verify_file() method
auto declined parsing /Users/allarm/repos/opengear/inventories/hosts as it did not pass its verify_file() method
Parsed /Users/allarm/repos/opengear/inventories/hosts inventory source with ini plugin
Loading collection opengear.om from /Users/allarm/.ansible/collections/ansible_collections/opengear/om
Loading callback plugin default of type stdout, v2.0 from /Users/allarm/.virtualenvs/default/lib/python3.8/site-packages/ansible/plugins/callback/default.py

PLAYBOOK: test.yml ***********************************************************************************************************************************************************************************
Positional arguments: test.yml
verbosity: 5
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/Users/allarm/repos/opengear/inventories/hosts',)
forks: 5
1 plays in test.yml

PLAY [lab] *******************************************************************************************************************************************************************************************
META: ran handlers

TASK [Get system info] *******************************************************************************************************************************************************************************
task path: /Users/allarm/repos/opengear/test.yml:7
redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi
Loading collection ansible.netcommon from /Users/allarm/.ansible/collections/ansible_collections/ansible/netcommon
The full traceback is:
Traceback (most recent call last):
  File "/Users/allarm/.virtualenvs/default/lib/python3.8/site-packages/ansible/executor/task_executor.py", line 158, in run
    res = self._execute()
  File "/Users/allarm/.virtualenvs/default/lib/python3.8/site-packages/ansible/executor/task_executor.py", line 613, in _execute
    self._connection = self._get_connection(cvars, templar)
  File "/Users/allarm/.virtualenvs/default/lib/python3.8/site-packages/ansible/executor/task_executor.py", line 908, in _get_connection
    connection, plugin_load_context = self._shared_loader_obj.connection_loader.get_with_context(
  File "/Users/allarm/.virtualenvs/default/lib/python3.8/site-packages/ansible/plugins/loader.py", line 826, in get_with_context
    obj.__init__(instance, *args, **kwargs)
  File "/Users/allarm/.ansible/collections/ansible_collections/ansible/netcommon/plugins/connection/httpapi.py", line 218, in __init__
    self.httpapi = httpapi_loader.get(self._network_os, self)
  File "/Users/allarm/.virtualenvs/default/lib/python3.8/site-packages/ansible/plugins/loader.py", line 780, in get
    return self.get_with_context(name, *args, **kwargs).object
  File "/Users/allarm/.virtualenvs/default/lib/python3.8/site-packages/ansible/plugins/loader.py", line 801, in get_with_context
    self._load_config_defs(name, self._module_cache[path], path)
  File "/Users/allarm/.virtualenvs/default/lib/python3.8/site-packages/ansible/plugins/loader.py", line 387, in _load_config_defs
    add_fragments(dstring, path, fragment_loader=fragment_loader, is_module=(type_name == 'module'))
  File "/Users/allarm/.virtualenvs/default/lib/python3.8/site-packages/ansible/utils/plugin_docs.py", line 121, in add_fragments
    fragments = doc.pop('extends_documentation_fragment', [])
AttributeError: 'AnsibleUnicode' object has no attribute 'pop'
fatal: [10.10.10.10]: FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}

PLAY RECAP *******************************************************************************************************************************************************************************************
10.10.10.10              : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

I assume the following caused by the same:

ansible-doc -t httpapi -l
...
opengear.om.om                     UNDOCUMENTED
...

ansible-doc -t httpapi opengear.om.om
ERROR! httpapi opengear.om.om missing documentation (or could not parse documentation): 'AnsibleUnicode' object has no attribute 'get'
ansible --version
ansible 2.10.2
  config file = None
  configured module search path = ['/Users/allarm/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/allarm/.virtualenvs/default/lib/python3.8/site-packages/ansible
  executable location = /Users/allarm/.virtualenvs/default/bin/ansible
  python version = 3.8.2 (default, Aug 10 2020, 05:49:21) [Clang 12.0.0 (clang-1200.0.31.1)]

Thank you.

avankatwyk commented 2 years ago

Hi @allarm, apologies for the late reply. I worked on this Ansible collection as a thesis project which has since ended and as such, I have not worked on the collection since uploading it to Github. I am aware that it very likely contains many bugs and is not in a production-ready state. As for the future of this collection, I will notify people at Opengear that there is interest in the project but I am currently busy with other obligations and thus will likely not be able to fix these issues myself in the near future.

avankatwyk commented 2 years ago

Also another thing, I believe that the ansible_network_os variable in the host file should just be opengear.om rather than opengear.om.om.

allarm commented 2 years ago

Hi @AdroDude, thank you for your answer. It's not possible to use in prod then, unfortunately. I hope this project will get some attention from the Opengear team in the future - being able to automate OM using Ansible is a nice to have in huge setups.

In the meantime, I created a tool that generates a set of Ansible playbooks from RAML API specification that serves my needs well for a moment.

Thank you again. /Andrey