Puppet Function: deferlib::if_cmd

Defined in:
functions/if_cmd.pp
Function type:
Puppet Language

Summary

returns value if deferred shell command execution exit code 0 else returns options[else]

Overview

deferlib::if_cmd(String $cmd, Any $value, Optional[Hash] $options = {})Any

Examples:

if command /bin/ismaintenance ensure cron service stopped else ensure running

service { 'cron':
  ensure => deferlib::if_cmd('/bin/ismaintenance', 'stopped', {
    'else'        => 'running',
    'user'        => 'foo',
    'group'       => 'bar',
    'environment' => { 'myvar' => 'myvalue' },
  }),
}

Parameters:

  • cmd (String)

    shell code to execute

  • value (Any)

    value to return if command exit code is 0

  • options (Optional[Hash]) (defaults to: {})

    shell execution options

Options Hash (options):

  • 'else' (Any)

    returned value if command exit code not 0, default []

  • 'user' (Variant[String,Integer])

    The user to run the command as

  • 'group' (Variant[String,Integer])

    The group to run the command as

  • 'environment' (Hash)

    Hash of environment variable names / variable values

Returns:

Author:

  • Franck Jouvanceau



31
32
33
34
35
36
37
# File 'functions/if_cmd.pp', line 31

function deferlib::if_cmd (
  String         $cmd,
  Any            $value,
  Optional[Hash] $options = {},
) {
  Deferred('deferlib::if_cmd_', [$cmd, $value, $options])
}