F5Networks / f5-ansible-f5os

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

f5networks.f5os.f5os_system gives an error when no hostname is pre-configured #21

Open RemcoAA opened 2 months ago

RemcoAA commented 2 months ago
COMPONENT NAME

f5networks.f5os.f5os_system

Environment

ANSIBLE VERSION
ansible [core 2.15.9]
  config file = /Users/xxx/Developer/xxx-F5-DO/ansible/ansible.cfg
  configured module search path = ['/Users/xxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/xxx/.homebrew/Cellar/ansible@8/8.7.0/libexec/lib/python3.11/site-packages/ansible
  ansible collection location = /Users/xxx/Developer/xxx-F5-DO/ansible/collections/ansible_collections:/usr/share/ansible/collections:/home/ts26ss/py3env01/lib/python3.10/site-packages/ansible_collections
  executable location = /Users/xxx/.homebrew/opt/ansible@8/bin/ansible
  python version = 3.11.9 (main, Apr  2 2024, 08:25:04) [Clang 15.0.0 (clang-1500.3.9.4)] (/Users/xxx/.homebrew/Cellar/ansible@8/8.7.0/libexec/bin/python)
  jinja version = 3.1.3
  libyaml = True
F5OS VERSION
1.7.0-8741
CONFIGURATION
[defaults]
host_key_checking = False
display_skipped_hosts = no
localhost_warning = false
OS / ENVIRONMENT

N/A

SUMMARY

Configuring base system settings fails when on a new device the hostname is not configured/

STEPS TO REPRODUCE

When trying to set the system settings on a new devices this module fails when the hostname is not set. When the hostname is manual set the module run without issues.

- name: Set system settings
  delegate_to: "{{ f5os_ip }}"
  f5networks.f5os.f5os_system:
    hostname: "{{ inventory_hostname }}"
    login_banner: "This system is for the use of authorized users only."
    timezone: UTC
    cli_timeout: 900
    sshd_idle_timeout: 900
    httpd_ciphersuite: ECDHE-ECDSA-AES256-GCM-SHA384:DHE-DSS-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256
    sshd_ciphers:
      - aes128-ctr
      - aes128-gcm@openssh.com
      - aes192-ctr
      - aes256-ctr
      - aes256-gcm@openssh.com
    sshd_kex_alg:
      - diffie-hellman-group14-sha256
      - diffie-hellman-group16-sha512
      - diffie-hellman-group18-sha512
      - ecdh-sha2-nistp256
      - ecdh-sha2-nistp384
      - ecdh-sha2-nistp521
      - curve25519-sha256
      - curve25519-sha256@libssh.org
    sshd_mac_alg:
      - umac-128@openssh.com
      - hmac-sha2-256
      - hmac-sha2-512
      - hmac-sha1
EXPECTED RESULTS

These system settings should be set on the device.

ACTUAL RESULTS
TASK [f5os-base-config : Set system settings] *********************************************************************************************************************************************************************************************************************************************
task path: /Users/xxx/Developer/P00983-F5-DO/ansible/roles/f5os-base-config/tasks/main.yaml:1
The full traceback is:
Traceback (most recent call last):
  File "/Users/xxx/.ansible/tmp/ansible-local-7472669ns_i5/ansible-tmp-1727185093.160814-7490-171274443706237/AnsiballZ_f5os_system.py", line 107, in <module>
    _ansiballz_main()
  File "/Users/xxx/.ansible/tmp/ansible-local-7472669ns_i5/ansible-tmp-1727185093.160814-7490-171274443706237/AnsiballZ_f5os_system.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/Users/xxx/.ansible/tmp/ansible-local-7472669ns_i5/ansible-tmp-1727185093.160814-7490-171274443706237/AnsiballZ_f5os_system.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.f5networks.f5os.plugins.modules.f5os_system', init_globals=dict(_module_fqn='ansible_collections.f5networks.f5os.plugins.modules.f5os_system', _modlib_path=modlib_path),
  File "<frozen runpy>", line 226, in run_module
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_system_payload_05n6ntak/ansible_f5networks.f5os.f5os_system_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system.py", line 900, in <module>
  File "/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_system_payload_05n6ntak/ansible_f5networks.f5os.f5os_system_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system.py", line 893, in main
  File "/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_system_payload_05n6ntak/ansible_f5networks.f5os.f5os_system_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system.py", line 467, in exec_module
  File "/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_system_payload_05n6ntak/ansible_f5networks.f5os.f5os_system_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system.py", line 481, in present
  File "/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_system_payload_05n6ntak/ansible_f5networks.f5os.f5os_system_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system.py", line 497, in update
  File "/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_system_payload_05n6ntak/ansible_f5networks.f5os.f5os_system_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system.py", line 804, in read_current_from_device
KeyError: 'openconfig-system:config'
fatal: [xxx -> xxx]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/Users/xxx/.ansible/tmp/ansible-local-7472669ns_i5/ansible-tmp-1727185093.160814-7490-171274443706237/AnsiballZ_f5os_system.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/Users/xxx/.ansible/tmp/ansible-local-7472669ns_i5/ansible-tmp-1727185093.160814-7490-171274443706237/AnsiballZ_f5os_system.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/Users/xxx/.ansible/tmp/ansible-local-7472669ns_i5/ansible-tmp-1727185093.160814-7490-171274443706237/AnsiballZ_f5os_system.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.f5networks.f5os.plugins.modules.f5os_system', init_globals=dict(_module_fqn='ansible_collections.f5networks.f5os.plugins.modules.f5os_system', _modlib_path=modlib_path),\n  File \"<frozen runpy>\", line 226, in run_module\n  File \"<frozen runpy>\", line 98, in _run_module_code\n  File \"<frozen runpy>\", line 88, in _run_code\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_system_payload_05n6ntak/ansible_f5networks.f5os.f5os_system_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system.py\", line 900, in <module>\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_system_payload_05n6ntak/ansible_f5networks.f5os.f5os_system_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system.py\", line 893, in main\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_system_payload_05n6ntak/ansible_f5networks.f5os.f5os_system_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system.py\", line 467, in exec_module\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_system_payload_05n6ntak/ansible_f5networks.f5os.f5os_system_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system.py\", line 481, in present\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_system_payload_05n6ntak/ansible_f5networks.f5os.f5os_system_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system.py\", line 497, in update\n  File \"/var/folders/j_/jg5t8wmn76q_3d9trzy6g73m0000gp/T/ansible_f5networks.f5os.f5os_system_payload_05n6ntak/ansible_f5networks.f5os.f5os_system_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system.py\", line 804, in read_current_from_device\nKeyError: 'openconfig-system:config'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}
pgouband commented 1 month ago

Hi,

Thanks for reporting. Added to the backlog and internal tracking ID for this request is: INFRAANO-1672.