puppetlabs/puppetlabs-mysql — pull request #251 by jburnham (2013-08-23 00:03:07+00:00)
Title: Ordering issues with mysql

Related to issue #228, I was having ordering issues with things happening before they should in the puppet module.
For example, if we set a different pidfile than the default, the service is started with the default and then the my.cnf is replaced and the service restart fails because the pidfile changed and the old mysql service is running. For Debian, the problem is the service starts automatically when the package is installed. This now puts the main config file in place before the server package is installed.

See a simplified example of the problem in puppet 3.2 with the current release:

```
[172.17.6.222] out: Notice: /Stage[main]/Mysql::Client::Install/Package[mysql_client]/ensure: current_value absent, should be present (noop)
[172.17.6.222] out: Notice: Class[Mysql::Client::Install]: Would have triggered 'refresh' from 1 events
[172.17.6.222] out: Notice: /Stage[main]/Mysql::Server/Package[mysql-server]/ensure: current_value absent, should be present (noop)
[172.17.6.222] out: Notice: /Stage[main]/Mysql::Server/Service[mysqld]/ensure: current_value stopped, should be running (noop)
[172.17.6.222] out: Notice: Class[Mysql::Server]: Would have triggered 'refresh' from 2 events
[172.17.6.222] out: Notice: /File[/etc/mysql]/ensure: current_value absent, should be directory (noop)
[172.17.6.222] out: Notice: /File[/etc/my.cnf]/ensure: current_value absent, should be file (noop)
[172.17.6.222] out: Notice: /File[/etc/mysql/conf.d]/ensure: current_value absent, should be directory (noop)
[172.17.6.222] out: Error: /Stage[main]/Mysql::Config/Exec[set_mysql_rootpw]: Could not evaluate: Could not find command 'mysqladmin'
[172.17.6.222] out: Notice: /File[/root/.my.cnf]: Dependency Exec[set_mysql_rootpw] has failures: true
[172.17.6.222] out: Warning: /File[/root/.my.cnf]: Skipping because of failed dependencies
[172.17.6.222] out: Notice: /File[/etc/mysql/conf.d/percona.cnf]/ensure: current_value absent, should be file (noop)
[172.17.6.222] out: Notice: /Stage[main]/Mysql::Config/Exec[mysqld-restart]: Dependency Exec[set_mysql_rootpw] has failures: true
[172.17.6.222] out: Warning: /Stage[main]/Mysql::Config/Exec[mysqld-restart]: Skipping because of failed dependencies
[172.17.6.222] out: Notice: /Stage[main]/Mysql::Config/Exec[mysqld-restart]: Would have triggered 'refresh' from 4 events
[172.17.6.222] out: Notice: Mysql::Server::Config[percona]: Would have triggered 'refresh' from 1 events
[172.17.6.222] out: Notice: Class[Simple]: Would have triggered 'refresh' from 1 events
[172.17.6.222] out: Notice: Class[Mysql::Config]: Would have triggered 'refresh' from 4 events
[172.17.6.222] out: Notice: Stage[main]: Would have triggered 'refresh' from 4 events
[172.17.6.222] out: Notice: Finished catalog run in 1.39 seconds
```

Here is the result post changes:

```
[172.17.6.222] out: Notice: /Stage[main]/Mysql::Client::Install/Package[mysql_client]/ensure: current_value absent, should be present (noop)
[172.17.6.222] out: Notice: /File[/etc/mysql]/ensure: current_value absent, should be directory (noop)
[172.17.6.222] out: Notice: /File[/etc/my.cnf]/ensure: current_value absent, should be file (noop)
[172.17.6.222] out: Notice: Class[Mysql::Client::Install]: Would have triggered 'refresh' from 1 events
[172.17.6.222] out: Notice: /File[/etc/mysql/conf.d]/ensure: current_value absent, should be directory (noop)
[172.17.6.222] out: Notice: Class[Mysql::Config::Files]: Would have triggered 'refresh' from 3 events
[172.17.6.222] out: Notice: /Stage[main]/Mysql::Server/Package[mysql-server]/ensure: current_value absent, should be present (noop)
[172.17.6.222] out: Notice: /File[/etc/mysql/conf.d/percona.cnf]/ensure: current_value absent, should be file (noop)
[172.17.6.222] out: Notice: Class[Mysql::Server]: Would have triggered 'refresh' from 1 events
[172.17.6.222] out: Notice: /Stage[main]/Mysql::Server::Service/Service[mysqld]/ensure: current_value stopped, should be running (noop)
[172.17.6.222] out: Notice: Class[Mysql::Server::Service]: Would have triggered 'refresh' from 1 events
[172.17.6.222] out: Error: /Stage[main]/Mysql::Config/Exec[set_mysql_rootpw]: Could not evaluate: Could not find command 'mysqladmin'
[172.17.6.222] out: Notice: /File[/root/.my.cnf]: Dependency Exec[set_mysql_rootpw] has failures: true
[172.17.6.222] out: Warning: /File[/root/.my.cnf]: Skipping because of failed dependencies
[172.17.6.222] out: Notice: /Stage[main]/Mysql::Config/Exec[mysqld-restart]: Would have triggered 'refresh' from 1 events
[172.17.6.222] out: Notice: Mysql::Server::Config[percona]: Would have triggered 'refresh' from 1 events
[172.17.6.222] out: Notice: Class[Mysql::Config]: Would have triggered 'refresh' from 1 events
[172.17.6.222] out: Notice: /Stage[main]/Simple/Database[percona]: Dependency Exec[set_mysql_rootpw] has failures: true
[172.17.6.222] out: Warning: /Stage[main]/Simple/Database[percona]: Skipping because of failed dependencies
[172.17.6.222] out: Notice: Class[Simple]: Would have triggered 'refresh' from 1 events
[172.17.6.222] out: Notice: Stage[main]: Would have triggered 'refresh' from 6 events
[172.17.6.222] out: Notice: Finished catalog run in 1.60 seconds
```

Here's my test code:

```puppet
class simple {
class { 'mysql':
root_password => 'lolpass',
} ->
class { 'mysql::server':
config_hash => {
server_id => '12345',
},
} ->
database { 'percona': }
mysql::server::config { 'percona':
settings => {
'mysqld' => {
max_allowed_packet => '32M',
},
},
}
}
```

This currently seems to works, but I am very open to suggestions and improvement ideas to make it more inline with how you guys want things done.