add a trailing , for form
[mirror/dsa-puppet.git] / modules / bacula / manifests / client.pp
1 # our bacula client configuration
2 #
3 # this mostly configures the file daemon, but also firewall rules and
4 # fragments to sent to the other servers.
5 class bacula::client(
6   Enum['present', 'absent'] $ensure = defined(Class['bacula::not_a_client']) ? { true => 'absent', default => 'present' },
7 ) inherits bacula {
8   $package_ensure = $ensure ? { 'present' => 'installed', 'absent' => 'purged' }
9   $service_ensure = $ensure ? { 'present' => 'running', 'absent'  => 'stopped' }
10   $service_enable = $ensure ? { 'present' => true, 'absent' => false }
11   $reverse_ensure = $ensure ? { 'present' => 'absent', 'absent' => 'present' }
12
13   if $ensure == 'present' {
14     @@bacula::storage_per_node { $::fqdn: }
15
16     @@bacula::node { $::fqdn:
17       bacula_client_port => $bacula::bacula_client_port,
18     }
19
20     @@concat::fragment { "bacula-dsa-client-list::${::fqdn}":
21       target  => $bacula::bacula_dsa_client_list ,
22       content => @("EOF"),
23           ${::fqdn}
24           | EOF
25       tag     => $bacula::tag_bacula_dsa_client_list,
26     }
27
28     # allow access from director
29     Ferm::Rule::Simple <<| tag == 'bacula::director-to-fd' |>> {
30       port => $bacula::bacula_client_port,
31     }
32   } elsif $ensure == 'absent' {
33     file { '/etc/bacula':
34       ensure  => absent,
35       purge   => true,
36       force   => true,
37       recurse => true;
38     }
39   }
40
41   ensure_packages ( [
42     'bacula-fd',
43     'bacula-common',
44   ], {
45     ensure => $package_ensure
46   })
47
48   service { 'bacula-fd':
49     ensure    => $service_ensure,
50     enable    => $service_enable,
51     hasstatus => true,
52     require   => Package['bacula-fd']
53   }
54
55   exec { 'bacula-fd restart-when-idle':
56     path        => '/usr/bin:/usr/sbin:/bin:/sbin',
57     command     => 'sh -c "setsid /usr/local/sbin/bacula-idle-restart fd &"',
58     refreshonly => true,
59     subscribe   => [ File[$bacula::bacula_ssl_server_cert], File[$bacula::bacula_ssl_client_cert] ],
60     require     => File['/usr/local/sbin/bacula-idle-restart'],
61   }
62
63   file { '/etc/bacula/bacula-fd.conf':
64     ensure  => $ensure,
65     content => template('bacula/bacula-fd.conf.erb'),
66     mode    => '0640',
67     owner   => root,
68     group   => bacula,
69     require => Package['bacula-fd'],
70     notify  => Exec['bacula-fd restart-when-idle'],
71   }
72   file { '/usr/local/sbin/bacula-backup-dirs':
73     ensure => $ensure,
74     mode   => '0775',
75     source => 'puppet:///modules/bacula/bacula-backup-dirs',
76   }
77   file { '/usr/local/sbin/postbaculajob':
78     ensure => $ensure,
79     mode   => '0775',
80     source => 'puppet:///modules/bacula/postbaculajob',
81   }
82   file { '/etc/default/bacula-fd':
83     ensure  => $ensure,
84     content => template('bacula/default.bacula-fd.erb'),
85     mode    => '0400',
86     owner   => root,
87     group   => root,
88     require => Package['bacula-fd'],
89     notify  => Service['bacula-fd'],
90   }
91   if (versioncmp($::lsbmajdistrelease, '9') >= 0 and $facts['systemd']) {
92     dsa_systemd::override { 'bacula-fd':
93       content => @(EOT)
94         [Service]
95         ExecStart=
96         ExecStart=/usr/sbin/bacula-fd -c $CONFIG -f -u bacula -k
97         | EOT
98     }
99   } else {
100     dsa_systemd::override { 'bacula-fd':
101       ensure  => absent,
102     }
103   }
104 }