Make bacula DB a parameter and template variable again
[mirror/dsa-puppet.git] / modules / bacula / manifests / client.pp
index f3443e3..dfeb176 100644 (file)
@@ -3,7 +3,7 @@
 # this mostly configures the file daemon, but also firewall rules and
 # fragments to sent to the other servers.
 class bacula::client(
-  Enum['present', 'absent'] $ensure = defined(Class["bacula::not_a_client"]) ? { true => 'absent', default => 'present' },
+  Enum['present', 'absent'] $ensure = defined(Class['bacula::not_a_client']) ? { true => 'absent', default => 'present' },
 ) inherits bacula {
   $package_ensure = $ensure ? { 'present' => 'installed', 'absent' => 'purged' }
   $service_ensure = $ensure ? { 'present' => 'running', 'absent'  => 'stopped' }
@@ -17,13 +17,26 @@ class bacula::client(
       bacula_client_port => $bacula::bacula_client_port,
     }
 
-    @@concat::fragment { "bacula-dsa-client-list::$fqdn":
+    @@concat::fragment { "bacula-dsa-client-list::${::fqdn}":
       target  => $bacula::bacula_dsa_client_list ,
       content => @("EOF"),
-          ${fqdn}
+          ${::fqdn}
           | EOF
       tag     => $bacula::tag_bacula_dsa_client_list,
     }
+
+    # allow access from director
+    Ferm::Rule::Simple <<| tag == "bacula::director-to-fd::${bacula::bacula_director_address}" |>> {
+      port => $bacula::bacula_client_port,
+    }
+
+    # get access to the storage
+    @@ferm::rule::simple { "bacula::fd-to-storage::${::fqdn}":
+      tag         => "bacula::director-to-storage::${bacula::bacula_storage_address}",
+      description => 'Allow bacula-fd access to the bacula-storage',
+      chain       => 'bacula-sd',
+      saddr       => $bacula::public_addresses,
+    }
   } elsif $ensure == 'absent' {
     file { '/etc/bacula':
       ensure  => absent,
@@ -33,9 +46,12 @@ class bacula::client(
     }
   }
 
-  package { ['bacula-fd', 'bacula-common']:
+  ensure_packages ( [
+    'bacula-fd',
+    'bacula-common',
+  ], {
     ensure => $package_ensure
-  }
+  })
 
   service { 'bacula-fd':
     ensure    => $service_ensure,
@@ -48,7 +64,7 @@ class bacula::client(
     path        => '/usr/bin:/usr/sbin:/bin:/sbin',
     command     => 'sh -c "setsid /usr/local/sbin/bacula-idle-restart fd &"',
     refreshonly => true,
-    subscribe   => [ File[$bacula_ssl_server_cert], File[$bacula_ssl_client_cert] ],
+    subscribe   => [ File[$bacula::bacula_ssl_server_cert], File[$bacula::bacula_ssl_client_cert] ],
     require     => File['/usr/local/sbin/bacula-idle-restart'],
   }
 
@@ -62,14 +78,14 @@ class bacula::client(
     notify  => Exec['bacula-fd restart-when-idle'],
   }
   file { '/usr/local/sbin/bacula-backup-dirs':
-    ensure  => $ensure,
-    mode    => '0775',
-    source  => 'puppet:///modules/bacula/bacula-backup-dirs',
+    ensure => $ensure,
+    mode   => '0775',
+    source => 'puppet:///modules/bacula/bacula-backup-dirs',
   }
   file { '/usr/local/sbin/postbaculajob':
-    ensure  => $ensure,
-    mode    => '0775',
-    source  => 'puppet:///modules/bacula/postbaculajob',
+    ensure => $ensure,
+    mode   => '0775',
+    source => 'puppet:///modules/bacula/postbaculajob',
   }
   file { '/etc/default/bacula-fd':
     ensure  => $ensure,
@@ -80,7 +96,7 @@ class bacula::client(
     require => Package['bacula-fd'],
     notify  => Service['bacula-fd'],
   }
-  if (versioncmp($::lsbmajdistrelease, '9') >= 0 and $systemd) {
+  if (versioncmp($::lsbmajdistrelease, '9') >= 0 and $facts['systemd']) {
     dsa_systemd::override { 'bacula-fd':
       content => @(EOT)
         [Service]
@@ -93,10 +109,4 @@ class bacula::client(
       ensure  => absent,
     }
   }
-
-  ferm::rule { 'dsa-bacula-fd':
-    domain      => '(ip ip6)',
-    description => 'Allow bacula access from storage and director',
-    rule        => "proto tcp mod state state (NEW) dport (${bacula_client_port}) saddr (${bacula_director_ip_addrs}) ACCEPT",
-  }
 }