1

I'm trying to create an Ansible Role to run on a VM that creates a new site (so my colleagues don't have to memorize the drush si --db-url command and automate the entire process.

I'm running into a problem where the drush si command is getting the error: Command site-install needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command. We know this means that we're trying to run Drush from a non-drupal environment, so even when I add the 'chdir' arg to my playbook, it still gets this error.

The command in the playbook looks like this:

- name: Site Install with Drush command: | drush si standard --db-url=mysql://{{ mysql_username }}:{{ mysql_password }}@127.0.0.1:3306/{{ mysql_dbname }} --sites-subdir="domain.edu.{{ drupal_uri }}" --db-prefix="d_" chdir=/vagrant/d7core/

0

I found in a comment somewhere deep in the internet that there is a hidden -r option to specify the drupal root within a drush command.

The new play looks like this:

- name: Site Install with Drush command: | drush si standard --db-url=mysql://{{ mysql_username }}:{{ mysql_password }}@127.0.0.1:3306/{{ mysql_dbname }} --sites-subdir="domain.edu.{{ drupal_uri }}" --db-prefix="d_" -r /vagrant/d7core/ -y chdir=/vagrant/d7core/

Note, I also added the -y option, because it will count as an ansible error when it asks you to confirm that you want to DROP ALL ON db.

Because this was hidden functionality and it took me an hour and a half and it was a random comment somewhere that I found that in, I figured I'd make it an official SO question so anyone else looking to automate a workflow could hopefully find this faster.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.