Defined Type: tp::info

Defined in:
manifests/info.pp

Overview

tp::info

Creates info scripts to check if the application managed by Tiny Puppet is runnign correctly.

Parameters:

  • ensure (Variant[Boolean,String]) (defaults to: present)
  • path (Variant[Undef,String]) (defaults to: undef)
  • source (Variant[Undef,String,Array]) (defaults to: undef)
  • template (Variant[Undef,String,Array]) (defaults to: undef)
  • epp (Variant[Undef,String]) (defaults to: undef)
  • content (Variant[Undef,String]) (defaults to: undef)
  • options_hash (Hash) (defaults to: {})
  • settings_hash (Hash) (defaults to: {})
  • data_module (String[1]) (defaults to: 'tinydata')
  • base_dir (String[1]) (defaults to: '/etc/tp/info')
  • app_dir (String[1]) (defaults to: '/etc/tp/app')
  • info_command (Stdlib::Absolutepath) (defaults to: $tp::info_script_path)
  • verbose (Boolean) (defaults to: false)
  • cli_enable (Boolean) (defaults to: pick($tp::cli_enable, true))


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'manifests/info.pp', line 6

define tp::info (

  Variant[Boolean,String] $ensure              = present,
  Variant[Undef,String]   $path                = undef,
  Variant[Undef,String,Array] $source          = undef,
  Variant[Undef,String,Array] $template        = undef,
  Variant[Undef,String]   $epp                 = undef,
  Variant[Undef,String]   $content             = undef,

  Hash                    $options_hash        = {},
  Hash                    $settings_hash       = {},

  String[1]               $data_module         = 'tinydata',
  String[1]               $base_dir            = '/etc/tp/info',
  String[1]               $app_dir             = '/etc/tp/app',

  Stdlib::Absolutepath    $info_command        = $tp::info_script_path,
  Boolean                 $verbose             = false,
  Boolean                 $cli_enable          = pick($tp::cli_enable, true),

) {
  # Settings evaluation
  $tp_settings=tp_lookup($title,'settings',$data_module,'deep_merge')
  $settings = $tp_settings + $settings_hash

  include tp

  # Default options and computed variables
  $options_defaults = {
    info_command           => $info_command,
  }

  $options = merge($options_defaults, $options_hash)

  $array_package_name=any2array($settings['package_name'])
  $array_service_name=any2array($settings['service_name'])
  $array_tcp_port=any2array($settings['tcp_port'])

  $epp_params = {
    options => $options,
    options_hash => $options_hash,
  }
  # Find out the file's content value
  if $content {
    $file_content = $content
  } elsif $template {
    $template_ext = $template[-4,4]
    $file_content = $template_ext ? {
      '.epp'  => epp($template,$epp_params),
      '.erb'  => template($template),
      default => template($template),
    }
  } elsif $epp {
    $file_content = epp($epp,$epp_params)
  } else {
    $file_content = undef
  }

  $sane_title = regsubst($title, '/', '_', 'G')

  $real_path = $path ? {
    undef   => "${base_dir}/${sane_title}",
    default => $path,
  }
  if $file_content
  or $source {
    file { $real_path:
      ensure  => $ensure,
      mode    => '0755',
      owner   => 'root',
      content => $file_content,
      source  => $source,
      tag     => 'tp_info',
    }
  }
}