2014-07-23 18:40:15 +02:00
---
layout: "docs"
page_title: "Provisioner: remote-exec"
sidebar_current: "docs-provisioners-remote"
2014-10-22 05:21:56 +02:00
description: |-
2015-05-08 13:45:31 +02:00
The `remote-exec` provisioner invokes a script on a remote resource after it is created. This can be used to run a configuration management tool, bootstrap into a cluster, etc. To invoke a local process, see the `local-exec` provisioner instead. The `remote-exec` provisioner supports both `ssh` and `winrm` type connections.
2014-07-23 18:40:15 +02:00
---
# remote-exec Provisioner
The `remote-exec` provisioner invokes a script on a remote resource after it
is created. This can be used to run a configuration management tool, bootstrap
into a cluster, etc. To invoke a local process, see the `local-exec`
[provisioner ](/docs/provisioners/local-exec.html ) instead. The `remote-exec`
2015-04-10 21:28:28 +02:00
provisioner supports both `ssh` and `winrm` type [connections ](/docs/provisioners/connection.html ).
2014-07-23 18:40:15 +02:00
## Example usage
```
# Run puppet and join our Consul cluster
resource "aws_instance" "web" {
...
provisioner "remote-exec" {
inline = [
"puppet apply",
2014-09-30 20:41:58 +02:00
"consul join ${aws_instance.web.private_ip}"
2014-07-23 18:40:15 +02:00
]
}
}
```
## Argument Reference
2014-07-23 21:14:31 +02:00
The following arguments are supported:
2014-07-23 18:40:15 +02:00
2015-01-14 18:28:25 +01:00
* `inline` - This is a list of command strings. They are executed in the order
2014-07-23 18:40:15 +02:00
they are provided. This cannot be provided with `script` or `scripts` .
* `script` - This is a path (relative or absolute) to a local script that will
be copied to the remote resource and then executed. This cannot be provided
with `inline` or `scripts` .
2015-01-14 18:28:25 +01:00
* `scripts` - This is a list of paths (relative or absolute) to local scripts
2014-07-23 18:40:15 +02:00
that will be copied to the remote resource and then executed. They are executed
in the order they are provided. This cannot be provided with `inline` or `script` .
2015-04-22 09:03:38 +02:00
## Script Arguments
You cannot pass any arguments to scripts using the `script` or
2015-04-23 00:00:16 +02:00
`scripts` arguments to this provisioner. If you want to specify arguments,
2015-04-22 09:03:38 +02:00
upload the script with the
[file provisioner ](/docs/provisioners/file.html )
and then use `inline` to call it. Example:
```
resource "aws_instance" "web" {
...
provisioner "file" {
source = "script.sh"
destination = "/tmp/script.sh"
}
provisioner "remote-exec" {
2015-10-09 20:27:38 +02:00
inline = [
"chmod +x /tmp/script.sh",
"/tmp/script.sh args"
]
2015-04-22 09:03:38 +02:00
}
}
```