Commit 4e5a356d authored by Marco Mariani's avatar Marco Mariani

use slapos.cookbook:generate.password

parent c419daae
...@@ -39,7 +39,6 @@ from slapos.recipe.librecipe import GenericBaseRecipe ...@@ -39,7 +39,6 @@ from slapos.recipe.librecipe import GenericBaseRecipe
# - drush connects to mysql with the password on command line # - drush connects to mysql with the password on command line
# see http://stackoverflow.com/questions/6607675/shell-script-password-security-of-command-line-parameters # 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 # 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). # - using slapproxy, sometimes this recipe is not able to connect to mysql (tunnel down).
# restarting from supervisor usually solves it. # restarting from supervisor usually solves it.
# #
...@@ -77,12 +76,11 @@ class InitRecipe(GenericBaseRecipe): ...@@ -77,12 +76,11 @@ class InitRecipe(GenericBaseRecipe):
drush_output = subprocess.check_output([drush_binary, drush_output = subprocess.check_output([drush_binary,
'-y', 'site-install', '-y', 'site-install',
'--account-name=admin' '--account-name=admin',
'--account-pass=%s' % self.options['admin-password'],
], ],
stderr=subprocess.STDOUT) stderr=subprocess.STDOUT)
self.options['admin-password'] = self.extract_password(drush_output)
# drush removes the 'w' bit from both the settings file and its # drush removes the 'w' bit from both the settings file and its
# directory. # directory.
# we restore them, otherwise buildout will see the file as changed # we restore them, otherwise buildout will see the file as changed
...@@ -95,10 +93,6 @@ class InitRecipe(GenericBaseRecipe): ...@@ -95,10 +93,6 @@ class InitRecipe(GenericBaseRecipe):
return [] 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): def is_db_empty(self, php_binary, settings_php):
with tempfile.NamedTemporaryFile() as fout: with tempfile.NamedTemporaryFile() as fout:
settings_dirname, settings_filename = os.path.split(settings_php) settings_dirname, settings_filename = os.path.split(settings_php)
......
...@@ -11,10 +11,22 @@ drush-binary = ${apache-php:location}/bin/drush ...@@ -11,10 +11,22 @@ drush-binary = ${apache-php:location}/bin/drush
php-binary = ${apache-php:location}/bin/php php-binary = ${apache-php:location}/bin/php
settings-php = ${application-configuration:location} settings-php = ${application-configuration:location}
htdocs = $${rootdirectory:srv}/www htdocs = $${rootdirectory:srv}/www
#admin-password = admin-password = $${gen-passwd:passwd}
dependency = $${apache-php:recipe} 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] [drupal-init]
recipe = iw.recipe.cmd recipe = iw.recipe.cmd
cmds = cmds =
$${drupal-init-base:drush-binary} install drush make build-datapublic.make DrupalDataPublic $${drupal-init-base:drush-binary} install drush make build-datapublic.make DrupalDataPublic
...@@ -52,7 +52,7 @@ part-list = drupal-init publish-drupal-admin-password ...@@ -52,7 +52,7 @@ part-list = drupal-init publish-drupal-admin-password
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-custom.cfg.in url = ${:_profile_base_location_}/instance-custom.cfg.in
output = ${buildout:directory}/instance-custom.cfg output = ${buildout:directory}/instance-custom.cfg
md5sum = cde648fb7477fd5927062d6df575e895 md5sum = 4d07c8018c3e78e46a5f6cb1958434d4
mode = 0644 mode = 0644
......
...@@ -11,10 +11,22 @@ drush-binary = ${apache-php:location}/bin/drush ...@@ -11,10 +11,22 @@ drush-binary = ${apache-php:location}/bin/drush
php-binary = ${apache-php:location}/bin/php php-binary = ${apache-php:location}/bin/php
settings-php = ${application-configuration:location} settings-php = ${application-configuration:location}
htdocs = $${rootdirectory:srv}/www htdocs = $${rootdirectory:srv}/www
#admin-password = admin-password = $${gen-passwd:passwd}
dependency = $${apache-php:recipe} 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] [drupal-init]
recipe = iw.recipe.cmd recipe = iw.recipe.cmd
cmds = cmds =
$${drupal-init-base:drush-binary} install drush make --prepare-install build-openpublic.make DrupalOpenPublic $${drupal-init-base:drush-binary} install drush make --prepare-install build-openpublic.make DrupalOpenPublic
...@@ -52,7 +52,7 @@ part-list = drupal-init publish-drupal-admin-password ...@@ -52,7 +52,7 @@ part-list = drupal-init publish-drupal-admin-password
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-custom.cfg.in url = ${:_profile_base_location_}/instance-custom.cfg.in
output = ${buildout:directory}/instance-custom.cfg output = ${buildout:directory}/instance-custom.cfg
md5sum = d318cbc4d417616b9d7afa4a398f3569 md5sum = 5a787592514eb5baa24edcda9a44f6b7
mode = 0644 mode = 0644
......
...@@ -11,6 +11,16 @@ drush-binary = ${apache-php:location}/bin/drush ...@@ -11,6 +11,16 @@ drush-binary = ${apache-php:location}/bin/drush
php-binary = ${apache-php:location}/bin/php php-binary = ${apache-php:location}/bin/php
settings-php = ${application-configuration:location} settings-php = ${application-configuration:location}
htdocs = $${rootdirectory:srv}/www htdocs = $${rootdirectory:srv}/www
#admin-password = admin-password = $${gen-passwd:passwd}
dependency = $${apache-php:recipe} 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
...@@ -34,7 +34,7 @@ part-list = drupal-init publish-drupal-admin-password ...@@ -34,7 +34,7 @@ part-list = drupal-init publish-drupal-admin-password
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-custom.cfg.in url = ${:_profile_base_location_}/instance-custom.cfg.in
output = ${buildout:directory}/instance-custom.cfg output = ${buildout:directory}/instance-custom.cfg
md5sum = 283cb53ff8cd34635703e771062db919 md5sum = 30b3d75d79916ae25ef19969499a3aa2
mode = 0644 mode = 0644
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment