-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeploy.yml
107 lines (93 loc) · 2.69 KB
/
deploy.yml
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
---
- name: Deploy Docker Compose application for {{ target_host }}
hosts: "{{ target_host }}"
remote_user: ansibleadmin
pre_tasks:
- name: Check if .env file exists
stat:
path: .env
register: env_file
delegate_to: localhost
vars_files:
- ./group_vars/{{ target_host }}/secrets.yml
tasks:
- name: Ensure destination directory exists
ansible.builtin.file:
path: "{{ service_src_folder }}"
state: directory
mode: 0755
owner: ansibleadmin
group: docker
become: yes
become_user: root
- name: Ensure nginx configurations directory exists
ansible.builtin.file:
path: "{{ service_src_folder }}/nginx-conf"
state: directory
mode: 0755
owner: ansibleadmin
group: docker
become: yes
become_user: root
- name: Ensure logs directory exists
ansible.builtin.file:
path: "{{ service_src_folder }}/logs"
state: directory
mode: 0755
owner: ansibleadmin
group: docker
become: yes
become_user: root
- name: Ensure plugins directory exists
ansible.builtin.file:
path: "{{ service_src_folder }}/plugins"
state: directory
mode: 0755
owner: www-data
group: www-data
become: yes
- name: Copy matomo-plugins folder to remote host
ansible.builtin.synchronize:
src: ./matomo-plugins/
dest: "{{ service_src_folder }}/plugins"
rsync_opts:
- "--no-group"
become: yes
- name: Change ownership of plugins directory
ansible.builtin.file:
path: "{{ service_src_folder }}/plugins"
owner: www-data
group: www-data
recurse: yes
become: yes
- name: Find the list of plugins in matomo-plugins folder
find:
paths: "./matomo-plugins"
recurse: no
file_type: directory
register: matomo_plugins
delegate_to: localhost
- name: Create docker-compose.yml from template
template:
src: docker-compose.yml.j2
dest: "{{ service_src_folder }}/docker-compose.yml"
vars:
MATOMO_PLUGINS: "{{ matomo_plugins }}"
- name: Create matomo.conf from template
template:
src: matomo.conf.j2
dest: "{{ service_src_folder }}/nginx-conf/matomo.conf"
- name: Create db.env from template
template:
src: db.env.j2
dest: "{{ service_src_folder }}/db.env"
- name: Create matomo.env from template
template:
src: matomo.env.j2
dest: "{{ service_src_folder }}/matomo.env"
- name: Copy Matomo PHP config file
template:
src: common.config.ini.php.j2
dest: "{{ service_src_folder }}/common.config.ini.php"
- name: Blue-green matomo container deployment
include_tasks: tasks/blue_green_deploy.yml