forked from EcrituresNumeriques/stylo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybook.yml
147 lines (126 loc) · 3.83 KB
/
playbook.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
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
138
139
140
141
142
143
144
145
146
147
---
- hosts: stylo
tasks:
- name: Set application version
ansible.builtin.set_fact: app_version="{{ app_version | default('latest') }}"
- name: Install aptitude
become: yes
ansible.builtin.apt:
name: aptitude
state: latest
update_cache: true
- name: Install required system packages
become: yes
ansible.builtin.apt:
name:
- ca-certificates
- curl
- gnupg
- lsb-release
state: latest
update_cache: true
- name: Add Docker GPG apt Key
become: yes
ansible.builtin.apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker Repository
become: yes
ansible.builtin.apt_repository:
repo: deb https://download.docker.com/linux/ubuntu bionic stable
state: present
- name: Update apt and install docker-ce
become: yes
ansible.builtin.apt:
name:
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
state: latest
update_cache: true
- name: Update NGINX settings
become: yes
ansible.builtin.copy:
src: ./{{ item.name }}.conf
dest: /etc/nginx/sites-enabled/{{ item.name }}.conf
with_items:
- { name: "{{ site }}" }
- { name: "pandoc-api.{{ site }}" }
- { name: "export.{{ site }}" }
notify: reload nginx
- name: Update NGINX settings
become: yes
ansible.builtin.copy:
src: ./stylo.ecrituresnumeriques.ca.conf
dest: /etc/nginx/sites-enabled/stylo.ecrituresnumeriques.ca.conf
when: site == "stylo.huma-num.fr"
notify: reload nginx
- name: Prune Docker images
become: yes
ansible.builtin.shell:
cmd: "docker image prune -af"
run_once: true
- name: Prune Docker system
become: yes
ansible.builtin.shell:
cmd: "docker system prune -af"
run_once: true
- name: Copy systemd service file
become: yes
ansible.builtin.copy:
src: ./docker-compose-stylo.service
dest: /etc/systemd/system/docker-compose-stylo.service
notify: start docker-compose-stylo
- name: Copy Nagios configuration
become: yes
ansible.builtin.copy:
src: ./{{ env }}-nagios-nrpe-local.cfg
dest: /etc/nagios/nrpe_local.cfg
- name: Copy config files
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
loop:
- { src: "./.env", dest: "~/stylo/.env" }
- { src: "./docker-compose.yaml", dest: "~/stylo/docker-compose.yaml" }
- name: Pull Docker containers
ansible.builtin.shell:
cmd: "docker compose pull"
chdir: ~/stylo
- name: Generate Shared GraphQL Token
register: graphql_token
ansible.builtin.shell:
cmd: "docker compose run --no-deps --rm graphql-stylo npm run generate-service-token --silent"
chdir: ~/stylo
run_once: true
no_log: true
- set_fact:
"se_graphql_token": "{{ graphql_token.stdout }}"
- name: Update config files
ansible.builtin.template:
src: "./.env"
dest: "~/stylo/.env"
- name: Copy frontend assets files
ansible.posix.synchronize:
src: "{{ assets_path }}"
dest: "~/stylo/front-assets/"
delete: true
- name: Restart containers
become: true
ansible.builtin.systemd:
name: docker-compose-stylo
state: restarted
daemon_reload: true
handlers:
- name: reload nginx
become: true
service:
name: nginx
state: reloaded
- name: start docker-compose-stylo
become: true
ansible.builtin.systemd:
name: docker-compose-stylo
state: started
enabled: yes