Module exec

Entities

entity exec::Run

Parents: std::Resource

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=Dict()

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 std::Host host [1]

The following implementations are defined for this entity:

The following implements statements select implementations for this entity:

Implementations

implementation exec::execHost

Plugins

exec.in_shell(command: string)

Wrap the command such that it is executed in a shell

Resources

class exec.Run

This class represents a service on a system.

Handlers

class exec.PosixRun

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 name posix

  • Handler for entity exec::Run