Skip to content

Commit

Permalink
added code for managed directories
Browse files Browse the repository at this point in the history
  • Loading branch information
Benedikt Braunger committed Dec 3, 2019
1 parent 3304995 commit 72e9d38
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 38 deletions.
56 changes: 26 additions & 30 deletions manifests/director.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
Expand All @@ -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',
Expand Down
17 changes: 9 additions & 8 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'],
}
}
14 changes: 14 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down

0 comments on commit 72e9d38

Please sign in to comment.