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 instead. The remote-exec
provisioner requires a connection
and supports both ssh
and winrm
.
Important: Use provisioners as a last resort. There are better alternatives for most situations. Refer to Declaring Provisioners for more details.
Example usage
Argument Reference
The following arguments are supported:
inline
- This is a list of command strings. They are executed in the order they are provided. This cannot be provided withscript
orscripts
.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 withinline
orscripts
.scripts
- This is a list of paths (relative or absolute) to local scripts that will be copied to the remote resource and then executed. They are executed in the order they are provided. This cannot be provided withinline
orscript
.
Note: Since inline
is implemented by concatenating commands into a script, on_failure
applies only to the final command in the list. In particular, with on_failure = fail
(the default behaviour) earlier commands will be allowed to fail, and later commands will also execute. If this behaviour is not desired, consider using "set -o errexit"
as the first command.
Script Arguments
You cannot pass any arguments to scripts using the script
or
scripts
arguments to this provisioner. If you want to specify arguments,
upload the script with the
file provisioner
and then use inline
to call it. Example: