Skip to content

Commit d13c06b

Browse files
author
Joshua Spence
committed
Ensure that Puppet runs are idempotent
Currently this module requires two executions of `puppet apply` to properly configure MySQL. On an Ubuntu 16.04 instance, I am seeing the second Puppet run produce the following changes: ``` Notice: Compiled catalog for ubuntu-16.04-x64 in environment production in 1.93 seconds Info: Applying configuration version '1504824440' Info: Computing checksum on file /etc/mysql/conf.d/mysql.cnf Info: /Stage[main]/Mysql::Server::Config/File[/etc/mysql/conf.d/mysql.cnf]: Filebucketed /etc/mysql/conf.d/mysql.cnf to puppet with sum c992f7b57d778f607e8d83792936e92b Notice: /Stage[main]/Mysql::Server::Config/File[/etc/mysql/conf.d/mysql.cnf]/ensure: removed Notice: /Stage[main]/Mysql::Server::Config/File[mysql-config-file]/ensure: defined content as '{md5}59e52aeed142f9004c9e74ff5e4f1d84' Info: Class[Mysql::Server::Config]: Scheduling refresh of Class[Mysql::Server::Service] Info: Class[Mysql::Server::Service]: Scheduling refresh of Service[mysqld] Info: Class[Mysql::Server::Service]: Scheduling refresh of Exec[wait_for_mysql_socket_to_open] Notice: /Stage[main]/Mysql::Server::Service/Service[mysqld]: Triggered 'refresh' from 1 events Notice: /Stage[main]/Mysql::Server::Service/Exec[wait_for_mysql_socket_to_open]: Triggered 'refresh' from 1 events Notice: Applied catalog in 2.49 seconds ``` The problem is that `Class['mysql::server::config']` is included before `Class['mysql::server::install']`. This means that `/etc/mysql/my.cnf` is configured first, but then subsequently overridden by the default configuration that is installed by the `mysql-server` package. This isn't picked up by the existing acceptance tests because they explicitly set `config_file` to `'#{@tmpdir}/my.cnf`.
1 parent d066549 commit d13c06b

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

manifests/server.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@
7676
}
7777

7878
Anchor['mysql::server::start']
79-
-> Class['mysql::server::config']
8079
-> Class['mysql::server::install']
80+
-> Class['mysql::server::config']
8181
-> Class['mysql::server::binarylog']
8282
-> Class['mysql::server::installdb']
8383
-> Class['mysql::server::service']

spec/acceptance/mysql_server_spec.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@
22

33
describe 'mysql class' do
44
describe 'advanced config' do
5-
before(:all) do
6-
@tmpdir = default.tmpdir('mysql')
7-
end
85
let(:pp) do
96
<<-EOS
107
class { 'mysql::server':
11-
config_file => '#{@tmpdir}/my.cnf',
12-
includedir => '#{@tmpdir}/include',
138
manage_config_file => 'true',
149
override_options => { 'mysqld' => { 'key_buffer_size' => '32M' }},
1510
package_ensure => 'present',
@@ -58,8 +53,6 @@ class { 'mysql::server':
5853
let(:pp) do
5954
<<-EOS
6055
class { 'mysql::server':
61-
config_file => '#{@tmpdir}/my.cnf',
62-
includedir => '#{@tmpdir}/include',
6356
manage_config_file => 'false',
6457
override_options => { 'mysqld' => { 'key_buffer_size' => '32M' }},
6558
package_ensure => 'present',

0 commit comments

Comments
 (0)