whitespace/quoting: modules/bacula/manifests/* (make lint happy)
[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   } elsif $ensure == 'absent' {
28     file { '/etc/bacula':
29       ensure  => absent,
30       purge   => true,
31       force   => true,
32       recurse => true;
33     }
34   }
35
36   ensure_packages ( [
37     'bacula-fd',
38     'bacula-common',
39   ], {
40     ensure => $package_ensure
41   })
42
43   service { 'bacula-fd':
44     ensure    => $service_ensure,
45     enable    => $service_enable,
46     hasstatus => true,
47     require   => Package['bacula-fd']
48   }
49
50   exec { 'bacula-fd restart-when-idle':
51     path        => '/usr/bin:/usr/sbin:/bin:/sbin',
52     command     => 'sh -c "setsid /usr/local/sbin/bacula-idle-restart fd &"',
53     refreshonly => true,
54     subscribe   => [ File[$bacula::bacula_ssl_server_cert], File[$bacula::bacula_ssl_client_cert] ],
55     require     => File['/usr/local/sbin/bacula-idle-restart'],
56   }
57
58   file { '/etc/bacula/bacula-fd.conf':
59     ensure  => $ensure,
60     content => template('bacula/bacula-fd.conf.erb'),
61     mode    => '0640',
62     owner   => root,
63     group   => bacula,
64     require => Package['bacula-fd'],
65     notify  => Exec['bacula-fd restart-when-idle'],
66   }
67   file { '/usr/local/sbin/bacula-backup-dirs':
68     ensure => $ensure,
69     mode   => '0775',
70     source => 'puppet:///modules/bacula/bacula-backup-dirs',
71   }
72   file { '/usr/local/sbin/postbaculajob':
73     ensure => $ensure,
74     mode   => '0775',
75     source => 'puppet:///modules/bacula/postbaculajob',
76   }
77   file { '/etc/default/bacula-fd':
78     ensure  => $ensure,
79     content => template('bacula/default.bacula-fd.erb'),
80     mode    => '0400',
81     owner   => root,
82     group   => root,
83     require => Package['bacula-fd'],
84     notify  => Service['bacula-fd'],
85   }
86   if (versioncmp($::lsbmajdistrelease, '9') >= 0 and $facts['systemd']) {
87     dsa_systemd::override { 'bacula-fd':
88       content => @(EOT)
89         [Service]
90         ExecStart=
91         ExecStart=/usr/sbin/bacula-fd -c $CONFIG -f -u bacula -k
92         | EOT
93     }
94   } else {
95     dsa_systemd::override { 'bacula-fd':
96       ensure  => absent,
97     }
98   }
99
100   ferm::rule { 'dsa-bacula-fd':
101     domain      => '(ip ip6)',
102     description => 'Allow bacula access from storage and director',
103     rule        => "proto tcp mod state state (NEW) dport (${bacula::bacula_client_port}) saddr (${bacula::bacula_director_ip_addrs}) ACCEPT",
104   }
105 }