|  | 
|  | 1 | +# @summary Program definition | 
|  | 2 | +# | 
|  | 3 | +# A command to be executed by haproxy master process | 
|  | 4 | +# | 
|  | 5 | +# @see https://www.haproxy.com/documentation/haproxy-configuration-tutorials/programs/ | 
|  | 6 | +# @example | 
|  | 7 | +#   haproxy::program { 'hello': | 
|  | 8 | +#     command => 'hello world', | 
|  | 9 | +#   } | 
|  | 10 | +define haproxy::program ( | 
|  | 11 | +  String                          $command, | 
|  | 12 | +  Optional[String]                $user        = undef, | 
|  | 13 | +  Optional[String]                $group       = undef, | 
|  | 14 | +  Optional[String]                $options     = undef, | 
|  | 15 | +  String                          $instance    = 'haproxy', | 
|  | 16 | +  Optional[Stdlib::Absolutepath]  $config_file = undef, | 
|  | 17 | +) { | 
|  | 18 | +  # We derive these settings so that the caller only has to specify $instance. | 
|  | 19 | +  include haproxy::params | 
|  | 20 | + | 
|  | 21 | +  if $instance == 'haproxy' { | 
|  | 22 | +    $instance_name = 'haproxy' | 
|  | 23 | +    $_config_file = pick($config_file, $haproxy::config_file) | 
|  | 24 | +  } else { | 
|  | 25 | +    $instance_name = "haproxy-${instance}" | 
|  | 26 | +    $_config_file = pick($config_file, inline_template($haproxy::params::config_file_tmpl)) | 
|  | 27 | +  } | 
|  | 28 | + | 
|  | 29 | +  concat::fragment { "${instance_name}-${name}_program": | 
|  | 30 | +    order   => "40-program-${name}", | 
|  | 31 | +    target  => $_config_file, | 
|  | 32 | +    content => epp('haproxy/haproxy_program.epp', { | 
|  | 33 | +      'name'    => $name, | 
|  | 34 | +      'command' => $command, | 
|  | 35 | +      'user'    => $user, | 
|  | 36 | +      'group'   => $group, | 
|  | 37 | +      'options' => $options, | 
|  | 38 | +    }), | 
|  | 39 | +  } | 
|  | 40 | +} | 
0 commit comments