wordpress-cookbook icon indicating copy to clipboard operation
wordpress-cookbook copied to clipboard

Wordpress DB password is not set correctly

Open erez-rabih opened this issue 11 years ago • 2 comments

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 :)

erez-rabih avatar Apr 19 '15 14:04 erez-rabih

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?

petracvv avatar Oct 13 '15 21:10 petracvv

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.

Vanders avatar May 26 '16 07:05 Vanders