Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

bigip_do_deploy check task status returns no message for successful task #93

@scoffeyfv

Description

@scoffeyfv
COMPONENT NAME

bigip_do_deploy

Environment

ANSIBLE VERSION
ansible [core 2.17.12]
  config file = /etc/ansible/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.10.12 (main, Feb  4 2025, 14:57:36) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True
BIGIP VERSION
Sys::Version
Main Package
  Product     BIG-IP
  Version     17.1.2.1
  Build       0.284.2
  Edition     Engineering Hotfix
  Date        Fri Mar 21 03:08:05 PDT 2025

Hotfix List
ID1787517-3   ID1626337-1  ID1623941  ID1602641-4  ID1296553-3  ID1004953-6
ID1672997-2 

(DO version 1.46)

CONFIGURATION

No custom changes

OS / ENVIRONMENT

Ubuntu but don't believe this is platform specific

SUMMARY

When using bigip_do_deploy to retrieve task result, no return value 'message' is returned if the task was successfully completed.
It is contrary to the suggestion of the sample value for 'message' ("task has been completed").
It causes example playbooks to fail where the response of the declaration task is registered and the value of 'message' tested.

STEPS TO REPRODUCE

Use bigip_do_deploy with content of a valid DO declaration.
Check the task status.
Register and print the response, see there is no 'message' value.
Use a condition to detect a status such as ongoing device restart, e.g. result.message == "Device is restarting services, unable to check task status." (as per examples).
This check will likely fail due to 'message' not being defined.

Example tasks:

- name: REQUEST BIGIP PLATFORM RECONFIGURATION (USING DO)
  f5networks.f5_bigip.bigip_do_deploy:
    content: "{{ lookup('ansible.builtin.template', 'simple_dns_template.json') }}"
  register: requestResponse

- name: GET DO TASK STATUS
  f5networks.f5_bigip.bigip_do_deploy:
    task_id: "{{ requestResponse.task_id }}"
  register: requestResult

- name: PRINT RESPONSE     
  ansible.builtin.debug:
    msg: "DO task result: {{ requestResult }}"

- name: WAIT 4 MINS IF A RESTART WAS NEEDED
  pause:
    minutes: 4
  when:
    -  requestResult.message == "Device is restarting services, unable to check task status."

EXPECTED RESULTS

The check of task status should return a message indicating completion (e.g. 'task completed').
Playbook logic can then be used to wait or proceed as needed.

ACTUAL RESULTS

Check of task status does not include a message value, so an error occurs due the 'when' condition per examples.

ansible-playbook [core 2.17.12]
  config file = /etc/ansible/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-playbook
  python version = 3.10.12 (main, Feb  4 2025, 14:57:36) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
Loading collection ansible.builtin from 
host_list declined parsing /root/scripts/green/playbooks/inventory.yml as it did not pass its verify_file() method
script declined parsing /root/scripts/green/playbooks/inventory.yml as it did not pass its verify_file() method
Parsed /root/scripts/green/playbooks/inventory.yml inventory source with yaml plugin
Loading collection f5networks.f5_bigip from /root/.ansible/collections/ansible_collections/f5networks/f5_bigip
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python3/dist-packages/ansible/plugins/callback/default.py
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: f5_bigip_onboard.yaml ***************************************************************************************************************************************************************************************************************
Positional arguments: ../green/playbooks/f5_bigip_onboard.yaml
verbosity: 4
connection: ssh
become_method: sudo
tags: ('all',)
inventory: ('/root/scripts/green/playbooks/inventory.yml',)
forks: 5
1 plays in ../green/playbooks/f5_bigip_onboard.yaml

PLAY [lab-ltm-1a] *****************************************************************************************************************************************************************************************************************************

