brint / wordpress-cookbook

Development repository for Opscode Cookbook wordpress
https://supermarket.chef.io/cookbooks/wordpress
Apache License 2.0
80 stars 174 forks source link

Wordpress DB password is not set correctly #56

Open erez-rabih opened 9 years ago

erez-rabih commented 9 years ago

I'm wrapping the wordpress cookbook with my own. I am trying to set the wordpress DB password using attributes:

include_attribute 'wordpress'
default['wordpress']['db']['pass'] = "some-password"

But it is not being set as expected. The problem is here: https://github.com/brint/wordpress-cookbook/blob/master/recipes/database.rb#L35

It overrides the given password even though the attribute has a value. After exploring the problem I found out that set_unless will override default precedence attributes. Changing the attributes file to normal instead of default solves it:

include_attribute 'wordpress'
normal['wordpress']['db']['pass'] = "some-password"

Just thought I should bring this issue to awareness.

Thanks :)

petracvv commented 9 years ago

I am running into this as well. It seems that you must set your own password as a normal precedence attribute in order for it to not be overwritten by the set_unless statement; not even a force_override was able to take precedence. Maybe switch the statement to something like:

node.set['wordpress']['db']['pass'] = secure_password if node['wordpress']['db']['pass'].nil?
Vanders commented 8 years ago

If you're still having problems with this I just opened https://github.com/brint/wordpress-cookbook/pull/71 that solves this for all of the set_unless cases and makes the cookbook more wrap-able.