Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow changing the mysql-config-file group-ownership #1284

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
$datadir = '/var/lib/mysql'
$root_group = 'root'
$mysql_group = 'mysql'
$mycnf_owner = undef
$mycnf_group = undef
$socket = '/var/lib/mysql/mysql.sock'
$ssl_ca = '/etc/mysql/cacert.pem'
$ssl_cert = '/etc/mysql/server-cert.pem'
Expand Down Expand Up @@ -152,6 +154,8 @@
}
$root_group = 'root'
$mysql_group = 'mysql'
$mycnf_owner = undef
$mycnf_group = undef
$server_service_name = 'mysql'

if $::operatingsystem =~ /(SLES|SLED)/ {
Expand Down Expand Up @@ -209,6 +213,8 @@
$pidfile = '/var/run/mysqld/mysqld.pid'
$root_group = 'root'
$mysql_group = 'adm'
$mycnf_owner = undef
$mycnf_group = undef
$socket = '/var/run/mysqld/mysqld.sock'
$ssl_ca = '/etc/mysql/cacert.pem'
$ssl_cert = '/etc/mysql/server-cert.pem'
Expand Down Expand Up @@ -253,6 +259,8 @@
$pidfile = '/var/run/mysqld/mysqld.pid'
$root_group = 'root'
$mysql_group = 'mysql'
$mycnf_owner = undef
$mycnf_group = undef
$server_service_name = 'mysqld'
$socket = '/var/lib/mysql/mysql.sock'
$ssl_ca = '/etc/mysql/cacert.pem'
Expand All @@ -278,6 +286,8 @@
$pidfile = '/run/mysqld/mysqld.pid'
$root_group = 'root'
$mysql_group = 'mysql'
$mycnf_owner = undef
$mycnf_group = undef
$server_service_name = 'mysql'
$socket = '/run/mysqld/mysqld.sock'
$ssl_ca = '/etc/mysql/cacert.pem'
Expand All @@ -303,6 +313,8 @@
$pidfile = '/var/run/mysql.pid'
$root_group = 'wheel'
$mysql_group = 'mysql'
$mycnf_owner = undef
$mycnf_group = undef
$server_service_name = 'mysql-server'
$socket = '/var/db/mysql/mysql.sock'
$ssl_ca = undef
Expand Down Expand Up @@ -331,6 +343,8 @@
$pidfile = '/var/mysql/mysql.pid'
$root_group = 'wheel'
$mysql_group = '_mysql'
$mycnf_owner = undef
$mycnf_group = undef
$server_service_name = 'mysqld'
$socket = '/var/run/mysql/mysql.sock'
$ssl_ca = undef
Expand Down Expand Up @@ -386,6 +400,8 @@
$pidfile = '/run/mysqld/mysqld.pid'
$root_group = 'root'
$mysql_group = 'mysql'
$mycnf_owner = undef
$mycnf_group = undef
$server_service_name = 'mariadb'
$socket = '/run/mysqld/mysqld.sock'
$ssl_ca = '/etc/mysql/cacert.pem'
Expand All @@ -411,6 +427,8 @@
$pidfile = '/var/run/mysqld/mysqld.pid'
$root_group = 'root'
$mysql_group = 'mysql'
$mycnf_owner = undef
$mycnf_group = undef
$server_service_name = 'mysqld'
$socket = '/var/lib/mysql/mysql.sock'
$ssl_ca = '/etc/mysql/cacert.pem'
Expand Down
6 changes: 6 additions & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
# The name of the group used for root. Can be a group name or a group ID. See more about the [group](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-group).
# @param mysql_group
# The name of the group of the MySQL daemon user. Can be a group name or a group ID. See more about the [group](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-group).
# @param mycnf_owner
# Name or user-id who owns the mysql-config-file.
# @param mycnf_group
# Name or group-id which owns the mysql-config-file.
# @param root_password
# The MySQL root password. Puppet attempts to set the root password and update `/root/.my.cnf` with it. This is required if `create_root_user` or `create_root_my_cnf` are true. If `root_password` is 'UNSET', then `create_root_user` and `create_root_my_cnf` are assumed to be false --- that is, the MySQL root user and `/root/.my.cnf` are not created. Password changes are supported; however, the old password must be set in `/root/.my.cnf`. Effectively, Puppet uses the old password, configured in `/root/my.cnf`, to set the new password in MySQL, and then updates `/root/.my.cnf` with the new password.
# @param service_enabled
Expand Down Expand Up @@ -85,6 +89,8 @@
$restart = $mysql::params::restart,
$root_group = $mysql::params::root_group,
$mysql_group = $mysql::params::mysql_group,
$mycnf_owner = $mysql::params::mycnf_owner,
$mycnf_group = $mysql::params::mycnf_group,
$root_password = $mysql::params::root_password,
$service_enabled = $mysql::params::server_service_enabled,
$service_manage = $mysql::params::server_service_manage,
Expand Down
2 changes: 2 additions & 0 deletions manifests/server/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
path => $mysql::server::config_file,
content => template('mysql/my.cnf.erb'),
mode => $mysql::server::config_file_mode,
owner => $mysql::server::mycnf_owner,
group => $mysql::server::mycnf_group,
selinux_ignore_defaults => true,
}

Expand Down
31 changes: 31 additions & 0 deletions spec/classes/mycnf_template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,37 @@
is_expected.to contain_file('mysql-config-file').with(mode: '0600')
end
end

context 'user owner 12345' do
let(:params) { { 'mycnf_owner' => '12345' } }

it do
is_expected.to contain_file('mysql-config-file').with(
owner: '12345',
)
end
end

context 'group owner 12345' do
let(:params) { { 'mycnf_group' => '12345' } }

it do
is_expected.to contain_file('mysql-config-file').with(
group: '12345',
)
end
end

context 'user and group owner 12345' do
let(:params) { { 'mycnf_owner' => '12345', 'mycnf_group' => '12345' } }

it do
is_expected.to contain_file('mysql-config-file').with(
owner: '12345',
group: '12345',
)
end
end
end
end
end