example42 / puppet-mysql

Mysql Puppet Module
http://www.example42.com
Other
16 stars 38 forks source link

Fixed use of parameters in mysql::query + added defaults #21

Closed RobQuistNL closed 11 years ago

RobQuistNL commented 11 years ago

It seems like orginally the mysql file .my.cfg wasn't used, plus the parameters host, password & username weren't used in the command yet.

alvagante commented 11 years ago

Well the my.cnf file was actually used by default, since Puppet runs as root. The fix for different users actually is weclomed, but please give me some time to properly test this in running environments. For example, I would keep the mysql_db a required filed and avoid any change in the query file that would trigger a new sql query command.

Freeaqingme commented 11 years ago

@example42 The problem was that although mysql runs as root, $MYSQL_HOME wasn't set in our puppet run, and therefore the .my.cnf file was ignored. I assume this is why the other classes also rely on the --defaults-file option (like mysql::user or mysql::grant).

Furthermore, the query we were trying to execute was a 'create database' statement, which clearly does not require a database (there are more queries possible that do not require a database). By leaving the db option empty, the use statement became "USE ;" which resulted in a mysql syntax error. I'm not sure if this could be fixed without touching the template (except for duplicating it).

Edit; fyi, @RobQuistNL is a colleague of mine.

alvagante commented 11 years ago

Ok, merged, thank you I fixed with the same approach the mysql::queryfile define, that had a similar issue. Note that I changed the template in order to avoid accidental re-executions of the query.