TASK [bigip_onboard : REQUEST BIGIP PLATFORM CONFIGURATION (USING DO)] ************************************************************************************************************************************************************************
task path: /root/scripts/green/playbooks/roles/bigip_onboard/tasks/main.yaml:1
File lookup using /root/scripts/green/playbooks/roles/bigip_onboard/templates/simple_dns_template.json as file
redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi
Loading collection ansible.netcommon from /usr/lib/python3/dist-packages/ansible_collections/ansible/netcommon
Loading collection ansible.utils from /usr/lib/python3/dist-packages/ansible_collections/ansible/utils
<10.154.80.76> Using network group action f5networks.f5_bigip.bigip for f5networks.f5_bigip.bigip_do_deploy
<10.154.80.76> attempting to start connection
<10.154.80.76> using connection plugin ansible.netcommon.httpapi
Found ansible-connection at path /usr/bin/ansible-connection
<10.154.80.76> local domain socket does not exist, starting it
<10.154.80.76> control socket path is /root/.ansible/pc/bccabcd7e7
<10.154.80.76> Loading collection ansible.builtin from 
<10.154.80.76> redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi
<10.154.80.76> Loading collection ansible.netcommon from /usr/lib/python3/dist-packages/ansible_collections/ansible/netcommon
<10.154.80.76> Loading collection ansible.utils from /usr/lib/python3/dist-packages/ansible_collections/ansible/utils
<10.154.80.76> Loading collection f5networks.f5_bigip from /root/.ansible/collections/ansible_collections/f5networks/f5_bigip
<10.154.80.76> local domain socket listeners started successfully
<10.154.80.76> loaded API plugin ansible_collections.f5networks.f5_bigip.plugins.httpapi.bigip from path /root/.ansible/collections/ansible_collections/f5networks/f5_bigip/plugins/httpapi/bigip.py for platform type f5networks.f5_bigip.bigip
<10.154.80.76> Loading collection ansible.builtin from 
<10.154.80.76> local domain socket path is /root/.ansible/pc/bccabcd7e7
<10.154.80.76> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
<10.154.80.76> ANSIBLE_NETWORK_IMPORT_MODULES: found f5networks.f5_bigip.bigip_do_deploy  at /root/.ansible/collections/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_do_deploy.py
<10.154.80.76> ANSIBLE_NETWORK_IMPORT_MODULES: running f5networks.f5_bigip.bigip_do_deploy
<10.154.80.76> ANSIBLE_NETWORK_IMPORT_MODULES: complete
changed: [lab-ltm-1a] => {
    "changed": true,
    "content": {
        "$schema": "https://raw.githubusercontent.com/F5Networks/f5-declarative-onboarding/main/src/schema/latest/do.schema.json",
        "Common": {
            "class": "Tenant",
            "myDns": {
                "class": "DNS",
                "nameServers": [
                    "10.154.1.224",
                    "10.154.1.225",
                    "10.200.1.224",
                    "10.200.1.225"
                ]
            }
        },
        "async": false,
        "class": "Device",
        "label": "Simple DNS config",
        "schemaVersion": "1.45.0"
    },
    "invocation": {
        "module_args": {
            "content": {
                "$schema": "https://raw.githubusercontent.com/F5Networks/f5-declarative-onboarding/main/src/schema/latest/do.schema.json",
                "Common": {
                    "class": "Tenant",
                    "myDns": {
                        "class": "DNS",
                        "nameServers": [
                            "10.154.1.224",
                            "10.154.1.225",
                            "10.200.1.224",
                            "10.200.1.225"
                        ]
                    }
                },
                "async": false,
                "class": "Device",
                "label": "Simple DNS config",
                "schemaVersion": "1.45.0"
            },
            "dry_run": null,
            "task_id": null,
            "timeout": 300
        }
    },
    "message": "DO async task started with id: 5469260a-2e80-42cb-acfb-00032821f274",
    "task_id": "5469260a-2e80-42cb-acfb-00032821f274"
}

TASK [bigip_onboard : GET DO TASK STATUS] *****************************************************************************************************************************************************************************************************
task path: /root/scripts/green/playbooks/roles/bigip_onboard/tasks/main.yaml:7
redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi
Loading collection ansible.netcommon from /usr/lib/python3/dist-packages/ansible_collections/ansible/netcommon
Loading collection ansible.utils from /usr/lib/python3/dist-packages/ansible_collections/ansible/utils
<10.154.80.76> Using network group action f5networks.f5_bigip.bigip for f5networks.f5_bigip.bigip_do_deploy
<10.154.80.76> attempting to start connection
<10.154.80.76> using connection plugin ansible.netcommon.httpapi
Found ansible-connection at path /usr/bin/ansible-connection
<10.154.80.76> found existing local domain socket, using it!
<10.154.80.76> ESTABLISH HTTP(S) CONNECTFOR USER: admin TO https://10.154.80.76:443
<10.154.80.76> updating play_context for connection
<10.154.80.76> Loading collection ansible.builtin from 
<10.154.80.76> local domain socket path is /root/.ansible/pc/bccabcd7e7
<10.154.80.76> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
<10.154.80.76> ANSIBLE_NETWORK_IMPORT_MODULES: found f5networks.f5_bigip.bigip_do_deploy  at /root/.ansible/collections/ansible_collections/f5networks/f5_bigip/plugins/modules/bigip_do_deploy.py
<10.154.80.76> ANSIBLE_NETWORK_IMPORT_MODULES: running f5networks.f5_bigip.bigip_do_deploy
<10.154.80.76> ANSIBLE_NETWORK_IMPORT_MODULES: complete
changed: [lab-ltm-1a] => {
    "changed": true,
    "invocation": {
        "module_args": {
            "content": null,
            "dry_run": null,
            "task_id": "5469260a-2e80-42cb-acfb-00032821f274",
            "timeout": 300
        }
    }
}

TASK [bigip_onboard : PRINT RESPONSE] *********************************************************************************************************************************************************************************************************
task path: /root/scripts/green/playbooks/roles/bigip_onboard/tasks/main.yaml:12
redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi
Loading collection ansible.netcommon from /usr/lib/python3/dist-packages/ansible_collections/ansible/netcommon
Loading collection ansible.utils from /usr/lib/python3/dist-packages/ansible_collections/ansible/utils
ok: [lab-ltm-1a] => {
    "msg": "DO task result: {'changed': True, 'failed': False}"
}

TASK [bigip_onboard : WAIT 4 MINS IF A RESTART WAS NEEDED] ************************************************************************************************************************************************************************************
task path: /root/scripts/green/playbooks/roles/bigip_onboard/tasks/main.yaml:16
fatal: [lab-ltm-1a]: FAILED! => {
    "msg": "The conditional check 'requestResult.message == \"Device is restarting services, unable to check task status.\"' failed. The error was: error while evaluating conditional (requestResult.message == \"Device is restarting services, unable to check task status.\"): 'dict object' has no attribute 'message'\n\nThe error appears to be in '/root/scripts/green/playbooks/roles/bigip_onboard/tasks/main.yaml': line 16, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: WAIT 4 MINS IF A RESTART WAS NEEDED\n  ^ here\n"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BacklogAdded to JIRA boardbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions