Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add and use settings.php template. #13

Open
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Contributor

dkinzer commented Feb 17, 2013

When a change is made to the database password attribute it is not reflected in settings.php. The result is that the code base can no longer communicate with its database and problems such as those described in mdxp/drupal-cookbook#5 arise.

This issue is partly the result of using drush-install to install drupal and not using a template to override the settings.php file.

Unfortunately drush-install does not currently allow a changes to settings.php file via the command line (as far as I'm aware). Therefore, this issue re implements the template process for configuring the settins.php file. Since d7 and d6 have different settings.php formats, a template is provided for each (@todo add d8 template).

This reverts part of commit 4547328.

Conflicts:
attributes/default.rb
metadata.rb
recipes/default.rb

@Konafets Konafets commented on an outdated diff Mar 31, 2013

recipes/default.rb
@@ -81,6 +81,17 @@
action :create
end
+template "#{node['drupal']['dir']}/sites/default/settings.php" do
+ source "d#{node['drupal']['version'][0..0]}.settings.php.erb"
+ mode "0644"
+ variables(
+ 'database' => node['drupal']['db']['database'],
+ 'user' => node['drupal']['db']['user'],
+ 'password' => node['drupal']['db']['password'],
+ 'host' => node['drupal']['db']['host'],
@Konafets

Konafets Mar 31, 2013

The trailing comma raise a syntax error

The patch works so far. I had to adjust the drupal dir a little bit.
I removed :dir => "/vagrant/mysite" from the vagrant file. The path is taken from the attributes/default.rb and is set to default['drupal']['dir'] = "/var/www/drupal".

Without this change I got this error:
================================================================================
Error executing action `create` on resource 'template[/vagrant/mysite/sites/default/settings.php]'
================================================================================

Errno::EPERM
------------
Operation not permitted - /vagrant/mysite/sites/default/settings.php

Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/drupal/recipes/default.rb

 82:
 83: template "#{node['drupal']['dir']}/sites/default/settings.php" do
 84:   source "d#{node['drupal']['version'][0..0]}.settings.php.erb"
 85:   mode "0644"
 86:   variables(
 87:     'database'        => node['drupal']['db']['database'],
 88:     'user'            => node['drupal']['db']['user'],
 89:     'password'        => node['drupal']['db']['password'],
 90:     'host'            => node['drupal']['db']['host']
 91:   )
 92: end
 93:

Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/drupal/recipes/default.rb:83:in `from_file'

template("/vagrant/mysite/sites/default/settings.php") do
  checksum "9137dcdf4309d599a2686abf8b1db64a66586483a01b9e48905dac429ac10607"
  mode "0644"
  diff "--- /vagrant/mysite/sites/default/settings.php\t2013-03-31 13:42:12.000000000 +0000\\n+++ /tmp/chef-rendered-template20130331-1410-13ctdg6-0\t2013-03-31 13:42:55.663923140 +0000\\n@@ -256,7 +256,7 @@\\n  *   $drupal_hash_salt = file_get_contents('/home/example/salt.txt');\\n  *\\n  */\\n-$drupal_hash_salt = 'oRbbl_IYHiKgXEkBxyVaMuj5hbg-HKmTH0vMkvjQSB0';\\n+$drupal_hash_salt = 'iZH6JKB2DREAVO8S-x4gs1iAXk-aqMs63j7Fk1sD53A';\\n \\n /**\\n  * Base URL (optional).\\n@@ -564,4 +564,4 @@\\n  *\\n  * Remove the leading hash signs to disable.\\n  */\\n-# $conf['allow_authorize_operations'] = FALSE;\\n+# $conf['allow_authorize_operations'] = FALSE;"
  retry_delay 2
  path "/vagrant/mysite/sites/default/settings.php"
  retries 0
  recipe_name "default"
  source "d7.settings.php.erb"
  action "create"
  cookbook_name :drupal
  variables {"database"=>"drupal", "user"=>"drupal", "host"=>"localhost", "password"=>"drupalpass"}
  backup 5
  provider Chef::Provider::Template
end

[2013-03-31T13:42:55+00:00] ERROR: Running exception handlers
[2013-03-31T13:42:55+00:00] ERROR: Exception handlers complete
[2013-03-31T13:42:55+00:00] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out
[2013-03-31T13:42:55+00:00] FATAL: Errno::EPERM: template[/vagrant/mysite/sites/default/settings.php] (drupal::default line 83) had an error: Errno::EPERM: Operation not permitted - /vagrant/mysite/sites/default/settings.php
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
Add and use settings.php template.
When a change is made to the databse password attribute it is not reflected in settings.php.  The result is that the code base can no longer comminicate with its database and problems such as those described in promet/drupal-cookbook#5 arise.

This issue is partly the result of using drush-install to install drupal and not using a template to override the settins.php file.

Unfortunately drush-install does not currently allow a changes to settings.php file via the command line (as far as I'm aware).  Therefore, this issue reimplements the template process for configuring the settins.php file.  Since d7 and d6 have different settins.php formats, a template is provided for each (@todo add d8 template).

This reverts part of commit 4547328.

--amend:
 (1) Remove trailing comma.

jedimonkey added a commit to meerkats/drupal-cookbook that referenced this pull request Nov 25, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment