-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.yml
58 lines (51 loc) · 1.5 KB
/
main.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
- name: Ensure app-frontend volume dir is present
file:
path: '{{ item }}'
state: directory
owner: deploy
group: deploy
mode: '0774'
loop:
- '{{ remote_paths.volumes_path }}/app-frontend'
- name: app-frontend envs are synced
register: app_frontend_env_file
template:
src: '{{ local_paths.envs_dir }}/frontend.env'
dest: '{{ remote_paths.volumes_path }}/app-frontend/frontend.env'
owner: deploy
group: deploy
mode: 0644
- name: Ensure app-frontend.container exists
become_user: deploy
register: app_frontend_container_file
blockinfile:
path: ~/.config/containers/systemd/app-frontend.container
create: true
block: |
[Unit]
Description=The app-frontend container
After=local-fs.target
StartLimitIntervalSec=5
[Container]
Image=0.0.0.0:5000/app-frontend:latest
LogDriver=journald
Label=io.containers.autoupdate=registry
Network=host
Environment=APP_ENV=production
Environment=SERVER_PORT=3002
EnvironmentFile={{ remote_paths.volumes_path }}/app-frontend/frontend.env
[Service]
TimeoutStartSec=15
Restart=always
RestartSec=8
[Install]
WantedBy=default.target
- name: Ensure app-frontend service works
become_user: deploy
ignore_errors: yes
systemd:
scope: user
name: app-frontend
state: '{{ "restarted" if app_frontend_container_file.changed or app_frontend_env_file.changed else "started" }}'
enabled: true
daemon_reload: true