F5Networks / f5-ansible-bigip

Declarative Ansible collection for managing F5 BIG-IP/BIG-IQ.
37 stars 17 forks source link

KeyError using bigip_device_info module when parameter gather_subset is set with all. #7

Closed leondelyon3 closed 3 years ago

leondelyon3 commented 3 years ago
COMPONENT NAME

bigip_device_info

Environment

ANSIBLE VERSION
ansible [core 2.11.4] 
  config file = /home/lionel/PyCharmProjects/venv3-8-5/Ansible/ansible.cfg
  configured module search path = ['/home/lionel/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/lionel/PyCharmProjects/venv3-8-5/lib/python3.8/site-packages/ansible
  ansible collection location = /home/lionel/PyCharmProjects/venv3-8-5/Ansible/collections
  executable location = /home/lionel/PyCharmProjects/venv3-8-5/bin/ansible
  python version = 3.8.5 (default, Sep 13 2020, 10:59:50) [GCC 9.3.0]
  jinja version = 3.0.1
  libyaml = True
BIGIP VERSION
Sys::Version                                
Main Package                                
  Product     BIG-IP                        
  Version     15.1.3.1                      
  Build       0.0.18                        
  Edition     Point Release 1               
  Date        Mon Jul 12 23:47:21 PDT 2021  
CONFIGURATION

[defaults] inventory = /home/lionel/PyCharmProjects/venv3-8-5/Ansible/inventory/hosts roles_path = ./roles collections_paths = ./collections retry_files_enabled = False host_key_checking = false forks = 15 module_name = raw vault_password_file = /home/lionel/PyCharmProjects/venv3-8-5/Ansible/.vault_pass.txt interpreter_python = auto_silent string_conversion_action = ignore

merge_multiple_cli_tags = True

[persistent_connection] connect_timeout = 240 connect_retry_timeout = 30 command_timeout = 300

[ssh_connection] pipelining = True scp_if_ssh = smart

OS / ENVIRONMENT

Ubuntu 20.04

SUMMARY

Got KeyError using bigip_device_info module when parameter gather_subset is set with all.

STEPS TO REPRODUCE

Using following command: ansible-playbook PlayBooks/bigipv2.yml -e '{"cible":"bigipa"}' -t fact -vvvv see below the playbook

---
- name: Backup F5 device
  hosts: "{{ cible }}"
  gather_facts: false
  strategy: linear
  connection: httpapi
  collections:
    - f5networks.f5_bigip

  vars:
    msg: "{{ lookup('pipe','date +%Y-%m-%d-%H-%M-%S') }}"

  tasks:
    - name: Collect BIG-IP information
      bigip_device_info:
        gather_subset:
          - all
      tags: fact
      register: output_f5

    - debug:
        var=output_f5
      tags: fact
EXPECTED RESULTS

Should get device info.

ACTUAL RESULTS
TASK [Collect BIG-IP information] ****************************************************************************************************************************************************************************
task path: /home/lionel/PyCharmProjects/venv3-8-5/Ansible/PlayBooks/bigipv2.yml:48
redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi
Loading collection ansible.netcommon from /home/lionel/PyCharmProjects/venv3-8-5/Ansible/collections/ansible_collections/ansible/netcommon
<10.171.60.227> attempting to start connection
<10.171.60.227> using connection plugin ansible.netcommon.httpapi
Found ansible-connection at path /home/lionel/PyCharmProjects/venv3-8-5/bin/ansible-connection
<10.171.60.227> local domain socket does not exist, starting it
<10.171.60.227> control socket path is /home/lionel/.ansible/pc/76fcc6d478
<10.171.60.227> redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi
<10.171.60.227> Loading collection ansible.netcommon from /home/lionel/PyCharmProjects/venv3-8-5/Ansible/collections/ansible_collections/ansible/netcommon
<10.171.60.227> Loading collection f5networks.f5_bigip from /home/lionel/PyCharmProjects/venv3-8-5/Ansible/collections/ansible_collections/f5networks/f5_bigip
<10.171.60.227> local domain socket listeners started successfully
<10.171.60.227> loaded API plugin ansible_collections.f5networks.f5_bigip.plugins.httpapi.bigip from path /home/lionel/PyCharmProjects/venv3-8-5/Ansible/collections/ansible_collections/f5networks/f5_bigip/plugins/httpapi/bigip.py for network_os f5networks.f5_bigip.bigip
<10.171.60.227> 
<10.171.60.227> local domain socket path is /home/lionel/.ansible/pc/76fcc6d478
<10.171.60.227> Using network group action bigip for bigip_device_info
<10.171.60.227> ANSIBLE_NETWORK_IMPORT_MODULES: disabled
<10.171.60.227> ANSIBLE_NETWORK_IMPORT_MODULES: module execution time may be extended
<10.171.60.227> ESTABLISH LOCAL CONNECTION FOR USER: lionel
<10.171.60.227> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/lionel/.ansible/tmp/ansible-local-1265559zhgh_rg `"&& mkdir "` echo /home/lionel/.ansible/tmp/ansible-local-1265559zhgh_rg/ansible-tmp-1629272996.2444608-126560-40012778561303 `" && echo ansible-tmp-1629272996.2444608-126560-40012778561303="` echo /home/lionel/.ansible/tmp/ansible-local-1265559zhgh_rg/ansible-tmp-1629272996.2444608-126560-40012778561303 `" ) && sleep 0'
Using module file /home/lionel/PyCharmProjects/venv3-8-5/Ansible/collections/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_device_info.py
<10.171.60.227> PUT /home/lionel/.ansible/tmp/ansible-local-1265559zhgh_rg/tmp1z2dqbzg TO /home/lionel/.ansible/tmp/ansible-local-1265559zhgh_rg/ansible-tmp-1629272996.2444608-126560-40012778561303/AnsiballZ_bigip_device_info.py
<10.171.60.227> EXEC /bin/sh -c 'chmod u+x /home/lionel/.ansible/tmp/ansible-local-1265559zhgh_rg/ansible-tmp-1629272996.2444608-126560-40012778561303/ /home/lionel/.ansible/tmp/ansible-local-1265559zhgh_rg/ansible-tmp-1629272996.2444608-126560-40012778561303/AnsiballZ_bigip_device_info.py && sleep 0'
<10.171.60.227> EXEC /bin/sh -c '/home/lionel/PyCharmProjects/venv3-8-5/bin/python /home/lionel/.ansible/tmp/ansible-local-1265559zhgh_rg/ansible-tmp-1629272996.2444608-126560-40012778561303/AnsiballZ_bigip_device_info.py && sleep 0'
<10.171.60.227> EXEC /bin/sh -c 'rm -f -r /home/lionel/.ansible/tmp/ansible-local-1265559zhgh_rg/ansible-tmp-1629272996.2444608-126560-40012778561303/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/home/lionel/.ansible/tmp/ansible-local-1265559zhgh_rg/ansible-tmp-1629272996.2444608-126560-40012778561303/AnsiballZ_bigip_device_info.py", line 100, in <module>
    _ansiballz_main()
  File "/home/lionel/.ansible/tmp/ansible-local-1265559zhgh_rg/ansible-tmp-1629272996.2444608-126560-40012778561303/AnsiballZ_bigip_device_info.py", line 92, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/lionel/.ansible/tmp/ansible-local-1265559zhgh_rg/ansible-tmp-1629272996.2444608-126560-40012778561303/AnsiballZ_bigip_device_info.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.f5networks.f5_bigip.plugins.modules.bigip_device_info', init_globals=dict(_module_fqn='ansible_collections.f5networks.f5_bigip.plugins.modules.bigip_device_info', _modlib_path=modlib_path),
  File "/usr/local/lib/python3.8/runpy.py", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/local/lib/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_bigip_device_info_payload_h2wey8w6/ansible_bigip_device_info_payload.zip/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_device_info.py", line 16797, in <module>
  File "/tmp/ansible_bigip_device_info_payload_h2wey8w6/ansible_bigip_device_info_payload.zip/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_device_info.py", line 16784, in main
  File "/tmp/ansible_bigip_device_info_payload_h2wey8w6/ansible_bigip_device_info_payload.zip/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_device_info.py", line 16502, in exec_module
  File "/tmp/ansible_bigip_device_info_payload_h2wey8w6/ansible_bigip_device_info_payload.zip/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_device_info.py", line 16583, in execute_managers
  File "/tmp/ansible_bigip_device_info_payload_h2wey8w6/ansible_bigip_device_info_payload.zip/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_device_info.py", line 9070, in exec_module
  File "/tmp/ansible_bigip_device_info_payload_h2wey8w6/ansible_bigip_device_info_payload.zip/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_device_info.py", line 9077, in _exec_module
  File "/tmp/ansible_bigip_device_info_payload_h2wey8w6/ansible_bigip_device_info_payload.zip/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_device_info.py", line 9081, in read_facts
  File "/tmp/ansible_bigip_device_info_payload_h2wey8w6/ansible_bigip_device_info_payload.zip/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_device_info.py", line 9092, in read_collection_from_device
KeyError: 0
fatal: [bigipa]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/home/lionel/.ansible/tmp/ansible-local-1265559zhgh_rg/ansible-tmp-1629272996.2444608-126560-40012778561303/AnsiballZ_bigip_device_info.py\", line 100, in <module>\n    _ansiballz_main()\n  File \"/home/lionel/.ansible/tmp/ansible-local-1265559zhgh_rg/ansible-tmp-1629272996.2444608-126560-40012778561303/AnsiballZ_bigip_device_info.py\", line 92, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/lionel/.ansible/tmp/ansible-local-1265559zhgh_rg/ansible-tmp-1629272996.2444608-126560-40012778561303/AnsiballZ_bigip_device_info.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.f5networks.f5_bigip.plugins.modules.bigip_device_info', init_globals=dict(_module_fqn='ansible_collections.f5networks.f5_bigip.plugins.modules.bigip_device_info', _modlib_path=modlib_path),\n  File \"/usr/local/lib/python3.8/runpy.py\", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/local/lib/python3.8/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/local/lib/python3.8/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_bigip_device_info_payload_h2wey8w6/ansible_bigip_device_info_payload.zip/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_device_info.py\", line 16797, in <module>\n  File \"/tmp/ansible_bigip_device_info_payload_h2wey8w6/ansible_bigip_device_info_payload.zip/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_device_info.py\", line 16784, in main\n  File \"/tmp/ansible_bigip_device_info_payload_h2wey8w6/ansible_bigip_device_info_payload.zip/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_device_info.py\", line 16502, in exec_module\n  File \"/tmp/ansible_bigip_device_info_payload_h2wey8w6/ansible_bigip_device_info_payload.zip/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_device_info.py\", line 16583, in execute_managers\n  File \"/tmp/ansible_bigip_device_info_payload_h2wey8w6/ansible_bigip_device_info_payload.zip/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_device_info.py\", line 9070, in exec_module\n  File \"/tmp/ansible_bigip_device_info_payload_h2wey8w6/ansible_bigip_device_info_payload.zip/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_device_info.py\", line 9077, in _exec_module\n  File \"/tmp/ansible_bigip_device_info_payload_h2wey8w6/ansible_bigip_device_info_payload.zip/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_device_info.py\", line 9081, in read_facts\n  File \"/tmp/ansible_bigip_device_info_payload_h2wey8w6/ansible_bigip_device_info_payload.zip/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_device_info.py\", line 9092, in read_collection_from_device\nKeyError: 0\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

PLAY RECAP ***************************************************************************************************************************************************************************************************
bigipa                     : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0 
leondelyon3 commented 3 years ago

f5_bigip "version": "1.2.0-devel"

wojtek0806 commented 3 years ago

issue logged internally: INFRAANO-500

will be fixed in 1.2.0 at release, once I merge to devel, i will put a notice here to pull the devel build so you don't wait till tomorrow.

wojtek0806 commented 3 years ago

changes merged into devel: https://github.com/F5Networks/f5-ansible-bigip/commit/9bfb62c5ae546692497a1251e2ae5df5231c9444