Skip to content

Commit 858e10d

Browse files
committed
Fixes #192: Make Drupal playbooks idempotent by fixing permissions issues.
1 parent b78b2ba commit 858e10d

File tree

2 files changed

+22
-26
lines changed

2 files changed

+22
-26
lines changed

drupal/provisioning/playbook.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,22 @@
144144
repo: https://git.drupal.org/project/drupal.git
145145
version: "{{ drupal_core_version }}"
146146
dest: "{{ drupal_core_path }}"
147+
register: git_checkout
148+
149+
- name: Ensure Drupal codebase is owned by www-data.
150+
file:
151+
path: "{{ drupal_core_path }}"
152+
owner: www-data
153+
group: www-data
154+
recurse: true
155+
when: git_checkout.changed | bool
147156

148157
- name: Install Drupal dependencies with Composer.
149158
command: >
150159
/usr/local/bin/composer install
151160
chdir={{ drupal_core_path }}
152161
creates={{ drupal_core_path }}/vendor/autoload.php
162+
become_user: www-data
153163

154164
- name: Install Drupal.
155165
command: >
@@ -160,16 +170,4 @@
160170
--root={{ drupal_core_path }}
161171
creates={{ drupal_core_path }}/sites/default/settings.php
162172
notify: restart apache
163-
164-
# SEE: https://drupal.org/node/2121849#comment-8413637
165-
- name: Set permissions properly on settings.php.
166-
file:
167-
path: "{{ drupal_core_path }}/sites/default/settings.php"
168-
mode: 0744
169-
170-
- name: Set permissions properly on files directory.
171-
file:
172-
path: "{{ drupal_core_path }}/sites/default/files"
173-
mode: 0777
174-
state: directory
175-
recurse: yes
173+
become_user: www-data

includes/provisioning/tasks/drupal.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,22 @@
44
repo: https://git.drupal.org/project/drupal.git
55
version: "{{ drupal_core_version }}"
66
dest: "{{ drupal_core_path }}"
7+
register: git_checkout
8+
9+
- name: Ensure Drupal codebase is owned by www-data.
10+
file:
11+
path: "{{ drupal_core_path }}"
12+
owner: www-data
13+
group: www-data
14+
recurse: true
15+
when: git_checkout.changed | bool
716

817
- name: Install Drupal dependencies with Composer.
918
command: >
1019
/usr/local/bin/composer install
1120
chdir={{ drupal_core_path }}
1221
creates={{ drupal_core_path }}/vendor/autoload.php
22+
become_user: www-data
1323

1424
- name: Install Drupal.
1525
command: >
@@ -20,16 +30,4 @@
2030
--root={{ drupal_core_path }}
2131
creates={{ drupal_core_path }}/sites/default/settings.php
2232
notify: restart apache
23-
24-
# SEE: https://drupal.org/node/2121849#comment-8413637
25-
- name: Set permissions properly on settings.php.
26-
file:
27-
path: "{{ drupal_core_path }}/sites/default/settings.php"
28-
mode: 0744
29-
30-
- name: Set permissions properly on files directory.
31-
file:
32-
path: "{{ drupal_core_path }}/sites/default/files"
33-
mode: 0777
34-
state: directory
35-
recurse: yes
33+
become_user: www-data

0 commit comments

Comments
 (0)