Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- define bareos::director::catalog (
- $ensure = present,
- $db_address = undef,
- $db_driver = undef,
- $db_name = undef,
- $db_password = undef,
- $db_port = undef,
- $db_socket = undef,
- $db_user = undef,
- $description = undef,
- $disable_batch_insert = undef,
- $exit_on_fatal = undef,
- $idle_timeout = undef,
- $inc_connections = undef,
- $max_connections = undef,
- $min_connections = undef,
- $multiple_connections = undef,
- $reconnect = undef,
- $validate_timeout = undef,
- ) {
- include ::bareos::director
- $_resource = 'Catalog'
- $_resource_dir = 'catalog'
- unless $ensure in [ 'present', 'absent' ] {
- fail('Invalid value for ensure')
- }
- if $ensure == 'present' {
- $_env = [
- "db_name=${db_name}",
- "PGDATABASE=${db_name}",
- "db_user=${db_user}",
- "PGUSER=${db_user}",
- "db_password=${db_password}",
- "PGPASSWORD=${db_password}",
- "db_address=${db_address}",
- "PGHOST=${db_address}",
- "PGPORT=${db_port}",
- ]
- case $db_driver {
- 'sqlite3': {
- # code
- $_commands = '/usr/lib/bareos/scripts/create_bareos_database && /usr/lib/bareos/scripts/make_bareos_tables'
- }
- 'mysql': {
- # code
- $_mysql_port = $db_port ? {
- undef => '-P 3306',
- default => "-P ${db_port}",
- }
- $_mysql_args = "${_mysql_port} -h \$db_address -u \"\$db_user\" -p\"\$db_password\" -D \"\$db_name\""
- $_command = "/usr/lib/bareos/scripts/create_bareos_database ${_mysql_args} && /usr/lib/bareos/scripts/make_bareos_tables ${_mysql_args}"
- }
- 'postgresql': {
- $_command = '/usr/lib/bareos/scripts/create_bareos_database && /usr/lib/bareos/scripts/make_bareos_tables'
- }
- default: {
- fail("DB driver '${db_driver}' is not support")
- }
- }
- File <| |> -> exec { "bareos director init catalog ${name}":
- command => $_command,
- environment => $_env,
- subscribe => File["${::bareos::director::config_dir}/${_resource_dir}/${name}.conf"],
- notify => Service[$::bareos::director::service_name],
- refreshonly => true,
- }
- $_settings = bareos_settings(
- [$name, 'Name', 'name', true],
- [$description, 'Description', 'string', false],
- [$db_address, 'Db Address', 'string', false],
- [$db_driver, 'Db Driver', 'string', true],
- [$db_name, 'Db Name', 'string', true],
- [$db_password, 'Db Password', 'autopassword', false],
- [$db_port, 'Db Port', 'pint32', false],
- [$db_socket, 'Db Socket', 'string', false],
- [$db_user, 'Db User', 'string', false],
- [$disable_batch_insert, 'Disable Batch Insert', 'boolean', false],
- [$exit_on_fatal, 'Exit On Fatal', 'boolean', false],
- [$idle_timeout, 'Idle Timeout', 'pint32', false],
- [$inc_connections, 'Inc Connections', 'pint32', false],
- [$max_connections, 'Max Connections', 'pint32', false],
- [$min_connections, 'Min Connections', 'pint32', false],
- [$multiple_connections, 'Multiple Connections', 'bit', false],
- [$reconnect, 'Reconnect', 'boolean', false],
- [$validate_timeout, 'Validate Timeout', 'pint32', false]
- )
- }
- file { "${::bareos::director::config_dir}/${_resource_dir}/${name}.conf":
- ensure => $ensure,
- mode => $::bareos::file_mode,
- owner => $::bareos::file_owner,
- group => $::bareos::file_group,
- content => template('bareos/resource.erb'),
- notify => [
- Service[$::bareos::director::service_name],
- ]
- }
- }
Add Comment
Please, Sign In to add comment