deferlib::cmd: returns output of deferred shell command execution
or options[else] if commmand exit code not 0 or output does not match options[match]deferlib::if_cmd: returns value if deferred shell command execution exit code 0 else returns options[else]deferlib::if_file: returns value if file exists else returns defaultdeferlib::unless_cmd: returns value if deferred shell command execution exit code not 0 else returns options[else]deferlib::unless_file: returns value if file does not exist else returns defaultdeferlib::cmdType: Puppet Language
returns output of deferred shell command execution or options[else] if commmand exit code not 0 or output does not match options[match]
service { 'cron':
ensure => deferlib::cmd({
'command' => 'cat /etc/cron_ensure',
'match' => '^(running|stopped)$',
'else' => 'running',
'user' => 'foo',
'group' => 'bar',
'environment' => { 'myvar' => 'myvalue' },
}),
}
deferlib::cmd(Hash $options)The deferlib::cmd function.
Returns: Any output of command or options[else]
service { 'cron':
ensure => deferlib::cmd({
'command' => 'cat /etc/cron_ensure',
'match' => '^(running|stopped)$',
'else' => 'running',
'user' => 'foo',
'group' => 'bar',
'environment' => { 'myvar' => 'myvalue' },
}),
}
optionsData type: Hash
options of shell execution
Options:
String: shell command to executeString: regexp to validate output of commandAny: returned value if command exit code not 0Variant[String,Integer]: The user to run the command asVariant[String,Integer]: The group to run the command asHash: Hash of environment variable names / variable valuesdeferlib::if_cmdType: Puppet Language
returns value if deferred shell command execution exit code 0 else returns options[else]
service { 'cron':
ensure => deferlib::if_cmd('/bin/ismaintenance', 'stopped', {
'else' => 'running',
'user' => 'foo',
'group' => 'bar',
'environment' => { 'myvar' => 'myvalue' },
}),
}
deferlib::if_cmd(String $cmd, Any $value, Optional[Hash] $options = {})The deferlib::if_cmd function.
Returns: Any value or options[else]
service { 'cron':
ensure => deferlib::if_cmd('/bin/ismaintenance', 'stopped', {
'else' => 'running',
'user' => 'foo',
'group' => 'bar',
'environment' => { 'myvar' => 'myvalue' },
}),
}
cmdData type: String
shell code to execute
valueData type: Any
value to return if command exit code is 0
optionsData type: Optional[Hash]
shell execution options
Options:
Any: returned value if command exit code not 0, default []Variant[String,Integer]: The user to run the command asVariant[String,Integer]: The group to run the command asHash: Hash of environment variable names / variable valuesdeferlib::if_fileType: Puppet Language
returns value if file exists else returns default
service { 'cron':
ensure => deferlib::if_file('/etc/maintenance', 'stopped', 'running')
}
deferlib::if_file(String $file, Any $value, Any $default = undef)The deferlib::if_file function.
Returns: Any
service { 'cron':
ensure => deferlib::if_file('/etc/maintenance', 'stopped', 'running')
}
fileData type: String
path to file to check existence
valueData type: Any
value to return if file exists
defaultData type: Any
value to return if file does not exist (default: [])
deferlib::unless_cmdType: Puppet Language
returns value if deferred shell command execution exit code not 0 else returns options[else]
service { 'cron':
ensure => deferlib::unless_cmd('/bin/ismaintenance', 'running'),
}
deferlib::unless_cmd(String $cmd, Any $value, Optional[Hash] $options = {})The deferlib::unless_cmd function.
Returns: Any value or options[else]
service { 'cron':
ensure => deferlib::unless_cmd('/bin/ismaintenance', 'running'),
}
cmdData type: String
shell code to execute
valueData type: Any
value to return if command exit code is not 0
optionsData type: Optional[Hash]
shell execution options
Options:
Any: returned value if command exit code is 0, default []Variant[String,Integer]: The user to run the command asVariant[String,Integer]: The group to run the command asHash: Hash of environment variable names / variable valuesdeferlib::unless_fileType: Puppet Language
returns value if file does not exist else returns default
service { 'cron':
ensure => deferlib::unless_file('/etc/maintenance', 'running')
}
deferlib::unless_file(String $file, Any $value, Any $default = undef)The deferlib::unless_file function.
Returns: Any
service { 'cron':
ensure => deferlib::unless_file('/etc/maintenance', 'running')
}
fileData type: String
path to file to check existence
valueData type: Any
value to return if file does not exist
defaultData type: Any
value to return if file exists (default: [])