Skip to content

Commit fccde9e

Browse files
author
carabasdaniel
authored
Merge pull request #1278 from unki/allow-adapt-config-file-permissions
Allow adapting MySQL configuration file's permissions mode
2 parents 775bed0 + 67c7375 commit fccde9e

File tree

4 files changed

+57
-6
lines changed

4 files changed

+57
-6
lines changed

manifests/params.pp

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
class mysql::params {
77

88
$manage_config_file = true
9+
$config_file_mode = '0644'
910
$purge_conf_dir = false
1011
$restart = false
1112
$root_password = 'UNSET'

manifests/server.pp

+7-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#
1212
# @param config_file
1313
# The location, as a path, of the MySQL configuration file.
14+
# @param config_file_mode
15+
# The MySQL configuration file's permissions mode.
1416
# @param includedir
1517
# The location, as a path, of !includedir for custom configuration overrides.
1618
# @param install_options
@@ -68,6 +70,7 @@
6870
#
6971
class mysql::server (
7072
$config_file = $mysql::params::config_file,
73+
$config_file_mode = $mysql::params::config_file_mode,
7174
$includedir = $mysql::params::includedir,
7275
$install_options = undef,
7376
$install_secret_file = $mysql::params::install_secret_file,
@@ -94,11 +97,10 @@
9497
$users = {},
9598
$grants = {},
9699
$databases = {},
97-
98-
# Deprecated parameters
99-
$enabled = undef,
100-
$manage_service = undef,
101-
$old_root_password = undef
100+
# Deprecated parameters
101+
$enabled = undef,
102+
$manage_service = undef,
103+
$old_root_password = undef
102104
) inherits mysql::params {
103105

104106
# Deprecated parameters.

manifests/server/config.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
file { 'mysql-config-file':
3838
path => $mysql::server::config_file,
3939
content => template('mysql/my.cnf.erb'),
40-
mode => '0644',
40+
mode => $mysql::server::config_file_mode,
4141
selinux_ignore_defaults => true,
4242
}
4343

spec/classes/mycnf_template_spec.rb

+48
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,54 @@
8080

8181
it { is_expected.to contain_file('mysql-config-file').without_content(%r{!includedir}) }
8282
end
83+
84+
context 'with file mode 0644' do
85+
let(:params) { { 'config_file_mode' => '0644' } }
86+
87+
it do
88+
is_expected.to contain_file('mysql-config-file').with(mode: '0644')
89+
end
90+
end
91+
92+
context 'with file mode 0664' do
93+
let(:params) { { 'config_file_mode' => '0664' } }
94+
95+
it do
96+
is_expected.to contain_file('mysql-config-file').with(mode: '0664')
97+
end
98+
end
99+
100+
context 'with file mode 0660' do
101+
let(:params) { { 'config_file_mode' => '0660' } }
102+
103+
it do
104+
is_expected.to contain_file('mysql-config-file').with(mode: '0660')
105+
end
106+
end
107+
108+
context 'with file mode 0641' do
109+
let(:params) { { 'config_file_mode' => '0641' } }
110+
111+
it do
112+
is_expected.to contain_file('mysql-config-file').with(mode: '0641')
113+
end
114+
end
115+
116+
context 'with file mode 0610' do
117+
let(:params) { { 'config_file_mode' => '0610' } }
118+
119+
it do
120+
is_expected.to contain_file('mysql-config-file').with(mode: '0610')
121+
end
122+
end
123+
124+
context 'with file 0600' do
125+
let(:params) { { 'config_file_mode' => '0600' } }
126+
127+
it do
128+
is_expected.to contain_file('mysql-config-file').with(mode: '0600')
129+
end
130+
end
83131
end
84132
end
85133
end

0 commit comments

Comments
 (0)