promet / drupal-cookbook

24 stars 28 forks source link

Add and use settings.php template. #13

Closed dkinzer closed 6 years ago

dkinzer commented 11 years ago

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 4547328ba0043376b3626aec26030c26c97e1fce.

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

Konafets commented 11 years ago

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.