Hi I am using chef for deployment automation of a wordpress site where in I need to read database, host, username and password from my shared.yml for wp-config.php so I am trying below code in my template file

define('DB_NAME', '"<%= @database %>"');
define('DB_USER', '"<%= @username %>"');
define('DB_PASSWORD', '"<%= @password %>"');
define('DB_HOST', '"<% @host %>"');
define('DB_CHARSET', 'utf8mb4');
define('DB_COLLATE', '');

however the interpolation isn't taking place in where it should take actual values that are defined in _shared.yml. My attributes in chef looks like below.

default[:example_wp][:database][:host]          = ""
default[:example_wp][:database][:adapter]       = "mysql2"
default[:example_wp][:database][:database]      = "wordpress"
default[:example_wp][:database][:username]      = "wordpress"
default[:example_wp][:database][:password]      = ""

Can someone help with interpolation that I am trying.


  • Please don't post the same question on multiple SE sites – coderanger Mar 21 '17 at 17:12
  • Answered over in stackoverflow.com/questions/42929709/… – coderanger Mar 22 '17 at 1:44
  • @coderanger Why? It's on topic here, not there. – Michael Hampton Mar 22 '17 at 1:50
  • Because the vast bulk of Chef questions, and thus people that answer them are on SO. Just compare the tag activity here vs. there. As you can see in my answer there, it's definitely a programming topic :) – coderanger Mar 22 '17 at 2:01

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.