Forum Discussion
Ansible bigip_command module
Is there a way you can ignore an error "wait_for" throws when a conditional statement hasn't been satisfied? In my play I have a task to see which LTM in the pair is active, and it fails when it hits the standby (which makes sense). But it would be nice if you could ignore this error.
Traceback (most recent call last):
File "/tmp/ansible_yIW5Ex/ansible_module_bigip_command.py", line 691, in
main()
File "/tmp/ansible_yIW5Ex/ansible_module_bigip_command.py", line 680, in main
results = mm.exec_module()
File "/tmp/ansible_yIW5Ex/ansible_module_bigip_command.py", line 617, in exec_module
result = manager.exec_module()
File "/tmp/ansible_yIW5Ex/ansible_module_bigip_command.py", line 409, in exec_module
changed = self.execute()
File "/tmp/ansible_yIW5Ex/ansible_module_bigip_command.py", line 498, in execute
raise FailedConditionsError(errmsg, failed_conditions)
ansible.module_utils.network.common.parsing.FailedConditionsError: One or more conditional statements have not been satisfied.
fatal: [x.x.x.x -> localhost]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_yIW5Ex/ansible_module_bigip_command.py\", line 691, in \n main()\n File \"/tmp/ansible_yIW5Ex/ansible_module_bigip_command.py\", line 680, in main\n results = mm.exec_module()\n File \"/tmp/ansible_yIW5Ex/ansible_module_bigip_command.py\", line 617, in exec_module\n result = manager.exec_module()\n File \"/tmp/ansible_yIW5Ex/ansible_module_bigip_command.py\", line 409, in exec_module\n changed = self.execute()\n File \"/tmp/ansible_yIW5Ex/ansible_module_bigip_command.py\", line 498, in execute\n raise FailedConditionsError(errmsg, failed_conditions)\nansible.module_utils.network.common.parsing.FailedConditionsError: One or more conditional statements have not been satisfied.\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
And here is the task I'm working with: (Note: the host inventory file contains 2 IPs only)
- name : Checking which LTM is active....
bigip_command:
server: "{{ inventory_hostname }}"
user: "{{ remote_username }}"
password: "{{ remote_passwd }}"
commands:
- "tmsh show sys failover"
- "tmsh list /sys management-ip | grep -o x.x.x.x"
wait_for:
- result[0] contains active
validate_certs: no
delegate_to: localhost
- Andy_McGrath
Cumulonimbus
I think your issue is the way you are using the
parameter.wait_for
So
within thewait_for
module is not a conditional in the sense of if than then this but used more to confirm something is valid and if not they fails the tasks, so raises an error.bigip_command
From Ansible bigip_command_module regarding
parameter:wait_for
Specifies what to evaluate from the output of the command and what conditionals to apply. This argument will cause the task to wait for a particular conditional to be true before moving forward. If the conditional is not true by the configured retries, the task fails.
You should look at Ansible Playbook Condistionals and look to do something like this:
- name: Checking which LTM is active.... bigip_command: server: "{{ inventory_hostname }}" user: "{{ remote_username }}" password: "{{ remote_passwd }}" validate_certs: no commands: - "tmsh show sys failover" register: result delegate_to: localhost - name: Debug Failover State when: "'active' in result['stdout'][0]" debug: var=result
Here we capture the output of the
command usingtmsh show sys failover
then we run another task, in this caseregister
with thedebug
parameter which checks for the work 'active' in the output we registered.when
Our conditional
is part of future tasks and not the initial task.when
If you have multiple commands then each output will be different item in the 'stdout' list, e.g. first command you can get the string out put from
the second fromresult['stdout'][0]
etc.result['stdout'][1]
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com