Puppet Class: mariadb::config

Defined in:
modules/mariadb/manifests/config.pp

Overview

Parameters:

  • config (Any) (defaults to: 'mariadb/default.my.cnf.erb')
  • prompt (Any) (defaults to: '\u@\h(\d)>\_')
  • password (Any) (defaults to: 'undefined')
  • basedir (Any) (defaults to: '/opt/wmf-mariadb10')
  • datadir (Any) (defaults to: '/srv/sqldata')
  • tmpdir (Any) (defaults to: '/srv/tmp')
  • socket (Any) (defaults to: '/run/mysqld/mysqld.sock')
  • port (Any) (defaults to: 3306)
  • sql_mode (Any) (defaults to: '')
  • read_only (Any) (defaults to: 0)
  • p_s (Any) (defaults to: 'off')
  • ssl (Any) (defaults to: 'off')
  • ssl_ca (Any) (defaults to: '')
  • ssl_cert (Any) (defaults to: '')
  • ssl_key (Any) (defaults to: '')
  • ssl_verify_server_cert (Any) (defaults to: true)
  • binlog_format (Any) (defaults to: 'MIXED')
  • semi_sync (Any) (defaults to: 'off')
  • replication_role (Any) (defaults to: 'standalone')
  • max_allowed_packet (Any) (defaults to: '16M')


14
15
16
17
18
19
20
21
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'modules/mariadb/manifests/config.pp', line 14

class mariadb::config(
    $config                 = 'mariadb/default.my.cnf.erb',
    $prompt                 = '\u@\h(\d)>\_',
    $password               = 'undefined',
    $basedir                = '/opt/wmf-mariadb10',
    $datadir                = '/srv/sqldata',
    $tmpdir                 = '/srv/tmp',
    $socket                 = '/run/mysqld/mysqld.sock',
    $port                   = 3306,
    $sql_mode               = '',
    $read_only              = 0,
    $p_s                    = 'off',
    $ssl                    = 'off',
    $ssl_ca                 = '',
    $ssl_cert               = '',
    $ssl_key                = '',
    $ssl_verify_server_cert = true,
    $binlog_format          = 'MIXED',
    $semi_sync              = 'off',
    $replication_role       = 'standalone',
    $max_allowed_packet     = '16M',
    ) {

    $server_id = inline_template(
        "<%= @ipaddress.split('.').inject(0)\
{|total,value| (total << 8 ) + value.to_i} %>"
    )

    $gtid_domain_id = inline_template(
        "<%= @ipaddress.split('.').inject(0)\
{|total,value| (total << 8 ) + value.to_i} %>"
    )

    file { '/etc/my.cnf':
        owner   => 'root',
        group   => 'root',
        mode    => '0644',
        content => template($config),
    }

    file { '/etc/mysql':
        ensure => directory,
        mode   => '0755',
        owner  => 'root',
        group  => 'root',
    }

    file { '/etc/mysql/grcat.config':
        ensure => present,
        mode   => '0644',
        owner  => 'root',
        group  => 'root',
        source => 'puppet:///modules/mariadb/grcat.config',
    }

    # if the socket location is different from the default, it is the role
    # class' reponsability to handle it (otherwise this could have side
    # efects, like changing / or /tmp permissions
    # Starting with buster, creation of /run/mysqld is done by setting:
    #   RuntimeDirectory=mysqld
    #   RuntimeDirectoryPreserve=yes
    # directly on the systemd unit
    if $socket == '/run/mysqld/mysqld.sock' and !os_version('debian >= buster'){
        systemd::tmpfile { 'mysqld':
            content => 'd /run/mysqld 0775 root mysql -',
        }
    }

    file { '/etc/mysql/my.cnf':
        ensure  => absent,
        require => File['/etc/mysql'],
    }

    file { '/usr/local/etc/my.cnf':
        ensure => absent,
    }
    file { "${basedir}/my.cnf":
        ensure => absent,
    }

    # Include these manually. If we're testing on systems with tarballs
    # instead of debs, the user won't exist.
    if os_version('debian >= stretch') {
        group { 'mysql':
            ensure => present,
            system => true,
        }
    }
    else {
        group { 'mysql':
            ensure => present,
        }
    }

    user { 'mysql':
        ensure     => present,
        gid        => 'mysql',
        shell      => '/bin/false',
        home       => '/nonexistent',
        system     => true,
        managehome => false,
    }

    if $datadir {
        file { "${datadir}/my.cnf":
            ensure => absent,
        }
        file { $datadir:
            ensure => directory,
            owner  => 'mysql',
            group  => 'mysql',
            mode   => '0755',
        }

        file { $tmpdir:
            ensure => directory,
            owner  => 'mysql',
            group  => 'mysql',
            mode   => '0755',
        }
    }
    file { '/usr/lib/nagios/plugins/check_mariadb.pl':
        owner  => 'root',
        group  => 'root',
        mode   => '0755',
        source => 'puppet:///modules/icinga/check_mariadb.pl',
    }

    # new script to check the health of a server
    file { '/usr/bin/check_mariadb.py':
        owner  => 'root',
        group  => 'root',
        mode   => '0755',
        source => 'puppet:///modules/mariadb/check_mariadb.py',
    }

    if ($ssl == 'on' or $ssl == 'puppet-cert') {

        # This creates also /etc/mysql/ssl
        ::base::expose_puppet_certs { '/etc/mysql':
            ensure          => present,
            provide_private => true,
            user            => 'mysql',
            group           => 'mysql',
        }

        file { '/etc/mysql/ssl/cacert.pem':
            ensure    => file,
            owner     => 'root',
            group     => 'mysql',
            mode      => '0440',
            show_diff => false,
            backup    => false,
            content   => secret('mysql/cacert.pem'),
        }
        file { '/etc/mysql/ssl/server-key.pem':
            ensure    => file,
            owner     => 'root',
            group     => 'mysql',
            mode      => '0440',
            show_diff => false,
            backup    => false,
            content   => secret('mysql/server-key.pem'),
        }
    }

    file { '/etc/mysql/ssl/server-cert.pem':
        ensure => absent,
    }
    file { '/etc/mysql/ssl/client-key.pem':
        ensure => absent,
    }
    file { '/etc/mysql/ssl/client-cert.pem':
        ensure => absent,
    }

}