Puppet Class: storm::db

Defined in:
manifests/db.pp

Summary

Install MariaDB server and client, create empty databases 'storm_db' and 'storm_be_ISAM', add storm user and all the necessary grants.

Overview

Examples:

Basic usage:

include storm::db

Parameters:

  • fqdn_hostname (String) (defaults to: $::fqdn)

    The Fully Qualified Domain Name of the host. Default value got from Puppet fact fqdn.

  • root_password (String) (defaults to: 'storm')

    MySQL root password. Default: 'storm'.

  • storm_username (String) (defaults to: 'storm')

    The username of the user used by storm services to query the databases. Default 'storm'.

  • storm_password (String) (defaults to: 'storm')

    The password of 'storm' username used by storm services to access the databases. Default: 'storm'.

  • override_options (Data) (defaults to: { 'mysqld' => { 'bind-address' => '0.0.0.0', 'max_connections' => 2048, }, })

    MySQL server override options. Read more about this at forge.puppet.com/puppetlabs/mysql/reference#override_options.



22
23
24
25
26
27
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
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
# File 'manifests/db.pp', line 22

class storm::db (

  String $fqdn_hostname = $::fqdn,
  String $root_password = 'storm',
  String $storm_username = 'storm',
  String $storm_password = 'storm',
  Data $override_options = {
    'mysqld' => {
      'bind-address'    => '0.0.0.0',
      'max_connections' => 2048,
    },
  },

) {

  ## MySQL Client
  include 'mysql::client'

  $service_dir='/etc/systemd/system/mysqld.service.d'

  file { $service_dir:
    ensure => directory,
    owner  => 'root',
    group  => 'root',
    mode   => '0644',
  }

  $service_file='/etc/systemd/system/mysqld.service.d/override.conf'
  $service_template_file='storm/etc/systemd/system/mysqld.service.d/override.conf.erb'

  file { $service_file:
    ensure  => present,
    content => template($service_template_file),
    mode    => '0644',
    owner   => 'root',
    group   => 'root',
    require => [File[$service_dir]],
  }

  ## MySQL Server
  class { 'mysql::server':
    root_password      => $root_password,
    manage_config_file => true,
    restart            => true,
    override_options   => $override_options,
    databases          => {
      'storm_db'      => {
        ensure  => 'present',
        charset => 'utf8',
        collate => 'utf8_general_ci',
      },
      'storm_be_ISAM' => {
        ensure  => 'present',
        charset => 'utf8',
        collate => 'utf8_general_ci',
      },
    },
    require            => [File[$service_file]],
  }

  $short_hostname = regsubst($fqdn_hostname, '^([^.]*).*$', '\1')
  notice("Computed short hostname for ${fqdn_hostname} => ${short_hostname}")

  mysql_user { "${storm_username}@${fqdn_hostname}":
    ensure        => 'present',
    password_hash => mysql::password($storm_password),
    require       => [Class['mysql::server']],
  }
  mysql_grant { "${storm_username}@${fqdn_hostname}/storm_db.*":
    user       => "${storm_username}@${fqdn_hostname}",
    table      => 'storm_db.*',
    privileges => 'ALL',
    require    => [Mysql_user["${storm_username}@${fqdn_hostname}"]],
  }
  mysql_grant { "${storm_username}@${fqdn_hostname}/storm_be_ISAM.*":
    user       => "${storm_username}@${fqdn_hostname}",
    table      => 'storm_be_ISAM.*',
    privileges => 'ALL',
    require    => [Mysql_user["${storm_username}@${fqdn_hostname}"]],
  }

  mysql_user { "${storm_username}@${short_hostname}":
    ensure        => 'present',
    password_hash => mysql::password($storm_password),
    require       => [Class['mysql::server']],
  }
  mysql_grant { "${storm_username}@${short_hostname}/storm_db.*":
    user       => "${storm_username}@${short_hostname}",
    table      => 'storm_db.*',
    privileges => 'ALL',
    require    => [Mysql_user["${storm_username}@${short_hostname}"]],
  }
  mysql_grant { "${storm_username}@${short_hostname}/storm_be_ISAM.*":
    user       => "${storm_username}@${short_hostname}",
    table      => 'storm_be_ISAM.*',
    privileges => 'ALL',
    require    => [Mysql_user["${storm_username}@${short_hostname}"]],
  }

  mysql_user { "${storm_username}@%":
    ensure        => 'present',
    password_hash => mysql::password($storm_password),
    require       => [Class['mysql::server']],
  }
  mysql_grant { "${storm_username}@%/storm_db.*":
    user       => "${storm_username}@%",
    table      => 'storm_db.*',
    privileges => 'ALL',
    require    => [Mysql_user["${storm_username}@%"]],
  }
  mysql_grant { "${storm_username}@%/storm_be_ISAM.*":
    user       => "${storm_username}@%",
    table      => 'storm_be_ISAM.*',
    privileges => 'ALL',
    require    => [Mysql_user["${storm_username}@%"]],
  }

  mysql_user { "${storm_username}@localhost":
    ensure        => 'present',
    password_hash => mysql::password($storm_password),
    require       => [Class['mysql::server']],
  }
  mysql_grant { "${storm_username}@localhost/storm_db.*":
    user       => "${storm_username}@localhost",
    table      => 'storm_db.*',
    privileges => 'ALL',
    require    => [Mysql_user["${storm_username}@localhost"]],
  }
  mysql_grant { "${storm_username}@localhost/storm_be_ISAM.*":
    user       => "${storm_username}@localhost",
    table      => 'storm_be_ISAM.*',
    privileges => 'ALL',
    require    => [Mysql_user["${storm_username}@localhost"]],
  }


}