From 4e5a356ddce831fea3b3b0325d0fc250c4f2aac6 Mon Sep 17 00:00:00 2001 From: Marco Mariani <marco.mariani@nexedi.com> Date: Wed, 3 Apr 2013 14:41:24 +0200 Subject: [PATCH] use slapos.cookbook:generate.password --- slapos/recipe/drupal/__init__.py | 10 ++-------- software/DrupalDataPublic/instance-custom.cfg.in | 14 +++++++++++++- software/DrupalDataPublic/software.cfg | 2 +- software/DrupalOpenPublic/instance-custom.cfg.in | 14 +++++++++++++- software/DrupalOpenPublic/software.cfg | 2 +- software/drupal/instance-custom.cfg.in | 12 +++++++++++- software/drupal/software.cfg | 2 +- 7 files changed, 42 insertions(+), 14 deletions(-) diff --git a/slapos/recipe/drupal/__init__.py b/slapos/recipe/drupal/__init__.py index a0ca8bd00..2a121bb1d 100644 --- a/slapos/recipe/drupal/__init__.py +++ b/slapos/recipe/drupal/__init__.py @@ -39,7 +39,6 @@ from slapos.recipe.librecipe import GenericBaseRecipe # - drush connects to mysql with the password on command line # see http://stackoverflow.com/questions/6607675/shell-script-password-security-of-command-line-parameters # it could use a socket, but we are on a different instance than mysql -# - the admin_password is not published yet. # - using slapproxy, sometimes this recipe is not able to connect to mysql (tunnel down). # restarting from supervisor usually solves it. # @@ -77,12 +76,11 @@ class InitRecipe(GenericBaseRecipe): drush_output = subprocess.check_output([drush_binary, '-y', 'site-install', - '--account-name=admin' + '--account-name=admin', + '--account-pass=%s' % self.options['admin-password'], ], stderr=subprocess.STDOUT) - self.options['admin-password'] = self.extract_password(drush_output) - # drush removes the 'w' bit from both the settings file and its # directory. # we restore them, otherwise buildout will see the file as changed @@ -95,10 +93,6 @@ class InitRecipe(GenericBaseRecipe): return [] - def extract_password(self, drush_output): - return re.search('User password: (\S+)', drush_output).groups()[0] - - def is_db_empty(self, php_binary, settings_php): with tempfile.NamedTemporaryFile() as fout: settings_dirname, settings_filename = os.path.split(settings_php) diff --git a/software/DrupalDataPublic/instance-custom.cfg.in b/software/DrupalDataPublic/instance-custom.cfg.in index 28dbbc4cd..a289c29a4 100644 --- a/software/DrupalDataPublic/instance-custom.cfg.in +++ b/software/DrupalDataPublic/instance-custom.cfg.in @@ -11,10 +11,22 @@ drush-binary = ${apache-php:location}/bin/drush php-binary = ${apache-php:location}/bin/php settings-php = ${application-configuration:location} htdocs = $${rootdirectory:srv}/www -#admin-password = +admin-password = $${gen-passwd:passwd} dependency = $${apache-php:recipe} + +#---------------- +#-- +#-- Generates a random password and stores it in the filesystem + +[gen-passwd] +recipe = slapos.cookbook:generate.password +storage-path = $${directories:srv}/drupal_passwd +bytes = 16 + + [drupal-init] recipe = iw.recipe.cmd cmds = $${drupal-init-base:drush-binary} install drush make build-datapublic.make DrupalDataPublic + diff --git a/software/DrupalDataPublic/software.cfg b/software/DrupalDataPublic/software.cfg index d958d4e8c..ff1113410 100644 --- a/software/DrupalDataPublic/software.cfg +++ b/software/DrupalDataPublic/software.cfg @@ -52,7 +52,7 @@ part-list = drupal-init publish-drupal-admin-password recipe = slapos.recipe.template url = ${:_profile_base_location_}/instance-custom.cfg.in output = ${buildout:directory}/instance-custom.cfg -md5sum = cde648fb7477fd5927062d6df575e895 +md5sum = 4d07c8018c3e78e46a5f6cb1958434d4 mode = 0644 diff --git a/software/DrupalOpenPublic/instance-custom.cfg.in b/software/DrupalOpenPublic/instance-custom.cfg.in index 020972898..836b6090d 100644 --- a/software/DrupalOpenPublic/instance-custom.cfg.in +++ b/software/DrupalOpenPublic/instance-custom.cfg.in @@ -11,10 +11,22 @@ drush-binary = ${apache-php:location}/bin/drush php-binary = ${apache-php:location}/bin/php settings-php = ${application-configuration:location} htdocs = $${rootdirectory:srv}/www -#admin-password = +admin-password = $${gen-passwd:passwd} dependency = $${apache-php:recipe} + +#---------------- +#-- +#-- Generates a random password and stores it in the filesystem + +[gen-passwd] +recipe = slapos.cookbook:generate.password +storage-path = $${directories:srv}/drupal_passwd +bytes = 16 + + [drupal-init] recipe = iw.recipe.cmd cmds = $${drupal-init-base:drush-binary} install drush make --prepare-install build-openpublic.make DrupalOpenPublic + diff --git a/software/DrupalOpenPublic/software.cfg b/software/DrupalOpenPublic/software.cfg index 9c488f7ad..ae83e1f47 100644 --- a/software/DrupalOpenPublic/software.cfg +++ b/software/DrupalOpenPublic/software.cfg @@ -52,7 +52,7 @@ part-list = drupal-init publish-drupal-admin-password recipe = slapos.recipe.template url = ${:_profile_base_location_}/instance-custom.cfg.in output = ${buildout:directory}/instance-custom.cfg -md5sum = d318cbc4d417616b9d7afa4a398f3569 +md5sum = 5a787592514eb5baa24edcda9a44f6b7 mode = 0644 diff --git a/software/drupal/instance-custom.cfg.in b/software/drupal/instance-custom.cfg.in index bda729507..88cf6de5a 100644 --- a/software/drupal/instance-custom.cfg.in +++ b/software/drupal/instance-custom.cfg.in @@ -11,6 +11,16 @@ drush-binary = ${apache-php:location}/bin/drush php-binary = ${apache-php:location}/bin/php settings-php = ${application-configuration:location} htdocs = $${rootdirectory:srv}/www -#admin-password = +admin-password = $${gen-passwd:passwd} dependency = $${apache-php:recipe} + +#---------------- +#-- +#-- Generates a random password and stores it in the filesystem + +[gen-passwd] +recipe = slapos.cookbook:generate.password +storage-path = $${directories:srv}/drupal_passwd +bytes = 16 + diff --git a/software/drupal/software.cfg b/software/drupal/software.cfg index 1c9b5ebc1..7786b259c 100644 --- a/software/drupal/software.cfg +++ b/software/drupal/software.cfg @@ -34,7 +34,7 @@ part-list = drupal-init publish-drupal-admin-password recipe = slapos.recipe.template url = ${:_profile_base_location_}/instance-custom.cfg.in output = ${buildout:directory}/instance-custom.cfg -md5sum = 283cb53ff8cd34635703e771062db919 +md5sum = 30b3d75d79916ae25ef19969499a3aa2 mode = 0644 -- 2.30.9