Module exec¶
License: Apache 2.0
Version: 2.1.0
Entities¶
- entity exec::Run¶
Parents:
std::PurgeableResource
Run a command with almost exact semantics as the exec type of puppet
The command is not executed in a shell! This means:
shell operators like ;, |, > don’t work
variable substitution doesn’t work: echo $PATH will literally print $PATH
variable substitution doesn’t work in environment variables either: setting PATH to $PATH will result in command not found
If want to run a command in a shell, use the plugin ‘in_shell’:
exec::Run(host=host, command=exec::in_shell(command))
If you want variable substitution on environment variables, use the export command in the shell:
exec::Run(host=host, command=exec::in_shell("export PATH=$PATH:/usr/local/bin; {{command}}"))
- attribute string command¶
The actual command to execute. The command should be almost always be idempotent.
- attribute string creates=''¶
A file that the command creates, when the file already exists the command will not be executed. This helps to make simple commands idempotent
- attribute string cwd=''¶
The directory from which to run the command. WARNING: Command is spawned in a subshell. This implies that the real path of cwd is used and not a possible symlinked path.
- attribute dict environment={}¶
Environment variables to set before the command is executed. A dictionary of variables can be passed in the form {“var”: “value”}.
- attribute string onlyif=''¶
Only execute the command if this command is true (returns 0)
- attribute string path=''¶
The path to search the command in
- attribute string reload=''¶
The command to execute when this run needs to reload. If empty the command itself will be executed again.
- attribute bool reload_only=false¶
Only use this command to reload
- attribute number[] returns=List()¶
A list of valid return codes, by default this is only 0
- attribute number timeout=300¶
The maximum time the command should take. If the command takes longer, the deploy agent will try to end it.
- attribute string unless=''¶
If this attribute is set, the command will only execute if the command in this attribute is not successful (returns not 0). If the command passed to this attribute does not exist, this is interpreted as a non-successful execution.
- attribute bool skip_on_fail=false¶
Report this resource as skipped instead of failed.
- relation mitogen::Context via [0:1]¶
Mitogen context dedicated to this resource. If not specified, defaults to the one of the host.
- relation std::Host host [1]¶
Relation to the host on which the Run commmand is executed.
The following implementations are defined for this entity:
The following implements statements select implementations for this entity:
exec::execHost
constrainttrue
Implementations¶
- implementation exec::execHost¶
Plugins¶
- exec.in_shell(command: 'string') 'string' ¶
Wrap the command such that it is executed in a shell
- exec.shlex_join(cmd: 'string[]') 'string' ¶
Join the provided command into a safe string that can be parsed by a shell, where each item in the command is threated a dedicated argument.
- Parameters:
cmd – The command to join into a string
Resources¶
- class exec.Run¶
This class represents a shell command
Resource for entity
exec::Run
Id attribute
command
Agent name
host.name
Handlers
exec.PosixRunHandler
Handlers¶
- class exec.PosixRunHandler¶
A handler to execute commands on posix compatible systems. This is a very atypical resource as this executes a command. The check_resource method will determine based on the “reload_only”, “creates”, “unless” and “onlyif” attributes if the command will be executed.
Handler for entity
exec::Run