F5Networks / f5-ansible-f5os

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

f5os.f5os_system_image_import requires 1.7.0 or higher to function #20

Open codatory opened 2 months ago

codatory commented 2 months ago
COMPONENT NAME

f5os.f5os_system_image_import

Environment

ANSIBLE VERSION
ansible --version
ansible [core 2.17.4]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /root/ansible-venv/lib64/python3.12/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /root/ansible-venv/bin/ansible
  python version = 3.12.1 (main, Aug 23 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/root/ansible-venv/bin/python3.12)
  jinja version = 3.1.4
  libyaml = True
F5OS VERSION
1.5.2-21056-LTS
CONFIGURATION

N/A

OS / ENVIRONMENT

N/A

SUMMARY

F5 OS API does not return operation-id for file import operations until F5OS 1.7.0, so all previous versions return an exception even though the image import task starts successfully.

STEPS TO REPRODUCE
- name: F5OS Base Deployment
  hosts: f5os
  connection: httpapi
  gather_facts: false

  vars_prompt:
    - name: ansible_api_user
      prompt: "Admin user"
      private: false
      default: "{{ lookup('env', 'USER') }}"
    - name: ansible_api_pass
      prompt: "Admin pass"

  vars:
    ansible_server: "{{inventory_hostname}}"
    ansible_user: "{{ansible_api_user}}"
    ansible_network_os: f5networks.f5os.f5os
    ansible_httpapi_password: "{{ ansible_api_pass }}"
    ansible_httpapi_port: 8888
    ansible_httpapi_use_ssl: true
    ansible_httpapi_use_proxy: true
    ansible_httpapi_validate_certs: false
    ansible_command_timeout: 1800
    persistent_log_messages: true

  tasks:
    - name: F5OS Image - Begin Import
      f5networks.f5os.f5os_system_image_import:
        remote_image_url: http://10.155.220.66/F5OS-A-1.7.0-8741.iso
        local_path: images/staging
        state: import
      register: import_task
    - name: DEBUG F5OS Import
      ansible.builtin.debug:
        var: import_task
    - name: F5OS Image - Wait for Import
      f5networks.f5os.f5os_system_image_import:
        timeout: 1200
        operation_id: "{{ import_task.operation_id }}"
        remote_image_url: "{{ import_task.remote_image_url }}"
        local_path: "{{ import_task.local_path }}"
        state: present
      when: import_task.changed # noqa: no-handler
EXPECTED RESULTS

Image imported and playbook continues.

ACTUAL RESULTS

Playbook exceptions and fails, image does import.

Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-local-6976px2pu1/ansible-tmp-1727145163.9415436-72-26526712713256/AnsiballZ_f5os_system_image_import.py", line 107, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-local-6976px2pu1/ansible-tmp-1727145163.9415436-72-26526712713256/AnsiballZ_f5os_system_image_import.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-local-6976px2pu1/ansible-tmp-1727145163.9415436-72-26526712713256/AnsiballZ_f5os_system_image_import.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.f5networks.f5os.plugins.modules.f5os_system_image_import', init_globals=dict(_module_fqn='ansible_collections.f5networks.f5os.plugins.modules.f5os_system_image_import', _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 "/tmp/ansible_f5networks.f5os.f5os_system_image_import_payload_ervcppea/ansible_f5networks.f5os.f5os_system_image_import_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system_image_import.py", line 512, in <module>
  File "/tmp/ansible_f5networks.f5os.f5os_system_image_import_payload_ervcppea/ansible_f5networks.f5os.f5os_system_image_import_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system_image_import.py", line 505, in main
  File "/tmp/ansible_f5networks.f5os.f5os_system_image_import_payload_ervcppea/ansible_f5networks.f5os.f5os_system_image_import_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system_image_import.py", line 239, in exec_module
  File "/tmp/ansible_f5networks.f5os.f5os_system_image_import_payload_ervcppea/ansible_f5networks.f5os.f5os_system_image_import_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system_image_import.py", line 257, in import_image
  File "/tmp/ansible_f5networks.f5os.f5os_system_image_import_payload_ervcppea/ansible_f5networks.f5os.f5os_system_image_import_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system_image_import.py", line 282, in create
  File "/tmp/ansible_f5networks.f5os.f5os_system_image_import_payload_ervcppea/ansible_f5networks.f5os.f5os_system_image_import_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system_image_import.py", line 326, in create_on_device
KeyError: 'operation-id'
fatal: [10.154.86.36]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-local-6976px2pu1/ansible-tmp-1727145163.9415436-72-26526712713256/AnsiballZ_f5os_system_image_import.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-local-6976px2pu1/ansible-tmp-1727145163.9415436-72-26526712713256/AnsiballZ_f5os_system_image_import.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-local-6976px2pu1/ansible-tmp-1727145163.9415436-72-26526712713256/AnsiballZ_f5os_system_image_import.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.f5networks.f5os.plugins.modules.f5os_system_image_import', init_globals=dict(_module_fqn='ansible_collections.f5networks.f5os.plugins.modules.f5os_system_image_import', _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 \"/tmp/ansible_f5networks.f5os.f5os_system_image_import_payload_ervcppea/ansible_f5networks.f5os.f5os_system_image_import_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system_image_import.py\", line 512, in <module>\n  File \"/tmp/ansible_f5networks.f5os.f5os_system_image_import_payload_ervcppea/ansible_f5networks.f5os.f5os_system_image_import_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system_image_import.py\", line 505, in main\n  File \"/tmp/ansible_f5networks.f5os.f5os_system_image_import_payload_ervcppea/ansible_f5networks.f5os.f5os_system_image_import_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system_image_import.py\", line 239, in exec_module\n  File \"/tmp/ansible_f5networks.f5os.f5os_system_image_import_payload_ervcppea/ansible_f5networks.f5os.f5os_system_image_import_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system_image_import.py\", line 257, in import_image\n  File \"/tmp/ansible_f5networks.f5os.f5os_system_image_import_payload_ervcppea/ansible_f5networks.f5os.f5os_system_image_import_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system_image_import.py\", line 282, in create\n  File \"/tmp/ansible_f5networks.f5os.f5os_system_image_import_payload_ervcppea/ansible_f5networks.f5os.f5os_system_image_import_payload.zip/ansible_collections/f5networks/f5os/plugins/modules/f5os_system_image_import.py\", line 326, in create_on_device\nKeyError: 'operation-id'\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-1690.