Skip to content

Commit

Permalink
Add support for .env file in drupal (steamengine_drupal_env_template_…
Browse files Browse the repository at this point in the history
…path)
  • Loading branch information
balobe committed Sep 6, 2021
1 parent afae188 commit e23c6cb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tasks/drupal/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,18 @@
tags:
- steamengine_deploy_drupal

# Add .env file for env_variables drupal modules: https://www.drupal.org/project/env_variables

- include_tasks:
file: "./deploy_env_file.yml"
apply:
tags:
- steamengine_deploy
- steamengine_deploy_drupal
when: steamengine_drupal_env_template_path is defined
tags:
- always

- name: Check if database is empty
command: "{{ steamengine_drush_launcher_path }} -r {{ steamengine_project_root_path_web }} sql-query 'show tables'"
register: database_table_number
Expand Down
26 changes: 26 additions & 0 deletions tasks/drupal/deploy_env_file.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---

- name: Remove potential env file
file:
state: absent
path: "{{ steamengine_project_root_path_web }}/.env"
when: steamengine_drupal_env_template_path is defined

# Template module is used because copy module is not recommended with variables : https://docs.ansible.com/ansible/latest/collections/ansible/builtin/copy_module.html)
- name: Create external env file
template:
src: "{{ steamengine_drupal_env_template_path }}"
dest: "{{ steamengine_conf_path }}/.env"
owner: "{{ steamengine_project_user }}"
group: "{{ steamengine_app_user }}"
mode: u=rw,g=r,o=
when: steamengine_drupal_env_template_path is defined

- name: Create env symlink
file:
state: link
src: "{{ steamengine_conf_path }}/.env"
dest: "{{ steamengine_project_root_path_web }}/.env"
owner: "{{ steamengine_project_user }}"
group: "{{ steamengine_app_user }}"
when: steamengine_drupal_env_template_path is defined

0 comments on commit e23c6cb

Please sign in to comment.