From bf525d9c735434a9bf73a105b682ed0ade37babf Mon Sep 17 00:00:00 2001 From: Benedikt Braunger Date: Tue, 3 Dec 2019 07:16:14 +0100 Subject: [PATCH] added code for managed directories additionally removed pp3.x from travis CI --- .travis.yml | 22 ----------------- manifests/director.pp | 56 ++++++++++++++++++++----------------------- manifests/init.pp | 17 ++++++------- manifests/params.pp | 14 +++++++++++ 4 files changed, 49 insertions(+), 60 deletions(-) diff --git a/.travis.yml b/.travis.yml index 69e79ab..2e1e221 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,10 +11,6 @@ rvm: cache: bundler script: bundle exec rake test env: - - PUPPET_GEM_VERSION="~> 3.4.0" - - PUPPET_GEM_VERSION="~> 3.6.0" STRICT_VARIABLES=yes - - PUPPET_GEM_VERSION="~> 3.8.0" STRICT_VARIABLES=yes - - PUPPET_GEM_VERSION="~> 3.8.0" STRICT_VARIABLES=yes FUTURE_PARSER=yes - PUPPET_GEM_VERSION="~> 4.0.0" STRICT_VARIABLES=yes - PUPPET_GEM_VERSION="~> 4.4.0" STRICT_VARIABLES=yes - PUPPET_GEM_VERSION="~> 4.6.0" STRICT_VARIABLES=yes @@ -31,28 +27,10 @@ matrix: env: PUPPET_GEM_VERSION="~> 4.6.0" STRICT_VARIABLES=yes - rvm: 1.9.3 env: PUPPET_GEM_VERSION="~> 5.0.1" STRICT_VARIABLES=yes - - rvm: 2.1 - env: PUPPET_GEM_VERSION="~> 3.4.0" # eclude all puppet 3.x 5.x for ruby 2.3 - - rvm: 2.3 - env: PUPPET_GEM_VERSION="~> 3.4.0" - - rvm: 2.3 - env: PUPPET_GEM_VERSION="~> 3.6.0" STRICT_VARIABLES=yes - - rvm: 2.3 - env: PUPPET_GEM_VERSION="~> 3.8.0" STRICT_VARIABLES=yes - - rvm: 2.3 - env: PUPPET_GEM_VERSION="~> 3.8.0" STRICT_VARIABLES=yes FUTURE_PARSER=yes - rvm: 2.3 env: PUPPET_GEM_VERSION="~> 5.0.1" STRICT_VARIABLES=yes # eclude all puppet 3.x 4.x for ruby 2.4 - - rvm: 2.4 - env: PUPPET_GEM_VERSION="~> 3.4.0" - - rvm: 2.4 - env: PUPPET_GEM_VERSION="~> 3.6.0" STRICT_VARIABLES=yes - - rvm: 2.4 - env: PUPPET_GEM_VERSION="~> 3.8.0" STRICT_VARIABLES=yes - - rvm: 2.4 - env: PUPPET_GEM_VERSION="~> 3.8.0" STRICT_VARIABLES=yes FUTURE_PARSER=yes - rvm: 2.4 env: PUPPET_GEM_VERSION="~> 4.0.0" STRICT_VARIABLES=yes - rvm: 2.4 diff --git a/manifests/director.pp b/manifests/director.pp index 3d74b4e..3699814 100644 --- a/manifests/director.pp +++ b/manifests/director.pp @@ -5,15 +5,16 @@ # This class will be automatically included when a resource is defined. # It is not intended to be used directly by external resources like node definitions or other modules. class bareos::director( - $manage_service = $::bareos::manage_service, - $manage_package = $::bareos::manage_package, - $manage_database = $::bareos::manage_database, - $package_name = $::bareos::director_package_name, - $package_ensure = $::bareos::package_ensure, - $service_name = $::bareos::director_service_name, - $service_ensure = $::bareos::service_ensure, - $service_enable = $::bareos::service_enable, - $config_dir = "${::bareos::config_dir}/bareos-dir.d" + $manage_service = $::bareos::manage_service, + $manage_package = $::bareos::manage_package, + $manage_database = $::bareos::manage_database, + $package_name = $::bareos::director_package_name, + $package_ensure = $::bareos::package_ensure, + $service_name = $::bareos::director_service_name, + $service_ensure = $::bareos::service_ensure, + $service_enable = $::bareos::service_enable, + $config_dir = "${::bareos::config_dir}/bareos-dir.d", + Array[String] $managed_dirs = $::bareos::director_managed_dirs, ) inherits ::bareos { include ::bareos::director::director @@ -32,28 +33,8 @@ } } - # directories - $config_director_dirs = [ - $config_dir, - "${config_dir}/catalog", - "${config_dir}/client", - "${config_dir}/console", - "${config_dir}/counter", - "${config_dir}/director", - "${config_dir}/fileset", - "${config_dir}/job", - "${config_dir}/jobdefs", - "${config_dir}/messages", - "${config_dir}/pool", - "${config_dir}/profile", - "${config_dir}/schedule", - "${config_dir}/storage", - ] - - file { $config_director_dirs: + file { $config_dir: ensure => directory, - purge => true, - recurse => true, force => true, mode => $::bareos::file_dir_mode, owner => $::bareos::file_owner, @@ -63,6 +44,21 @@ tag => ['bareos', 'bareos_director'], } + $managed_dirs.each |$managed_dir| { + file { "${config_dir}/${managed_dir}": + ensure => directory, + purge => true, + recurse => true, + force => true, + require => Package[$package_name], + mode => $::bareos::file_dir_mode, + owner => $::bareos::file_owner, + group => $::bareos::file_group, + notify => Service[$service_name], + tag => ['bareos', 'bareos_director'], + } + } + if $manage_database { File <| tag == 'bareos_director' |> -> exec { 'bareos director init catalog': command => '/usr/lib/bareos/scripts/create_bareos_database && /usr/lib/bareos/scripts/make_bareos_tables && /usr/lib/bareos/scripts/grant_bareos_privileges', diff --git a/manifests/init.pp b/manifests/init.pp index 456db82..85dc56d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -27,6 +27,7 @@ $monitor_package_name = $::bareos::params::monitor_package_name, $director_package_name = $::bareos::params::director_package_name, $director_service_name = $::bareos::params::director_service_name, + $director_managed_dirs = $::bareos::params::director_managed_dirs, $client_package_name = $::bareos::params::client_package_name, $client_service_name = $::bareos::params::client_service_name, $storage_package_name = $::bareos::params::storage_package_name, @@ -66,13 +67,13 @@ } file { $config_dir: - ensure => directory, - purge => true, - recurse => true, - force => true, - mode => $::bareos::file_dir_mode, - owner => $::bareos::file_owner, - group => $::bareos::file_group, - tag => ['bareos', 'bareos_core'], + ensure => directory, + purge => true, + recurse => true, + recurselimit => 1, + mode => $::bareos::file_dir_mode, + owner => $::bareos::file_owner, + group => $::bareos::file_group, + tag => ['bareos', 'bareos_core'], } } diff --git a/manifests/params.pp b/manifests/params.pp index 802b89a..6d6c246 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -42,6 +42,20 @@ 'bareos-database-tools', ] $director_service_name = 'bareos-dir' + $director_managed_dirs = [ 'catalog', + 'client', + 'console', + 'counter', + 'director', + 'fileset', + 'job', + 'jobdefs', + 'messages', + 'pool', + 'profile', + 'schedule', + 'storage', + ] # filedaemon/client $client_package_name = ['bareos-filedaemon', 'bareos-filedaemon-python-plugin']