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
|
# File 'modules/mariadb/manifests/config.pp', line 14
class mariadb::config(
Stdlib::UnixPath $basedir,
$config = 'mariadb/default.my.cnf.erb',
$prompt = '\u@\h(\d)>\_',
$password = 'undefined',
$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',
$innodb_pool_size = undef,
# Will be deprecated in 10.12 https://jira.mariadb.org/browse/MDEV-29694
$innodb_change_buffering = 'none',
$event_scheduler = 1,
$sync_binlog = '1',
$flush_log_at_trx_commit = '1'
) {
$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',
}
# Include these manually. If we're testing on systems with tarballs
# instead of debs, the user won't exist.
group { 'mysql':
ensure => present,
system => true,
}
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':
ensure => absent,
}
nrpe::plugin { 'check_mariadb':
source => 'puppet:///modules/icinga/check_mariadb.pl',
}
if ($ssl == 'on' or $ssl == 'puppet-cert') {
# TODO: consider using profile::pki::get_cert
# This creates also /etc/mysql/ssl
puppet::expose_agent_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'),
}
}
$cleanup_files = ['/etc/mysql/my.cnf', '/usr/local/etc/my.cnf', "${basedir}/my.cnf",
'/etc/mysql/ssl/client-key.pem', '/etc/mysql/ssl/client-cert.pem',
'/etc/mysql/ssl/server-cert.pem']
file {$cleanup_files:
ensure => absent,
}
}
|