Last updated on: 2024-04-01 03:24:20.

bigip_command – Run TMSH and BASH commands on F5 devices

New in version 1.0.0.

Synopsis

  • Sends a TMSH or BASH command to an BIG-IP node and returns the results read from the device. This module includes an argument that causes the module to wait for a specific condition before returning or timing out if the condition is not met.
  • This module is not idempotent, and will never be. It is intended as a stop-gap measure to satisfy automation requirements until a real module has been developed.
  • If you are using this module, you should probably also be filing an issue to have a real module created for your needs.

Parameters

Parameter Choices/Defaults Configuration Comments
chdir
string
Change into this directory before running the command.
commands
raw / required
The commands to send to the remote BIG-IP device over the configured provider. The resulting output from the command is returned. If the wait_for argument is provided, the module is not returned until the condition is satisfied or the number of retries as expired.
Only tmsh commands are supported. If you are piping or adding additional logic that is outside of tmsh (such as using grep, awk or other shell related things that are not tmsh, this behavior is not supported.
interval
integer
Default:
1
Configures the interval to wait between retries of the command in seconds. If the command does not pass the specified conditional, the interval indicates how to long to wait before trying the command again.
match
string
    Choices:
  • any
  • all ←
The match argument is used in conjunction with the wait_for argument to specify the match policy. Valid values are all or any. If the value is set to all then all conditionals in the wait_for must be satisfied. If the value is set to any then only one of the values must be satisfied.
retries
integer
Default:
10
Specifies the number of retries a command should by tried before it is considered failed. The command is run on the target device every retry and evaluated against the wait_for conditionals.
use_ssh
boolean
    Choices:
  • no ←
  • yes
Determines if network_cli is to be used as a method of connection.
Default connection is always httpapi.
wait_for
list / elements=string
Specifies what to evaluate from the output of the command and what conditionals to apply. This argument causes the task to wait for a particular conditional to be true before moving forward. If the conditional is not true by the configured number of retries, the task fails. See the examples.

aliases: waitfor
warn
boolean
    Choices:
  • no
  • yes ←
Whether or not the module should raise warnings related to command idempotency.
Note the F5 Ansible developers specifically leave this on to make you aware your usage of this module may be better served by official F5 Ansible modules. This module should always be used as a last resort.

Notes

Note

  • When running this module in an HA environment via SSH connection and using a role other than admin or root, you may see a Change Pending status, even if you did not make any changes. This is being tracked with ID429869.

Examples

- name: Run show version on remote devices
  bigip_command:
    commands: show sys version

- name: Run show version and check to see if output contains BIG-IP
  bigip_command:
    commands: show sys version
    wait_for: result[0] contains BIG-IP

- name: Run multiple commands on remote nodes
  bigip_command:
    commands:
      - show sys version
      - list ltm virtual

- name: Run multiple commands and evaluate the output
  bigip_command:
    commands:
      - show sys version
      - list ltm virtual
    wait_for:
      - result[0] contains BIG-IP
      - result[1] contains my-vs

- name: Tmsh prefixes will automatically be handled
  bigip_command:
    commands:
      - show sys version
      - tmsh list ltm virtual

- name: Delete all LTM nodes in Partition1, assuming no dependencies exist
  bigip_command:
    commands:
      - delete ltm node all
    chdir: Partition1

Return Values

The following are the fields unique to this module:

Key Returned Description
failed_conditions
list
failed
The list of conditionals that have failed.

Sample:
['...', '...']
stdout
list
always
The set of responses from the commands.

Sample:
['...', '...']
stdout_lines
list
always
The value of stdout split into a list.

Sample:
[['...', '...'], ['...'], ['...']]
warn
boolean
changed
Whether or not to raise warnings about modification commands.

Sample:
True


Status

Authors

  • Wojciech Wypior (@wojtek0806)