This repository was archived by the owner on Oct 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.yml
More file actions
137 lines (125 loc) · 4.17 KB
/
main.yml
File metadata and controls
137 lines (125 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
---
- name: Fix file permissions for settings.php.
ansible.builtin.file:
state: file
path: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}/settings.php"
owner: "{{ www_user }}"
group: "{{ www_user }}"
become: true
with_items: "{{ drupal.sites }}"
loop_control:
loop_var: site
when:
- www_user != deploy_user
- previous_build_number == 0
- name: Fix file permissions for config directory.
ansible.builtin.file:
state: directory
path: "{{ deploy_path }}/{{ site.config_sync_directory }}"
owner: "{{ www_user }}"
group: "{{ www_user }}"
mode: '0775' # in this case often our deploy user is in the web user group and will need to be able to manipulate config
become: true
with_items: "{{ drupal.sites }}"
loop_control:
loop_var: site
when:
- www_user != deploy_user
- previous_build_number == 0
- name: Install Drupal.
ansible.builtin.command:
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' }}"
become_user: "{{ www_user }}"
with_items: "{{ drupal.sites }}"
loop_control:
loop_var: site
when: (previous_build_number == 0) or (site.force_install is defined and site.force_install)
register: _drush_output
- name: Sync database.
ansible.builtin.include_role:
name: sync/database_sync
vars:
mysql_sync: "{{ site.mysql_sync }}"
with_items: "{{ drupal.sites }}"
loop_control:
loop_var: site
when:
- (previous_build_number == 0) or (site.force_install is defined and site.force_install)
- site.feature_branch | default(false)
- site.mysql_sync | length > 0
- name: Sync files.
ansible.builtin.include_role:
name: sync/files_sync
vars:
files_sync: "{{ site.files_sync }}"
with_items: "{{ drupal.sites }}"
loop_control:
loop_var: site
when:
- (previous_build_number == 0) or (site.force_install is defined and site.force_install)
- site.feature_branch | default(false)
- site.files_sync | length > 0
- name: Show drush output.
ansible.builtin.debug:
msg: "{{ _drush_output }}"
when: drupal.drush_verbose_output
- name: Fix permissions on Drupal directory.
ansible.builtin.file:
path: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}"
state: directory
mode: '0755'
with_items: "{{ drupal.sites }}"
loop_control:
loop_var: site
when: (previous_build_number == 0) or (site.force_install is defined and site.force_install)
- name: Clear the cache.
ansible.builtin.include_role:
name: "cache_clear/cache_clear-{{ project_type }}"
with_items: "{{ drupal.sites }}"
loop_control:
loop_var: site
when:
- previous_build_number > 0
- site.config_import_command != 'deploy'
- name: Apply Drupal database updates.
ansible.builtin.command:
cmd: "{{ drush_bin }} -l {{ site.folder }} -y updb"
chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}"
become: "{{ 'no' if www_user == deploy_user else 'yes' }}"
become_user: "{{ www_user }}"
with_items: "{{ drupal.sites }}"
loop_control:
loop_var: site
when: site.config_import_command != 'deploy'
register: _drush_output
- name: Show drush output.
ansible.builtin.debug:
msg: "{{ _drush_output }}"
when: drupal.drush_verbose_output
- name: Clear cache before config import.
ansible.builtin.include_role:
name: "cache_clear/cache_clear-{{ project_type }}"
with_items: "{{ drupal.sites }}"
loop_control:
loop_var: site
when:
- drupal.clear_cache_before_config_import | default(false)
- name: Import configuration.
ansible.builtin.command:
cmd: "{{ drush_bin }} -l {{ site.folder }} -y {{ site.config_import_command }}"
chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}"
become: "{{ 'no' if www_user == deploy_user else 'yes' }}"
become_user: "{{ www_user }}"
with_items: "{{ drupal.sites }}"
loop_control:
loop_var: site
when:
- previous_build_number > 0
- site.config_import_command | length > 0
register: _drush_output
- name: Show drush output.
ansible.builtin.debug:
msg: "{{ _drush_output }}"
when: drupal.drush_verbose_output