Puppet Class: bacula::director

Inherits:
bacula
Defined in:
manifests/director.pp

Summary

Configure the Bacula Director

Overview

This class installs and configures the Bacula Director

TODO:

director_address is only used by bconsole, and is confusing as director is likely the same

Examples:

class { 'bacula::director':
  storage => 'mystorage.example.com'
}

Parameters:

  • messages (Hash[String, Bacula::Message])

    Logging configuration; loaded from hiera

  • packages (Array[String])

    A list of packages to install; loaded from hiera

  • services (String)

    A list of services to operate; loaded from hiera

  • manage_db (Bacula::Yesno) (defaults to: true)

    Whether the module should manage the director database

  • conf_dir (String) (defaults to: $bacula::conf_dir)

    Path to bacula configuration directory

  • db_name (String) (defaults to: 'bacula')

    The database name

  • db_pw (String) (defaults to: 'notverysecret')

    The database user’s password

  • db_user (String) (defaults to: 'bacula')

    The database user

  • db_address (Optional[String]) (defaults to: undef)

    The database address

  • db_port (Optional[String]) (defaults to: undef)

    The database port

  • director_address (String) (defaults to: $bacula::director_address)

    The address of the director used by bconsole

  • director (String) (defaults to: $trusted['certname'])

    The name of the director

  • group (String) (defaults to: $bacula::bacula_group)

    The posix group for bacula

  • homedir (String) (defaults to: $bacula::homedir)

    The bacula director working directory

  • job_tag (Optional[String]) (defaults to: $bacula::job_tag)

    A string to use when realizing jobs and filesets

  • listen_address (Array[String[1]]) (defaults to: [])

    The listening IP addresses for the director The notes for ‘bacula::client::listen_address` apply.

  • max_concurrent_jobs (Integer) (defaults to: 20)

    Bacula Director option for ‘Maximum Concurrent Jobs’

  • manage_defaults (Boolean) (defaults to: true)

    Setup default jobdef, schedule, pool and restoration jobs

  • password (String) (defaults to: 'secret')

    password to connect to the director

  • port (Integer) (defaults to: 9101)

    The listening port for the Director

  • rundir (String) (defaults to: $bacula::rundir)

    Bacula Director option for ‘Pid Directory’

  • storage_name (String) (defaults to: $bacula::storage_name)

    The Name of the Storage daemon

  • make_bacula_tables (String)

    Path to the script that loads the database schema



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'manifests/director.pp', line 37

class bacula::director (
  Hash[String, Bacula::Message] $messages,
  Array[String]                 $packages,
  String                        $services,
  String                        $make_bacula_tables,
  Bacula::Yesno                 $manage_db           = true,
  String                        $conf_dir            = $bacula::conf_dir,
  String                        $db_name             = 'bacula',
  String                        $db_pw               = 'notverysecret',
  String                        $db_user             = 'bacula',
  Optional[String]              $db_address          = undef,
  Optional[String]              $db_port             = undef,
  String                        $director_address    = $bacula::director_address,
  String                        $director            = $trusted['certname'], # director here is not bacula::director
  String                        $group               = $bacula::bacula_group,
  String                        $homedir             = $bacula::homedir,
  Optional[String]              $job_tag             = $bacula::job_tag,
  Array[String[1]]              $listen_address      = [],
  Integer                       $max_concurrent_jobs = 20,
  Boolean                       $manage_defaults     = true,
  String                        $password            = 'secret',
  Integer                       $port                = 9101,
  String                        $rundir              = $bacula::rundir,
  String                        $storage_name        = $bacula::storage_name,
) inherits bacula {
  if $manage_defaults {
    include bacula::director::defaults

    bacula::job { 'RestoreFiles':
      jobtype             => 'Restore',
      jobdef              => false,
      messages            => 'Standard',
      fileset             => 'Common',
      max_concurrent_jobs => $max_concurrent_jobs,
    }
  }

  case $bacula::db_type {
    /^(pgsql|postgresql)$/: { include bacula::director::postgresql }
    'none':                 {}
    default:                { fail('No db_type set') }
  }

  # Allow for package names to include EPP syntax for db_type
  $package_names = $packages.map |$p| {
    $package_name = inline_epp($p,
      {
        'db_type' => $bacula::db_type
      }
    )
  }
  ensure_packages($package_names)

  service { $services:
    ensure  => running,
    enable  => true,
    require => Package[$package_names],
  }

  file { "${conf_dir}/conf.d":
    ensure => directory,
  }

  file { "${conf_dir}/bconsole.conf":
    owner     => 'root',
    group     => $group,
    mode      => '0640',
    show_diff => false,
    content   => epp('bacula/bconsole.conf.epp');
  }

  Concat {
    owner  => 'root',
    group  => $group,
    mode   => '0640',
    notify => Service[$services],
  }

  concat::fragment { 'bacula-director-header':
    order   => '00',
    target  => "${conf_dir}/bacula-dir.conf",
    content => epp('bacula/bacula-dir-header.epp'),
  }

  concat::fragment { 'bacula-director-tail':
    order   => '99999',
    target  => "${conf_dir}/bacula-dir.conf",
    content => epp('bacula/bacula-dir-tail.epp'),
  }

  create_resources(bacula::messages, $messages)
  # Realize any clients or storage that have the same director specified
  Bacula::Director::Storage <<| tag == "bacula-${director}" |>> { conf_dir => $conf_dir }
  Bacula::Director::Client <<| tag == "bacula-${director}" |>> { conf_dir => $conf_dir }

  if $job_tag {
    Bacula::Director::Fileset <<| tag == $job_tag |>> { conf_dir => $conf_dir }
    Bacula::Director::Job <<| tag == $job_tag |>> { conf_dir => $conf_dir }
    # TODO tag pool resources on export when job_tag is defined
    Bacula::Director::Pool <<|tag == $job_tag |>> { conf_dir => $conf_dir }
  } else {
    Bacula::Director::Fileset <<||>> { conf_dir => $conf_dir }
    Bacula::Director::Job <<||>> { conf_dir => $conf_dir }
    Bacula::Director::Pool <<||>> { conf_dir => $conf_dir }
  }

  Concat::Fragment <<| tag == "bacula-${director}" |>>

  concat { "${conf_dir}/bacula-dir.conf":
    show_diff => false,
  }

  $sub_confs = [
    "${conf_dir}/conf.d/schedule.conf",
    "${conf_dir}/conf.d/pools.conf",
    "${conf_dir}/conf.d/job.conf",
    "${conf_dir}/conf.d/jobdefs.conf",
    "${conf_dir}/conf.d/fileset.conf",
  ]

  $sub_confs_with_secrets = [
    "${conf_dir}/conf.d/client.conf",
    "${conf_dir}/conf.d/storage.conf",
  ]

  concat { $sub_confs: }

  concat { $sub_confs_with_secrets:
    show_diff => false,
  }

  bacula::director::fileset { 'Common':
    files => ['/etc'],
  }
}