Module exec — Inmanta 2017.2.1 documentation

# Module exec

> - License: Apache 2.0
> - Version: 0.5.0
> - Author: Inmanta <code@inmanta.com>
> - This module requires compiler version 2017.1 or higher
> - Upstream project: https://github.com/inmanta/exec.git

## Entities

entity `exec::Run`

  Parents: `std::Entity`

  Run a command with almost exact semantics as the exec type of puppet

  attribute string `reload`=''

    The command to execute when this run needs to reload. If empty the command itself will be executed again.

  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 `onlyif`=''

    Only execute the command if this command is true (returns 0)

  attribute bool `reload_only`=False

    Only use this command to reload

  attribute string `path`=''

    The path to search the command in

  attribute number `returns`=List()

    A list of valid return codes, by default this is only 0

  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. An array of variables can be passed as strings in the form var=value

  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 `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 string `command`

    The actual command to execute. The command should be almost always be idempotent.

  relation std::Host `host` [1]

    other end: `std::Host.exec_run_commands [0:*]`

  The following implements statements select implementations for this entity:

  > - `std::none`

## Resources

class `exec.` `Run`

  > This class represents a service on a system.

  - Resource for entity `exec::Run`
  - Id attribute `command`
  - Agent name `host.name`
  - Handlers `exec.PosixRun`

## 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`