F5Networks / f5-ansible-f5os

Collection for managing F5OS based devices
2 stars 1 forks source link

Sending telemetry errors with f5os_device_info #1

Closed Omripresent closed 1 year ago

Omripresent commented 1 year ago
COMPONENT NAME

f5os_device_info

Environment

ANSIBLE VERSION
2.13.5
F5OS VERSION
1.3.1
CONFIGURATION
OS / ENVIRONMENT

N/A

SUMMARY

In certain conditions when running f5os_device_info the F5Client class has no client kwarg and the module run fails with AttributeError

Should handle variable better on line 74, for example:

if client.plugin is not None and client.plugin.telemetry():
STEPS TO REPRODUCE
- hosts: all
  collections:
    - f5networks.f5os
  connection: httpapi
  vars:
    ansible_host: "lb.mydomain.com"
    ansible_user: "admin"
    ansible_httpapi_password: "secret"
    ansible_network_os: f5networks.f5os.f5os
    ansible_httpapi_use_ssl: yes
  tasks:
    - name: Collect all F5OS device information
      f5os_device_info:
        gather_subset:
          - all
EXPECTED RESULTS
ACTUAL RESULTS
TASK [Collect all F5OS device information] *********************************************************************************************************************************************************************************************************************
task path: *REDACTED*/f5os-info.yaml:21
redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi
Loading collection ansible.netcommon from /var/opt/ansible/collections/ansible_collections/ansible/netcommon
<*REDACTED*> attempting to start connection
<*REDACTED*> using connection plugin ansible.netcommon.httpapi
Found ansible-connection at path /var/opt/ansible/venv/bin/ansible-connection
<*REDACTED*> found existing local domain socket, using it!
<*REDACTED*> updating play_context for connection
<*REDACTED*>
<*REDACTED*> local domain socket path is /root/.ansible/pc/a09fe927ba
<*REDACTED*> ESTABLISH LOCAL CONNECTION FOR USER: root
<*REDACTED*> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-local-4169668_lubgppz `"&& mkdir "` echo /root/.ansible/tmp/ansible-local-4169668_lubgppz/ansible-tmp-1672334102.0005035-4169772-111621317794636 `" && echo ansible-tmp-1672334102.0005035-4169772-111621317794636="` echo /root/.ansible/tmp/ansible-local-4169668_lubgppz/ansible-tmp-1672334102.0005035-4169772-111621317794636 `" ) && sleep 0'
Using module file /var/opt/ansible/collections/ansible_collections/f5networks/f5os/plugins/modules/f5os_device_info.py
<*REDACTED*> PUT /root/.ansible/tmp/ansible-local-4169668_lubgppz/tmpii7bl60d TO /root/.ansible/tmp/ansible-local-4169668_lubgppz/ansible-tmp-1672334102.0005035-4169772-111621317794636/AnsiballZ_f5os_device_info.py
<*REDACTED*> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-local-4169668_lubgppz/ansible-tmp-1672334102.0005035-4169772-111621317794636/ /root/.ansible/tmp/ansible-local-4169668_lubgppz/ansible-tmp-1672334102.0005035-4169772-111621317794636/AnsiballZ_f5os_device_info.py && sleep 0'
<*REDACTED*> EXEC /bin/sh -c '/var/opt/ansible/venv/bin/python /root/.ansible/tmp/ansible-local-4169668_lubgppz/ansible-tmp-1672334102.0005035-4169772-111621317794636/AnsiballZ_f5os_device_info.py && sleep 0'
<*REDACTED*> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-local-4169668_lubgppz/ansible-tmp-1672334102.0005035-4169772-111621317794636/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-local-4169668_lubgppz/ansible-tmp-1672334102.0005035-4169772-111621317794636/AnsiballZ_f5os_device_info.py", line 107, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-local-4169668_lubgppz/ansible-tmp-1672334102.0005035-4169772-111621317794636/AnsiballZ_f5os_device_info.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-local-4169668_lubgppz/ansible-tmp-1672334102.0005035-4169772-111621317794636/AnsiballZ_f5os_device_info.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.f5networks.f5os.plugins.modules.f5os_device_info', init_globals=dict(_module_fqn='ansible_collections.f5networks.f5os.plugins.modules.f5os_device_info', _modlib_path=modlib_path),
  File "/usr/lib/python3.10/runpy.py", line 209, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_f5os_device_info_payload_z_bkbvhx/ansible_f5os_device_info_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_device_info.py", line 1319, in <module>
  File "/tmp/ansible_f5os_device_info_payload_z_bkbvhx/ansible_f5os_device_info_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_device_info.py", line 1305, in main
  File "/tmp/ansible_f5os_device_info_payload_z_bkbvhx/ansible_f5os_device_info_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_device_info.py", line 1211, in exec_module
  File "/tmp/ansible_f5os_device_info_payload_z_bkbvhx/ansible_f5os_device_info_payload.zip/ansible_collections/f5networks/f5os/plugins/module_utils/client.py", line 74, in send_teem
AttributeError: 'NoneType' object has no attribute 'telemetry'
fatal: [m1e-pgc-lbhv-d01]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-local-4169668_lubgppz/ansible-tmp-1672334102.0005035-4169772-111621317794636/AnsiballZ_f5os_device_info.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-local-4169668_lubgppz/ansible-tmp-1672334102.0005035-4169772-111621317794636/AnsiballZ_f5os_device_info.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-local-4169668_lubgppz/ansible-tmp-1672334102.0005035-4169772-111621317794636/AnsiballZ_f5os_device_info.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.f5networks.f5os.plugins.modules.f5os_device_info', init_globals=dict(_module_fqn='ansible_collections.f5networks.f5os.plugins.modules.f5os_device_info', _modlib_path=modlib_path),\n  File \"/usr/lib/python3.10/runpy.py\", line 209, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.10/runpy.py\", line 96, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_f5os_device_info_payload_z_bkbvhx/ansible_f5os_device_info_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_device_info.py\", line 1319, in <module>\n  File \"/tmp/ansible_f5os_device_info_payload_z_bkbvhx/ansible_f5os_device_info_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_device_info.py\", line 1305, in main\n  File \"/tmp/ansible_f5os_device_info_payload_z_bkbvhx/ansible_f5os_device_info_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_device_info.py\", line 1211, in exec_module\n  File \"/tmp/ansible_f5os_device_info_payload_z_bkbvhx/ansible_f5os_device_info_payload.zip/ansible_collections/f5networks/f5os/plugins/module_utils/client.py\", line 74, in send_teem\nAttributeError: 'NoneType' object has no attribute 'telemetry'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}
wojtek0806 commented 1 year ago

client should never be none, if it is at that stage then something else is breaking, there is another issue with platform detection function, that i will be fixing, after its merged retest to see if you see the problem

wojtek0806 commented 1 year ago

looks like client was not instantiated properly, i have fixed it and it will be in the 1.1 release, for now you can disable telemetry with the following playbook variable:

f5_telemetry: false