Puppet Class: bareos::client

Defined in:
manifests/client.pp

Overview



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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'manifests/client.pp', line 9

class bareos::client {

  include bareos

  ### Client specific checks
  $real_client_password = $bareos::client_password ? {
    ''      => $bareos::real_default_password,
    default => $bareos::client_password,
  }

  $manage_client_file_content = $bareos::client_template ? {
    ''      => undef,
    default => template($bareos::client_template),
  }

  $manage_client_file_source = $bareos::client_source ? {
    ''        => undef,
    default   => $bareos::client_source,
  }

  $manage_client_service_autorestart = $bareos::bool_service_autorestart ? {
    true    => Service[$bareos::client_service],
    default => undef,
  }

  ### Managed resources
  require bareos::repository

  package { $bareos::client_package:
    ensure  => $bareos::manage_package,
    noop    => $bareos::noops,
    require => Class['bareos::repository'],
  }

  file { 'bareos-fd.conf':
    ensure  => $bareos::manage_file,
    path    => $bareos::client_config_file,
    mode    => $bareos::config_file_mode,
    owner   => $bareos::config_file_owner,
    group   => $bareos::config_file_group,
    require => Package[$bareos::client_package],
    notify  => $manage_client_service_autorestart,
    source  => $manage_client_file_source,
    content => $manage_client_file_content,
    replace => $bareos::manage_file_replace,
    audit   => $bareos::manage_audit,
    noop    => $bareos::noops,
  }

  service { $bareos::client_service:
      ensure     => $bareos::manage_service_ensure,
      name       => $bareos::client_service,
      enable     => $bareos::manage_service_enable,
      hasstatus  => $bareos::service_status,
      pattern    => $bareos::client_process,
      require    => Package[$bareos::client_package],
      noop       => $bareos::noops,
    }


  ### Provide puppi data, if enabled ( puppi => true )
  if $bareos::bool_puppi == true {
    $classvars=get_class_args()
    puppi::ze { 'bareos-client':
      ensure    => $bareos::manage_file,
      variables => $classvars,
      helper    => $bareos::puppi_helper,
      noop      => $bareos::noops,
    }
  }

  ### Service monitoring, if enabled ( monitor => true )
  if $bareos::bool_monitor == true {
    if $bareos::client_port != '' {
      monitor::port { "monitor_bareos_client_${bareos::protocol}_${bareos::client_port}":
        protocol => $bareos::protocol,
        port     => $bareos::client_port,
        target   => $bareos::monitor_target,
        tool     => $bareos::monitor_tool,
        enable   => $bareos::manage_monitor,
        noop     => $bareos::noops,
      }
    }
    if $bareos::client_service != '' {
      monitor::process { 'bareos_client_process':
        process  => $bareos::client_process,
        service  => $bareos::client_service,
        pidfile  => $bareos::client_pid_file,
        user     => $bareos::process_user,
        argument => $bareos::process_args,
        tool     => $bareos::monitor_tool,
        enable   => $bareos::manage_monitor,
        noop     => $bareos::noops,
      }
    }
  }


  ### Firewall management, if enabled ( firewall => true )
  if $bareos::bool_firewall == true and $bareos::client_port != '' {
    firewall { "firewall_bareos_client_${bareos::protocol}_${bareos::client_port}":
      source      => $bareos::firewall_src,
      destination => $bareos::firewall_dst,
      protocol    => $bareos::protocol,
      port        => $bareos::client_port,
      action      => 'allow',
      direction   => 'input',
      tool        => $bareos::firewall_tool,
      enable      => $bareos::manage_firewall,
      noop        => $bareos::noops,
    }
  }


  ### Debugging, if enabled ( debug => true )
  if $bareos::bool_debug == true {
    file { 'debug_client_bareos':
      ensure  => $bareos::manage_file,
      path    => "${settings::vardir}/debug-client-bareos",
      mode    => '0640',
      owner   => 'root',
      group   => 'root',
      content => inline_template('<%= scope.to_hash.reject { |k,v| k.to_s =~ /(uptime.*|path|timestamp|free|.*password.*|.*psk.*|.*key)/ }.to_yaml %>'),
      noop    => $bareos::noops,
    }
  }


}