ansible-collections / community.network

Ansible Community Network Collection
http://galaxy.ansible.com/community/network
Other
124 stars 90 forks source link

Edgeswitches automation issue. ES-48/ES-8 can't return back requested information #527

Open VerticalMalek opened 1 year ago

VerticalMalek commented 1 year ago
SUMMARY

While trying to use edgeswitch_facts module it won't return back data which I requested (it shows me an error which is mentioned bellow)

ISSUE TYPE
COMPONENT NAME

edgeswitch_facts ansible_network_os = edgeswitch

ANSIBLE VERSION
  ansible [core 2.12.10]
  config file = /root/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 2.11.3
  libyaml = True
COLLECTION VERSION
amazon.aws                    2.3.0
ansible.netcommon             2.6.1
ansible.posix                 1.4.0
ansible.utils                 2.6.1
ansible.windows               1.10.0
arista.eos                    3.1.0
awx.awx                       19.4.0
azure.azcollection            1.13.0
check_point.mgmt              2.3.0
chocolatey.chocolatey         1.2.0
cisco.aci                     2.2.0
cisco.asa                     2.1.0
cisco.dnac                    6.5.0
cisco.intersight              1.0.19
cisco.ios                     2.8.1
cisco.iosxr                   2.9.0
cisco.ise                     1.2.1
cisco.meraki                  2.8.0
cisco.mso                     1.4.0
cisco.nso                     1.0.3
cisco.nxos                    2.9.1
cisco.ucs                     1.8.0
cloud.common                  2.1.2
cloudscale_ch.cloud           2.2.2
community.aws                 2.6.1
community.azure               1.1.0
community.ciscosmb            1.0.5
community.crypto              2.3.4
community.digitalocean        1.20.0
community.dns                 2.2.0
community.docker              2.6.0
community.fortios             1.0.0
community.general             4.8.3
community.google              1.0.0
community.grafana             1.5.0
community.hashi_vault         2.5.0
community.hrobot              1.4.0
community.kubernetes          2.0.1
community.kubevirt            1.0.0
community.libvirt             1.1.0
community.mongodb             1.4.1
community.mysql               2.3.8
community.network             3.3.0
community.okd                 2.2.0
community.postgresql          1.7.4
community.proxysql            1.4.0
community.rabbitmq            1.2.1
community.routeros            2.1.0
community.sap                 1.0.0
community.sap_libs            1.1.0
community.skydive             1.0.0
community.sops                1.2.2
community.vmware              1.18.2
community.windows             1.10.0
community.zabbix              1.7.0
containers.podman             1.9.3
cyberark.conjur               1.1.0
cyberark.pas                  1.0.14
dellemc.enterprise_sonic      1.1.1
dellemc.openmanage            4.4.0
dellemc.os10                  1.1.1
dellemc.os6                   1.0.7
dellemc.os9                   1.0.4
f5networks.f5_modules         1.17.0
fortinet.fortimanager         2.1.5
fortinet.fortios              2.1.6
frr.frr                       1.0.4
gluster.gluster               1.0.2
google.cloud                  1.0.2
hetzner.hcloud                1.6.0
hpe.nimble                    1.1.4
ibm.qradar                    1.0.3
infinidat.infinibox           1.3.3
infoblox.nios_modules         1.2.2
inspur.sm                     1.3.0
junipernetworks.junos         2.10.0
kubernetes.core               2.3.2
mellanox.onyx                 1.0.0
netapp.aws                    21.7.0
netapp.azure                  21.10.0
netapp.cloudmanager           21.18.0
netapp.elementsw              21.7.0
netapp.ontap                  21.20.0
netapp.storagegrid            21.10.0
netapp.um_info                21.8.0
netapp_eseries.santricity     1.3.0
netbox.netbox                 3.7.1
ngine_io.cloudstack           2.2.4
ngine_io.exoscale             1.0.0
ngine_io.vultr                1.1.2
openstack.cloud               1.8.0
openvswitch.openvswitch       2.1.0
ovirt.ovirt                   1.6.6
purestorage.flasharray        1.13.0
purestorage.flashblade        1.9.0
sensu.sensu_go                1.13.1
servicenow.servicenow         1.0.6
splunk.es                     1.0.2
t_systems_mms.icinga_director 1.30.0
theforeman.foreman            2.2.0
vmware.vmware_rest            2.2.0
vyos.vyos                     2.8.0
wti.remote                    1.0.4
CONFIGURATION
DEFAULT_HOST_LIST(/root/ansible.cfg) = ['/root/hosts']
DEFAULT_TIMEOUT(/root/ansible.cfg) = 5
HOST_KEY_CHECKING(/root/ansible.cfg) = False
OS / ENVIRONMENT

