Mysql – Restarting thesql utilizing the puppetlabs/thesql module

MySQLpuppetvagrant

I have two folders — one is 'public_modules' and the other is 'private_modules'. When I start a new Vagrant machine, the 'public_modules' folder is populated with modules as described in my Puppetfile (for brevity sake, these are all modules on the puppetforge). 'private_modules' holds whatever modifications and settings I need to change to the public modules. By using librarian-puppet, I don't need to check in these public modules nor rely on git submodules. Consider the following manifest file:

class drupaldb {
class { '::mysql::server':
    root_password => 'platform',
    override_options => { 'mysqld' => { 'max_connections' => '1024', 'bind-address' => '0.0.0.0' } }
}

mysql::db { 'drupaldb':
    user     => 'root',
    password => 'platform',
    host     => '%',
    grant    => ['SELECT', 'UPDATE', 'DELETE'],
}

service { 'mysql':
    ensure => running,
    enable => true,
    subscribe => File['/etc/mysql/my.cnf']
}
}

Provisioning Vagrant will fail because the mysql service has already been defined in the public module here:

class mysql::server::service {

if $mysql::server::real_service_enabled {
    $service_ensure = 'running'
} else {
    $service_ensure = 'stopped'
}

if $mysql::server::real_service_manage {
    file { $mysql::params::log_error:
      owner => 'mysql',
      group => 'mysql',
}
service { 'mysqld':
  ensure   => $service_ensure,
  name     => $mysql::server::service_name,
  enable   => $mysql::server::real_service_enabled,
  provider => $mysql::server::service_provider,
}
}

}

So, what I've been unable to solve is how to instruct mysql to restart at the end of my module? I've resorted to restarting mysql via an inline shell command at the end of my Vagrantfile, but that is surely a hack.

Here is the puppetlabs module

Best Answer

I had the same problem, and I solved it by added a 'restart' param to my ::mysql::server initialization.

class { '::mysql::server':
  override_options => $override_options,
  restart => true,
}

This tells the mysql module to restart mysql whenever something changes.