Puppet Class: bacula::director::mysql

Defined in:
manifests/director/mysql.pp

Overview

Class: bacula::director::mysql

Manage MySQL resources for the Bacula director.

Parameters

All bacula+ classes are called from the main <tt>::bacula class. Parameters are documented there.

Copyright 2012 Russell Harrison

License

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Parameters:

  • db_database (Any) (defaults to: 'bacula')
  • db_host (Any) (defaults to: 'localhost')
  • db_password (Any) (defaults to: '')
  • db_port (Any) (defaults to: '3306')
  • db_user (Any) (defaults to: '')
  • db_user_host (Any) (defaults to: undef)
  • manage_db (Any) (defaults to: false)


28
29
30
31
32
33
34
35
36
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
# File 'manifests/director/mysql.pp', line 28

class bacula::director::mysql (
  $db_database  = 'bacula',
  $db_host      = 'localhost',
  $db_password  = '',
  $db_port      = '3306',
  $db_user      = '',
  $db_user_host = undef,
  $manage_db    = false
){
  include ::bacula::params

  if $manage_db {
    if defined(Class['::mysql::server']) {
      if defined(Class['::mysql::config']) {
        $db_require = [
          Class['::mysql::server'],
          Class['::mysql::config'],
        ]
      } else {
        $db_require = Class['::mysql::server']
      }
    } else {
      $db_require = undef
    }

    $db_user_host_real = $db_user_host ? {
      undef   => $::fqdn,
      default => $db_user_host,
    }

    mysql::db { $db_database:
      user      => $db_user,
      password  => $db_password,
      host      => $db_user_host,
      grant     => ['all'],
      require   => $db_require,
      notify    => Exec['make_db_tables'],
    }
  }

  $make_db_tables_command = $::operatingsystem ? {
    /(Ubuntu|Debian)/ => '/usr/lib/bacula/make_bacula_tables',
    default           => '/usr/libexec/bacula/make_mysql_tables',
  }
  $db_parameters = "--host=${db_host} --user=${db_user} --password=${db_password} --port=${db_port} --database=${db_database}"

  exec { 'make_db_tables':
    command     => "${make_db_tables_command} ${db_parameters}",
    refreshonly => true,
    logoutput   => true,
    require     => Package[$::bacula::params::director_mysql_package],
    notify      => Service['bacula-dir'],
  }
}