Closed BethkePeter closed 10 years ago
I had the exact same issue with the current code as of today. I think the solution is similar to your proposed solution, but you can also leave the has_variable? check in there, like this:
<% if has_variable?('mysql_password_hash') && @mysql_password_hash != '' then %>
PASSWORD '<%= @mysql_password_hash %>'
<% else %>
'<%= @mysql_password %>';
<% end %>
The current code would, I think, only go to the else block if mysql_password_hash was undefined--but since it's a blank string by default, that never happens.
I fixed as suggested. Note anyway that I personally never used mysql::user to set the root user password (there is the mysql::root_password parameter for that and it manages also /root/.my.cnf with the configured password (required to manage correctly the various class defines)
When I try the following, to set the password to "secret1". Then it use the Empty mysql_password_hash.
mysql::user { 'root-127.0.0.1': mysql_password => 'secret1', mysql_user => 'root', mysql_host => '127.0.0.1', }
Here is what i think. Have look.
The user.pp set the mysql_password_hash = ''
Define mysql::queryfile
define mysql::user ( $mysql_user, $mysql_password = '', $mysql_password_hash = '', $mysql_host = 'localhost', $mysql_grant_filepath = '/root/puppet-mysql' ) {
The user.erb is looking for an variable mysql_password_hash, and that is allways set. No Chance to use the variable mysql_password
<% if has_variable?('mysql_password_hash') && @mysql_password_hash then %> PASSWORD '<%= @mysql_password_hash %>' <% else %> '<%= @mysql_password %>'; <% end %>
I changed it to: <% if @mysql_password_hash != '' then %> PASSWORD '<%= @mysql_password_hash %>' <% else %> '<%= @mysql_password %>'; <% end %>
but I am not sure if that is the right way.
kind regards Peter Bethke