Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bigip_command "wait_for" documentation #2380

Open
stanislaspiron opened this issue Nov 2, 2023 · 2 comments
Open

bigip_command "wait_for" documentation #2380

stanislaspiron opened this issue Nov 2, 2023 · 2 comments
Labels
backlog Item logged internally

Comments

@stanislaspiron
Copy link

COMPONENT NAME

Environment

ANSIBLE VERSION
Not ansible version related
BIGIP VERSION
Not BIGIP version related
CONFIGURATION
OS / ENVIRONMENT
SUMMARY

bigip_command wait_for parameter is not well documented

STEPS TO REPRODUCE

The following task is working well, but I wanted to add conditions to like split text and only compare second word in output first line.

  - name: Wait for active or standby status (means online)
    bigip_command:
      commands: 
      - show sys failover
      provider: "{{ bigip_provider }}"
      warn: no
      match: any
      wait_for:
      - result[0] contains 'Failover active'
      - result[0] contains 'Failover standby'
      retries: 60
      interval: 30
    register: sys_failover_state

After multiple tests, I discovered that wait_for 'result' is an internal bigip_command variable and is not the same as defined in register attribute.

According to the example above and the clouddocs documentation, I was expecting that wait_for conditions use sys_failover_state variable and not result

I tried to change contains operator with equals, in... but not other operator I tried works. What operators are supported? can we split output to compare second word?

EXPECTED RESULTS

I was expecting to use filter like:

- sys_failover_state.stdout_lines.0.0.split()[1] in ['active','standby']
@stanislaspiron stanislaspiron added bug Issues that are related to bugs in the Ansible modules untriaged issue that needs an initial response from the developers labels Nov 2, 2023
@pgouband
Copy link
Contributor

pgouband commented Nov 3, 2023

Hi @stanislaspiron,

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

@pgouband pgouband added backlog Item logged internally and removed bug Issues that are related to bugs in the Ansible modules untriaged issue that needs an initial response from the developers labels Nov 3, 2023
@wojtek0806
Copy link
Contributor

The wait_for parameter uses ansible.netcommon Conditional function which has implemented a number of operators that are allowed to be used. You can see them here in the source:

https://github.com/ansible-collections/ansible.netcommon/blob/main/plugins/module_utils/network/common/parsing.py#L171

When it comes to using result keyword, this looks like implementation issue, i have raised a question/bug report with ansible:
ansible-collections/ansible.netcommon#601

For now you need to use result in wait_for condition, you do not need to register the output to result, for me the below works:

    - name: Wait for active or standby status (means online)
      bigip_command:
        commands: 
          - show sys failover
        wait_for:
          - result[0] contains 'Failover active'
        provider: "{{ f5_provider }}"
        warn: no
        match: any
        retries: 60
        interval: 30
      register: sys_failover_state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Item logged internally
Projects
None yet
Development

No branches or pull requests

3 participants