f5networks / f5networks.f5_bigip / 1.13.0 / module / bigip_command Run TMSH and BASH commands on F5 devices | "added in version" 1.0.0 of f5networks.f5_bigip" Authors: Wojciech Wypior (@wojtek0806)f5networks.f5_bigip.bigip_command (1.13.0) — module
Install with ansible-galaxy collection install f5networks.f5_bigip:==1.13.0
collections: - name: f5networks.f5_bigip version: 1.13.0
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 B(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 B(real) module created for your needs.
- hosts: all collections: - f5networks.f5_bigip connection: httpapi vars: ansible_host: "lb.mydomain.com" ansible_user: "admin" ansible_httpapi_password: "secret" ansible_network_os: f5networks.f5_bigip.bigip ansible_httpapi_use_ssl: yes tasks: - 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
warn: default: true description: - Whether the module should raise warnings related to command idempotency or not. - Note that the F5 Ansible developers specifically leave this on to make you aware that your usage of this module may be better served by official F5 Ansible modules. This module should always be used as a last resort. type: bool chdir: description: - Change into this directory before running the command. type: str match: choices: - any - all default: all description: - The I(match) argument is used in conjunction with the I(wait_for) argument to specify the match policy. Valid values are C(all) or C(any). If the value is set to C(all) then all conditionals in the I(wait_for) must be satisfied. If the value is set to C(any) then only one of the values must be satisfied. type: str retries: default: 10 description: - 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 I(wait_for) conditionals. type: int use_ssh: default: false description: - Determines if C(network_cli) is to be used as a method of connection. - Default connection is always C(httpapi). type: bool commands: description: - The commands to send to the remote BIG-IP device over the configured provider. The resulting output from the command is returned. If the I(wait_for) argument is provided, the module is not returned until the condition is satisfied or the number of retries as expired. - Only C(tmsh) commands are supported. If you are piping or adding additional logic that is outside of C(tmsh) (such as using grep, awk or other shell related things that are not C(tmsh), this behavior is not supported. required: true type: raw interval: default: 1 description: - 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. type: int wait_for: aliases: - waitfor description: - 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. elements: str type: list
failed_conditions: description: The list of conditionals that have failed. returned: failed sample: - '...' - '...' type: list stdout: description: The set of responses from the commands. returned: always sample: - '...' - '...' type: list stdout_lines: description: The value of stdout split into a list. returned: always sample: - - '...' - '...' - - '...' - - '...' type: list warn: description: Whether or not to raise warnings about modification commands. returned: changed sample: true type: bool