Skip to content

Commit

Permalink
Add Bash example for bigip_command
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-harvey-z3q committed Oct 6, 2024
1 parent d1eabd0 commit b227cd5
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions docs/resources/bigip_command.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,53 @@ description: |-
`bigip_command` Run TMSH commands on F5 devices

This resource is helpful to send TMSH command to an BIG-IP node and returns the results read from the device
## Example Usage

## Example Usage

```hcl
resource "bigip_command" "test-command" {
commands = ["show sys version"]
}
#create ltm node
# Create ltm node
resource "bigip_command" "test-command" {
commands = ["create ltm node 10.10.10.70"]
}
# Destroy ltm node
resource "bigip_command" "test-command" {
when = "destroy"
commands = ["delete ltm node 10.10.10.70"]
}
```

```
## Argument Reference
It is also possible to send Bash commands however care is needed with quoting:

* `commands` - (Required) The commands to send to the remote BIG-IP device over the configured provider. The resulting output from the command is returned and added to `command_result`
* `when` - (Optional,possible values:`apply` or `destroy`) default value will be `apply`,can be set to `destroy` for terraform destroy call.
```hcl
resource "bigip_command" "byol-license" {
commands = [
"bash -c \"cp /config/bigip.license /config/bigip.license.bak.$(date +%s)\"",
"bash -c \"echo ${var.license_file_contents_base64} | base64 --decode > /config/bigip.license\"",
"bash -c \"reloadlic\""
]
}
```

Note that use of single quotes is not supported, thus this will not work:

```hcl
resource "bigip_command" "hello-world" {
commands = ["bash -c 'echo hello world'"]
}
```

## Argument Reference

* `commands` - (Required) The commands to send to the remote BIG-IP device over the configured provider. The resulting output from the command is returned and added to `command_result`
* `when` - (Optional, possible values: `apply` or `destroy`) default value will be `apply`,can be set to `destroy` for terraform destroy call.

## Attributes Reference

In addition to all arguments above, the following attributes are exported:

* `command_result` - The resulting output from the `commands` executed
* `command_result` - The resulting output from the `commands` executed.

0 comments on commit b227cd5

Please sign in to comment.