puppetlabs/puppetlabs-mysql — pull request #92 by inkblot (2012-08-07 19:05:52+00:00)
Title: Use root credentials explicitly

The mysql root password is stored in .my.cnf in root's home directory. However, the mysql and mysqladmin commands use the value of the HOME environment variable rather than libc user ent data to determine the location of .my.cnf. This causes the puppet module's mysql and mysqladmin invocations to fail when HOME and the current user's home directory are not the same, e.g. if the puppet process was started using sudo.

I had created a pull request earlier and then got talked out of it. My initial discovery was that 'sudo puppet agent -t' failed but the running puppet daemon was able to apply the catalog. Someone suggested 'sudo -i puppet agent -t' which works. I have since discovered that even restarting the agent daemon with sudo ('sudo /etc/init.d/puppet restart') causes the a mismatch. This is much more insidious because the running daemon will fail on every run.