Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.
3 changes: 2 additions & 1 deletion roles/database_apply/database_apply-drupal7/tasks/ctools.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
# For some reason D7 drush doesn't respect 'chdir' with command, using shell instead.
- name: Check if Ctools module is enabled.
ansible.builtin.shell:
cmd: "{{ drush_bin }} pm-info ctools | grep ': enabled' | wc -l"
chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}"
register: ctools_enabled

- name: Revert Drupal configuration from Ctools.
ansible.builtin.command:
ansible.builtin.shell:
cmd: "{{ drush_bin }} -y ctools-export-revert --all"
chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}"
when: ctools_enabled.stdout == "1"
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
# For some reason D7 drush doesn't respect 'chdir' with command, using shell instead.
- name: Check if Features module is enabled.
shell: "cd {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }} && {{ drush_bin }} -l {{ site.folder }} pm-info features | grep ': enabled' | wc -l"
ansible.builtin.shell: "cd {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }} && {{ drush_bin }} -l {{ site.folder }} pm-info features | grep ': enabled' | wc -l"
register: features_enabled

- name: Revert Drupal configuration from Features.
shell: "cd {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }} && {{ drush_bin }} -l {{ site.folder }} -y {{ site.revert_features_command }}"
ansible.builtin.shell: "cd {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }} && {{ drush_bin }} -l {{ site.folder }} -y {{ site.revert_features_command }}"
when: features_enabled.stdout == "1"
12 changes: 6 additions & 6 deletions roles/database_apply/database_apply-drupal7/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

# For some reason D7 drush doesn't respect 'chdir' with command, using shell instead.
- name: Install Drupal.
shell:
ansible.builtin.shell:
cmd: "{{ drush_bin }} -l {{ site.folder }} {{ site.install_command }}"
chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}"
become: "{{ 'no' if www_user == deploy_user else 'yes' }}"
Expand All @@ -12,7 +12,7 @@
when: previous_build_number == 0 or (site.force_install is defined and site.force_install)

- name: Fix permissions on Drupal directory.
shell:
ansible.builtin.shell:
cmd: "chmod 755 {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}"
with_items: "{{ drupal.sites }}"
loop_control:
Expand All @@ -30,15 +30,15 @@
when: previous_build_number > 0

- name: Apply Drupal database updates.
shell:
ansible.builtin.shell:
cmd: "{{ drush_bin }} -l {{ site.folder }} -y updb"
chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}"
with_items: "{{ drupal.sites }}"
loop_control:
loop_var: site

- name: Revert Drupal configuration with Features.
include_tasks: features.yml
ansible.builtin.include_tasks: features.yml
with_items: "{{ drupal.sites }}"
loop_control:
loop_var: site
Expand All @@ -47,7 +47,7 @@
- site.revert_features_command

- name: Revert Drupal configuration with Ctools.
include_tasks: ctools.yml
ansible.builtin.include_tasks: ctools.yml
with_items: "{{ drupal.sites }}"
loop_control:
loop_var: site
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
- ansible.builtin.set_fact:
_admin_pwd: "{{ lookup('password', '/tmp/{{ project_name }}-{{ site.folder }}-{{ build_type }}-{{ build_number }}-pwd chars=ascii_letters') }}"

# For some reason D7 drush doesn't respect 'chdir' with command, using shell instead.
- name: Reset admin username.
ansible.builtin.command:
ansible.builtin.shell:
cmd: "{{ drush_bin }} -l {{ site.folder }} sql-query \"UPDATE users SET name='{{ _admin_user }}' WHERE uid=1;\""
chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}"
- name: Reset admin password.
ansible.builtin.command:
ansible.builtin.shell:
cmd: "{{ drush_bin }} -l {{ site.folder }} upwd {{ _admin_user }} --password='{{ _admin_pwd }}'"
chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}"
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
# For some reason D7 drush doesn't respect 'chdir' with command, using shell instead.
- name: Clear Drupal 7 cache.
ansible.builtin.command:
ansible.builtin.shell:
cmd: "{{ drush_bin }} -l {{ site.folder }} -y cc all"
chdir: "{{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}"
become: "{{ 'no' if www_user == deploy_user else 'yes' }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
# For some reason D7 drush doesn't respect 'chdir' with command, using shell instead.
- name: Apply Drupal database updates.
ansible.builtin.command:
ansible.builtin.shell:
cmd: "{{ drush_bin }} -l {{ site.folder }} -y updb"
chdir: "{{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}"
with_items: "{{ drupal.sites }}"
Expand Down