drush-ops / drush

Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt.
https://www.drush.org
2.33k stars 1.08k forks source link

Drush site-install fails to respect default password set in site alias yml file #5719

Open bhanu951 opened 1 year ago

bhanu951 commented 1 year ago

Describe the bug

drush site-install fails to respect default password set in site alias yml file. We have option to set default password on site install in site alias file, but site-install command fails to respect it.

To Reproduce

Create a file named as self.site.yml in drush/sites/ directory similar to example.site.yml

dev:
  root: /var/www/html/web
  uri: https://drupal-contrib.ddev.site
  command:
    site:
      install:
        options:
          admin-password: 'admin'

and run drush @self.dev si you will see below message.

drupal-contrib $ddev drush si

 You are about to:
 * DROP all tables in your 'db' database.

 Do you want to continue? (yes/no) [yes]:
 >

 [notice] Starting Drupal installation. This takes a while.
 [notice] Performed install task: install_select_language
 [notice] Performed install task: install_select_profile
 [notice] Performed install task: install_load_profile
 [notice] Performed install task: install_verify_requirements
 [notice] Performed install task: install_verify_database_ready
 [notice] Performed install task: install_base_system
 [notice] Performed install task: install_bootstrap_full
 [notice] Performed install task: install_profile_modules
 [notice] Performed install task: install_profile_themes
 [notice] Performed install task: install_install_profile
 [notice] Performed install task: install_configure_form
 [notice] Performed install task: install_finished
 [success] Installation complete.  User name: admin  User password: 4qY8eHdfPQ

Expected behavior

It is expected that default password admin is set instead of generating random password every time we run the above command.

Actual behavior

It is generating random password every time we run the above command.

Workaround

drush @self.dev site:install standard --account-name=admin --account-pass=admin --site-name="Drupal 9" -y

System Configuration

Q A
Drush version? 12.x/11.x/
Drupal version? 10.x/9.x/
PHP version 8.x/7.x
OS? Mac + Ddev
drupal-contrib $ddev drush st
Drupal version   : 9.5.10
Site URI         : https://drupal-contrib.ddev.site
DB driver        : mysql
DB hostname      : db
DB port          : 3306
DB username      : db
DB name          : db
Database         : Connected
Drupal bootstrap : Successful
Default theme    : olivero
Admin theme      : claro
PHP binary       : /usr/bin/php7.4
PHP config       : /etc/php/7.4/cli/php.ini
PHP OS           : Linux
PHP version      : 7.4.33
Drush script     : /var/www/html/vendor/bin/drush
Drush version    : 11.6.0
Drush temp       : /tmp
Drush configs    : /var/www/html/vendor/drush/drush/drush.yml
Install profile  : standard
Drupal root      : /var/www/html/web
Site path        : sites/default
Files, Public    : sites/default/files
Files, Temp      : /tmp

This issue is reproduced on both Drush 11 and 12 with Drupal 9 and 10 and PHP 8 and 7 combinations.

greg-1-anderson commented 1 year ago

You are using account-pass in your workaround, but admin-password in your drush.yml file. Does it work if you use account-pass in the drush.yml file?

bhanu951 commented 1 year ago

Hi @greg-1-anderson Thanks for response. It doesn't work for either.

bhanu951 commented 1 year ago

Hi @greg-1-anderson just found out drush doesn't respect other commands overrides in yml file as well.

dev:
  root: /var/www/html/web
  uri: https://drupal-contrib.ddev.site
  command:
    site:
      install:
        options:
          admin-password: 'admin'
    sql:
      dump:
        options:
          extra-dump: '--column-statistics=0 --no-tablespaces'

ddev drush sql:dump > ./databases/clean_db_03_08_2023.sql

mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces

Due to Breaking Chnages in MYSQL 8+ we need to add -no-tablespaces to drush sql:dump command, I added extra-dump: '--column-statistics=0 --no-tablespaces' in yml file. But it is not respecting it.

The below command works

ddev drush sql:dump --extra-dump=--no-tablespaces > ./databases/clean_db_03_08_2023.sql

but

ddev drush sql:dump > ./databases/clean_db_03_08_2023.sql after adding override in yml still produces error.

weitzman commented 1 year ago

Drush configs : /var/www/html/vendor/drush/drush/drush.yml. Suggests that your config file is not found. If it were you would see another entry here.

bhanu951 commented 1 year ago

Hi @weitzman thanks for the response.

Can't we override command options in site alias yml file? Thats what I did. Same was suggested in example site alias yml file.

I am sure that my site alias file is loaded properly as I can run drush commands with including site alias.

weitzman commented 1 year ago

Sorry I see mostly commands in your example without @dev. Yes command options should work in site alias files as per https://www.drush.org/12.x/examples/example.site.yml/. Alias files are meant for remote sites but I think they still work for local sites (not recommended).

bhanu951 commented 1 year ago

Thanks for looking into it. I tried both with and without site alias for testing , both produced same results. I will once again try with adding command overrides in drush.yml file instead of site alias yml file and update here.