Proxmox, there is Debian VM where ansible is installed

STEPS TO REPRODUCE

(I'm on root user)

ansible-playbook -i hosts edge.yaml -vvvv

- name: EdgeSwitch test
  hosts: edgeswitch48
  connection: network_cli

  tasks:
  - name: running config
    community.network.edgeswitch_facts:
      gather_subset:
        - config
[edgeswitch48]
10.10.10.110
[edgeswitch8]
10.10.10.111
[edgeswitch48:vars]
ansible_network_os = edgeswitch
ansible_user=ubnt
ansible_password=ubnt
[edgeswitch8:vars]
ansible_network_os = edgeswitch
ansible_user=ubnt
ansible_password=ubnt
EXPECTED RESULTS

Getting info which i requested from Edgeswitch

ACTUAL RESULTS

ansible-playbook [core 2.12.10] config file = /root/ansible.cfg configured module search path = ['/root/.ansible/plugins/modules', '/usr/share /ansible/plugins/modules'] ansible python module location = /usr/lib/python3/dist-packages/ansible ansible collection location = /root/.ansible/collections:/usr/share/ansible/co llections executable location = /usr/bin/ansible-playbook python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] jinja version = 2.11.3 libyaml = True Using /root/ansible.cfg as config file host_list declined parsing /root/hosts as it did not pass its verify_file() meth od script declined parsing /root/hosts as it did not pass its verify_file() method auto declined parsing /root/hosts as it did not pass its verify_file() method Parsed /root/hosts inventory source with ini plugin /usr/lib/python3/dist-packages/requests/init.py:87: RequestsDependencyWarnin g: urllib3 (1.26.5) or chardet (5.1.0) doesn't match a supported version! warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported " Skipping callback 'default', as we already have a stdout callback. Skipping callback 'minimal', as we already have a stdout callback. Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: edge.yaml **** 1 plays in edge.yaml

PLAY [EdgeSwitch test] *****

TASK [Gathering Facts] ***** task path: /root/edge.yaml:1 redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon. network_cli redirecting (type: terminal) ansible.builtin.edgeswitch to community.network.edg eswitch redirecting (type: cliconf) ansible.builtin.edgeswitch to community.network.edge switch <10.10.10.110> ESTABLISH LOCAL CONNECTION FOR USER: root <10.10.10.110> EXEC /bin/sh -c '( umask 77 && mkdir -p "echo /root/.ansible/tmp/ansible-local-14944be9pkup2"&& mkdir "echo /root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832380.6743455-14948-242306386353140" && echo ansible-tmp-1677832380.6743455-14948-242306386353140="echo /root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832380.6743455-14948-242306386353140" ) && sleep 0' Using module file /usr/lib/python3/dist-packages/ansible/modules/setup.py <10.10.10.110> PUT /root/.ansible/tmp/ansible-local-14944be9pkup2/tmpffypw2ea TO /root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832380.6743455-14948-242306386353140/AnsiballZ_setup.py <10.10.10.110> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832380.6743455-14948-242306386353140/ /root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832380.6743455-14948-242306386353140/AnsiballZ_setup.py && sleep 0' <10.10.10.110> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832380.6743455-14948-242306386353140/AnsiballZ_setup.py && sleep 0' <10.10.10.110> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832380.6743455-14948-242306386353140/ > /dev/null 2>&1 && sleep 0' ok: [10.10.10.110] META: ran handlers

TASK [running config] ** task path: /root/edge.yaml:6 redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli redirecting (type: terminal) ansible.builtin.edgeswitch to community.network.edgeswitch redirecting (type: cliconf) ansible.builtin.edgeswitch to community.network.edgeswitch <10.10.10.110> ESTABLISH LOCAL CONNECTION FOR USER: root <10.10.10.110> EXEC /bin/sh -c '( umask 77 && mkdir -p "echo /root/.ansible/tmp/ansible-local-14944be9pkup2"&& mkdir "echo /root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832382.5975838-14998-101865756239201" && echo ansible-tmp-1677832382.5975838-14998-101865756239201="echo /root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832382.5975838-14998-101865756239201" ) && sleep 0' Using module file /root/.ansible/collections/ansible_collections/community/network/plugins/modules/edgeswitch_facts.py <10.10.10.110> PUT /root/.ansible/tmp/ansible-local-14944be9pkup2/tmpl_2mghgc TO /root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832382.5975838-14998-101865756239201/AnsiballZ_edgeswitch_facts.py <10.10.10.110> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832382.5975838-14998-101865756239201/ /root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832382.5975838-14998-101865756239201/AnsiballZ_edgeswitch_facts.py && sleep 0' <10.10.10.110> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832382.5975838-14998-101865756239201/AnsiballZ_edgeswitch_facts.py && sleep 0' <10.10.10.110> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832382.5975838-14998-101865756239201/ > /dev/null 2>&1 && sleep 0' The full traceback is: Traceback (most recent call last): File "/root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832382.5975838-14998-101865756239201/AnsiballZ_edgeswitch_facts.py", line 107, in _ansiballz_main() File "/root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832382.5975838-14998-101865756239201/AnsiballZ_edgeswitch_facts.py", line 99, in _ansiballz_main invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS) File "/root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832382.5975838-14998-101865756239201/AnsiballZ_edgeswitch_facts.py", line 47, in invoke_module runpy.run_module(mod_name='ansible_collections.community.network.plugins.modules.edgeswitch_facts', init_globals=dict(_module_fqn='ansible_collections.community.network.plugins.modules.edgeswitch_facts', _modlib_path=modlib_path), File "/usr/lib/python3.9/runpy.py", line 210, in run_module return _run_module_code(code, init_globals, run_name, mod_spec) File "/usr/lib/python3.9/runpy.py", line 97, in _run_module_code _run_code(code, mod_globals, init_globals, File "/usr/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/tmp/ansible_community.network.edgeswitch_facts_payload_zfpfnu9c/ansible_community.network.edgeswitch_facts_payload.zip/ansible_collections/community/network/plugins/modules/edgeswitch_facts.py", line 283, in File "/tmp/ansible_community.network.edgeswitch_facts_payload_zfpfnu9c/ansible_community.network.edgeswitch_facts_payload.zip/ansible_collections/community/network/plugins/modules/edgeswitch_facts.py", line 279, in main File "/tmp/ansible_community.network.edgeswitch_facts_payload_zfpfnu9c/ansible_community.network.edgeswitch_facts_payload.zip/ansible/module_utils/basic.py", line 1519, in exit_json File "/tmp/ansible_community.network.edgeswitch_facts_payload_zfpfnu9c/ansible_community.network.edgeswitch_facts_payload.zip/ansible/module_utils/basic.py", line 1512, in _return_formatted File "/tmp/ansible_community.network.edgeswitch_facts_payload_zfpfnu9c/ansible_community.network.edgeswitch_facts_payload.zip/ansible/module_utils/common/parameters.py", line 890, in remove_values File "/tmp/ansible_community.network.edgeswitch_facts_payload_zfpfnu9c/ansible_community.network.edgeswitch_facts_payload.zip/ansible/module_utils/common/parameters.py", line 461, in _remove_values_conditions TypeError: Value of unknown type: <class 'ansible.errors.AnsibleConnectionFailure'>, show running-config ^ % Invalid input detected at '^' marker.

