salt.states.cmd

Execution of arbitrary commands.

The cmd state module manages the enforcement of executed commands, this state can tell a command to run under certain circumstances.

Available Functions

The cmd state only has a single function, the run function

run

Execute a command given certain conditions

A simple example:

date > /tmp/salt-run:
cmd:
    - run

Only run if another execution returns successfully, in this case truncate syslog if there is no disk space:

> /var/log/messages:
  cmd.run:
    - unless: echo 'foo' > /tmp/.test

Members

mod_watch

salt.states.cmd.mod_watch(name, onlyif=None, unless=None, cwd='/root', user=None, group=None, shell=None, env=())

Run a command if certain circumstances are met

name
The command to execute, remember that the command will execute with the path and permissions of the salt-minion.
onlyif
A command to run as a check, run the named command only if the command passed to the onlyif option returns true
unless
A command to run as a check, only run the named command if the command passed to the unless option returns false
cwd
The current working directory to execute the command in, defaults to /root
user
The user name to run the command as
group
The group context to run the command as
shell
The shell to use for execution, defaults to the shell grain

run

salt.states.cmd.run(name, onlyif=None, unless=None, cwd='/root', user=None, group=None, shell=None, env=())

Run a command if certain circumstances are met

name
The command to execute, remember that the command will execute with the path and permissions of the salt-minion.
onlyif
A command to run as a check, run the named command only if the command passed to the onlyif option returns true
unless
A command to run as a check, only run the named command if the command passed to the unless option returns false
cwd
The current working directory to execute the command in, defaults to /root
user
The user name to run the command as
group
The group context to run the command as
shell
The shell to use for execution, defaults to the shell grain

wait

salt.states.cmd.wait(name, onlyif=None, unless=None, cwd='/root', user=None, group=None, shell=None)

Run the given command only if the watch statement calls it

name
The command to execute, remember that the command will execute with the path and permissions of the salt-minion.
onlyif
A command to run as a check, run the named command only if the command passed to the onlyif option returns true
unless
A command to run as a check, only run the named command if the command passed to the unless option returns false
cwd
The current working directory to execute the command in, defaults to /root
user
The user name to run the command as
group
The group context to run the command as
shell
The shell to use for execution, defaults to /bin/sh

Parent topic

Table Of Contents

Previous topic

salt.states.alias

Next topic

salt.states.cron