Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Updated role to depend on drush deploy command. (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
markdorison authored Aug 18, 2020
1 parent 7700e72 commit 0c79c5d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 51 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
# Ansible Role: deploy-drupal

Manages Drupal site deployments.

## Requirements

None.

## Role Variables

See [defaults](defaults/main.yml) for all available variables and accompanying
documentation.

## Example Playbook

Including an example of how to use your role (for instance, with variables
passed in as parameters) is always nice for users too:

```
```yaml
- hosts: all

vars:
Expand All @@ -29,4 +33,5 @@ passed in as parameters) is always nice for users too:
```
## License
MIT
6 changes: 3 additions & 3 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ deploydrupal_site_install: false
# deploydrupal_site_install is true.
deploydrupal_site_install_config: true

# If set to false, drush config-import will not be run as part of deployment.
deploydrupal_config_import: true
# If set to false, drush deploy will not be run as part of deployment.
deploydrupal_drush_deploy: true

# The path the repository should be cloned to.
deploydrupal_dir: "/var/www/html"
Expand All @@ -54,7 +54,7 @@ deploydrupal_npm_theme_build: false
deploydrupal_npm_theme_path: ""
deploydrupal_npm_theme_run_commands: []

# Rebuild Drupal cache.
# Rebuild Drush cache.
deploydrupal_drush_cache_rebuild: true

# Site file directory folders that need permission fixes after site install.
Expand Down
57 changes: 10 additions & 47 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@
mode: 0770
become: "{{ deploydrupal_files_become }}"

- name: clear caches.
shell: "{{ deploydrupal_drush_path }} cache-rebuild"
- name: run theme build tasks.
shell: "{{ item }}"
args:
chdir: "{{ deploydrupal_core_path }}/sites/{{ deploydrupal_site_name }}"
chdir: "{{ deploydrupal_npm_theme_path }}"
with_items: "{{ deploydrupal_npm_theme_run_commands }}"
when:
- not deploydrupal_site_install
- deploydrupal_drush_cache_rebuild
- deploydrupal_npm_theme_build
- deploydrupal_npm_theme_path is defined

# Drush ^9 uses the Drupal service container. We intentionally clear the Drupal
# cache before the Drush cache to avoid fatal errors due to stale cache in the
Expand Down Expand Up @@ -117,56 +118,18 @@
when:
- deploydrupal_site_install

# Import the latest configuration. This includes the latest
# configuration_split configuration. Importing this twice ensures that the
# latter command enables and disables modules based upon the most up to date
# configuration.
- name: import configuration 1/2.
shell: "{{ deploydrupal_drush_path }} config-import -y"
args:
chdir: "{{ deploydrupal_core_path }}/sites/{{ deploydrupal_site_name }}"
register: drush_output
when:
- deploydrupal_config_import

- name: print drush output
debug: var=drush_output.stdout_lines
when:
- deploydrupal_config_import

- name: import configuration 2/2.
shell: "{{ deploydrupal_drush_path }} config-import -y"
- name: drush deploy
shell: "{{ deploydrupal_drush_path }} deploy -v -y"
args:
chdir: "{{ deploydrupal_core_path }}/sites/{{ deploydrupal_site_name }}"
register: drush_output
when:
- deploydrupal_config_import
- deploydrupal_drush_deploy

- name: print drush output
debug: var=drush_output.stdout_lines

- name: run database updates.
shell: "{{ deploydrupal_drush_path }} updatedb -y"
args:
chdir: "{{ deploydrupal_core_path }}/sites/{{ deploydrupal_site_name }}"
when:
- not deploydrupal_site_install

- name: run theme build tasks.
shell: "{{ item }}"
args:
chdir: "{{ deploydrupal_npm_theme_path }}"
with_items: "{{ deploydrupal_npm_theme_run_commands }}"
when:
- deploydrupal_npm_theme_build
- deploydrupal_npm_theme_path is defined

- name: clear caches.
shell: "{{ deploydrupal_drush_path }} cache-rebuild"
args:
chdir: "{{ deploydrupal_core_path }}/sites/{{ deploydrupal_site_name }}"
when:
- deploydrupal_drush_cache_rebuild
- deploydrupal_drush_deploy

# Save redis data to disk. This is necessary in Docker environments to ensure we
# preserve the correct cache state.
Expand Down

0 comments on commit 0c79c5d

Please sign in to comment.