(UBNT EdgeSwitch) > fatal: [10.10.10.110]: FAILED! => { "changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832382.5975838-14998-101865756239201/AnsiballZ_edgeswitch_facts.py\", line 107, in \n _ansiballz_main()\n File \"/root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832382.5975838-14998-101865756239201/AnsiballZ_edgeswitch_facts.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/root/.ansible/tmp/ansible-local-14944be9pkup2/ansible-tmp-1677832382.5975838-14998-101865756239201/AnsiballZ_edgeswitch_facts.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.community.network.plugins.modules.edgeswitch_facts', init_globals=dict(_module_fqn='ansible_collections.community.network.plugins.modules.edgeswitch_facts', _modlib_path=modlib_path),\n File \"/usr/lib/python3.9/runpy.py\", line 210, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib/python3.9/runpy.py\", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib/python3.9/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_community.network.edgeswitch_facts_payload_zfpfnu9c/ansible_community.network.edgeswitch_facts_payload.zip/ansible_collections/community/network/plugins/modules/edgeswitch_facts.py\", line 283, in \n File \"/tmp/ansible_community.network.edgeswitch_facts_payload_zfpfnu9c/ansible_community.network.edgeswitch_facts_payload.zip/ansible_collections/community/network/plugins/modules/edgeswitch_facts.py\", line 279, in main\n File \"/tmp/ansible_community.network.edgeswitch_facts_payload_zfpfnu9c/ansible_community.network.edgeswitch_facts_payload.zip/ansible/module_utils/basic.py\", line 1519, in exit_json\n File \"/tmp/ansible_community.network.edgeswitch_facts_payload_zfpfnu9c/ansible_community.network.edgeswitch_facts_payload.zip/ansible/module_utils/basic.py\", line 1512, in _return_formatted\n File \"/tmp/ansible_community.network.edgeswitch_facts_payload_zfpfnu9c/ansible_community.network.edgeswitch_facts_payload.zip/ansible/module_utils/common/parameters.py\", line 890, in remove_values\n File \"/tmp/ansible_community.network.edgeswitch_facts_payload_zfpfnu9c/ansible_community.network.edgeswitch_facts_payload.zip/ansible/module_utils/common/parameters.py\", line 461, in _remove_values_conditions\nTypeError: Value of unknown type: <class 'ansible.errors.AnsibleConnectionFailure'>, show running-config\r\n ^\r\n% Invalid input detected at '^' marker.\r\n\r\n(UBNT EdgeSwitch) >\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1 }

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

Andersson007 commented 1 year ago

@VerticalMalek hi, thanks for reporting the issue!

Andersson007 commented 1 year ago

@f-bor hi, could you please as an author take a look?

wuench commented 1 year ago

Had a similar issue. You have to set become: yes to view running-config:

---
- name: Get Edgeswitch Info
  hosts: all
  gather_facts: no
  connection: network_cli

  vars:
    ansible_network_os: edgeswitch
    ansible_host_key_checking: false

  tasks:
  - name: Get Facts
    community.network.edgeswitch_facts:
      gather_subset:
        - config
    register: output
    become: yes

  - name: Show Info
    debug:
      msg: "{{ output }}"
Andersson007 commented 1 year ago

the module author doesn't respond, so if anyone wants to fix this themselves, here's the quick start guide.

oza4h07 commented 11 months ago

What about after setting ansible_become_pass to ubnt ?

oza4h07 commented 11 months ago

@Andersson007 Is there a way to document a "full example" somewhere ?

Doc in [1] in fine but settings like ansible_become or ansible_become_method are (for good reasons, certainly) omitted there.

[1] https://docs.ansible.com/ansible/latest/collections/community/network/edgeswitch_facts_module.html#ansible-collections-community-network-edgeswitch-facts-module

Andersson007 commented 11 months ago

@Andersson007 Is there a way to document a "full example" somewhere ?

Doc in [1] in fine but settings like ansible_become or ansible_become_method are (for good reasons, certainly) omitted there.

[1] https://docs.ansible.com/ansible/latest/collections/community/network/edgeswitch_facts_module.html#ansible-collections-community-network-edgeswitch-facts-module

@oza4h07 if it's not too big and its presence is necessary (i.e. make users' life much easier), i think you can put it in the module docs in the EXAMPLES section. It can be, say, a new - block: or you can override the whole examples's content

VerticalMalek commented 11 months ago

become command actually helped. Would be great to have that in the documentation as it's not anywhere in examples section

Andersson007 commented 11 months ago

feel free to submit a PR, folks