I think your issue is the way you are using the
wait_for
parameter.
So
wait_for
within the
bigip_command
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.
From Ansible bigip_command_module regarding
wait_for
parameter:
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
tmsh show sys failover
command using
register
then we run another task, in this case
debug
with the
when
parameter which checks for the work 'active' in the output we registered.
Our conditional
when
is part of future tasks and not the initial task.
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
result['stdout'][0]
the second from
result['stdout'][1]
etc.