X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fbacula%2Fmanifests%2Fclient.pp;h=3837699a2e92ac274bb69a1361788ff84e0e024b;hb=69a42e4c538f99ba4882bc5ea89a4b687b8bc51c;hp=dfeb176ed2ed4dbf05350cc7e6c920be2ec4efef;hpb=38bdfc6af73945d7d1405f2d9d32d06c9ccc1adb;p=mirror%2Fdsa-puppet.git diff --git a/modules/bacula/manifests/client.pp b/modules/bacula/manifests/client.pp index dfeb176ed..3837699a2 100644 --- a/modules/bacula/manifests/client.pp +++ b/modules/bacula/manifests/client.pp @@ -2,37 +2,64 @@ # # this mostly configures the file daemon, but also firewall rules and # fragments to sent to the other servers. +# +# @param director_server director server (address) that controls this client's backups +# @param storage_server storage server (address) to use for this client +# @param port_fd port that bacula-fd listens on +# @param client_name bacula client name for this instance +# @param ensure present or absent class bacula::client( + Stdlib::Host $director_server, + Stdlib::Host $storage_server, + Integer $port_fd = 9102, + String $client_name = "${::fqdn}-fd", 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' } $service_enable = $ensure ? { 'present' => true, 'absent' => false } $reverse_ensure = $ensure ? { 'present' => 'absent', 'absent' => 'present' } + $directory_ensure = $ensure ? { 'present' => 'directory', 'absent' => 'absent' } + + $client = $::fqdn + + file { '/etc/bacula/fd-conf.d': + ensure => $directory_ensure, + mode => '0755', + group => bacula, + purge => true, + force => true, + recurse => true, + notify => Exec['bacula-fd restart-when-idle'], + } if $ensure == 'present' { - @@bacula::storage_per_node { $::fqdn: } + Bacula::Client::Director <<| tag == "bacula::to-fd::${director_server}" |>> { + before => Exec['bacula-fd restart-when-idle'], + } - @@bacula::node { $::fqdn: - bacula_client_port => $bacula::bacula_client_port, + @@bacula::storage::client { $client: + tag => "bacula::to-storage::${storage_server}", + client => $client, + director_server => $director_server, } - @@concat::fragment { "bacula-dsa-client-list::${::fqdn}": + @@concat::fragment { "bacula-dsa-client-list::${client}": target => $bacula::bacula_dsa_client_list , content => @("EOF"), - ${::fqdn} + ${client} | 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, + Ferm::Rule::Simple <<| tag == "bacula::director-to-fd::${director_server}" |>> { + port => $port_fd, } # get access to the storage - @@ferm::rule::simple { "bacula::fd-to-storage::${::fqdn}": - tag => "bacula::director-to-storage::${bacula::bacula_storage_address}", + @@ferm::rule::simple { "bacula::fd-to-storage::${client}": + tag => "bacula::fd-to-storage::${storage_server}", description => 'Allow bacula-fd access to the bacula-storage', chain => 'bacula-sd', saddr => $bacula::public_addresses, @@ -57,15 +84,21 @@ class bacula::client( ensure => $service_ensure, enable => $service_enable, hasstatus => true, - require => Package['bacula-fd'] + } + dsa_systemd::override { 'bacula-fd': + ensure => $ensure, + content => @(EOF), + [Unit] + After=network-online.target + | EOF } exec { 'bacula-fd restart-when-idle': path => '/usr/bin:/usr/sbin:/bin:/sbin', - command => 'sh -c "setsid /usr/local/sbin/bacula-idle-restart fd &"', + command => "sh -c 'setsid /usr/local/sbin/bacula-idle-restart ${port_fd} bacula-fd &'", refreshonly => true, subscribe => [ File[$bacula::bacula_ssl_server_cert], File[$bacula::bacula_ssl_client_cert] ], - require => File['/usr/local/sbin/bacula-idle-restart'], + require => [ File['/usr/local/sbin/bacula-idle-restart'], File['/etc/bacula/fd-conf.d/empty.conf'] ], } file { '/etc/bacula/bacula-fd.conf': @@ -74,7 +107,13 @@ class bacula::client( mode => '0640', owner => root, group => bacula, - require => Package['bacula-fd'], + notify => Exec['bacula-fd restart-when-idle'], + } + file { '/etc/bacula/fd-conf.d/empty.conf': + ensure => $ensure, + content => '', + mode => '0440', + group => bacula, notify => Exec['bacula-fd restart-when-idle'], } file { '/usr/local/sbin/bacula-backup-dirs': @@ -93,7 +132,6 @@ class bacula::client( mode => '0400', owner => root, group => root, - require => Package['bacula-fd'], notify => Service['bacula-fd'], } if (versioncmp($::lsbmajdistrelease, '9') >= 0 and $facts['systemd']) {