Puppet 2.7, using the mysql module, version 2.1.0.
I do not wish to have Puppet manage the root password because passwords should not be included in my manifests (which are captured in Git).
I have a setup where /root/.my.cnf symlinks to a central .my.cnf file on a NFS mount. The goal is to have Puppet do all the database setup, create the symlink, then I log in and update root password.
To make this work, here is a snippet of the steps I'm executing:
class { '::mysql::server':
databases => $databases,
override_options => $override_options,
grants => $grants,
package_name => 'MariaDB-server',
remove_default_accounts => true,
restart => true,
service_enabled => true,
service_name => 'mysql',
users => $users,
}
file { '/root/.my.cnf':
ensure => 'link',
target => '/nfs/projects/a/admin/.my.cnf',
}
Class['::mysql::server'] ->
File['/root/.my.cnf']
Problem #1) This returns a dependency cycle error:
err: Could not apply complete catalog: Found 1 dependency cycle:
(Anchor[mysql::server::end] => Class[Mysql::Server] => File[/root/.my.cnf] =>
Mysql_grant[pma@%] => Class[Mysql::Server::Providers] => Anchor[mysql::server::end])
($users includes 'pma@%' so that I can point phpMyAdmin to the database at a later point.)
After unsuccessfully troubleshooting the problem, I changed my manifest to the following:
exec { 'symlink':
command => "ln -s ${mycnf} /root/.my.cnf",
unless => "ls /root/.my.cnf",
}
Class['::mysql::server'] ->
Exec['symlink']
Problem #2) Only part of ::mysql::server executes before the symlink is created.
...snip...
** [out :: ] notice: /Stage[main]/Mysql::Server::Providers/Mysql_grant[pma@%]/ensure: created
** [out :: ] notice: /Stage[main]/Mysql::Server::Account_security/Mysql_user[root@<hostname>]/ensure: removed
** [out :: ] notice: /Stage[main]/Mysql::Server::Account_security/Mysql_database[test]/ensure: removed
** [out :: ] notice: /Stage[main]/Hmdc_mariadb/Exec[symlink]/returns: executed successfully
** [out :: ] err: /Stage[main]/Mysql::Server::Account_security/Mysql_user[root@::1]/ensure: change from present to absent failed: Execution of '/usr/bin/mysql --defaults-extra-file=/root/.my.cnf -e DROP USER 'root'@'::1'' returned 1: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
** [out :: ]
** [out :: ] err: /Stage[main]/Mysql::Server::Account_security/Mysql_user[@<hostname>]/ensure: change from present to absent failed: Execution of '/usr/bin/mysql --defaults-extra-file=/root/.my.cnf -e DROP USER ''@'<hostname>'' returned 1: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)'
...snip...
I was under the impression that chaining meant all instructions would finish before moving on to the next? I'm considering putting a sleep statement in my symlink exec, in the hopes that a few more seconds will allow ::mysql::server to finish executing.
Any help is appreciated!