Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bash example for bigip_command #1017

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.