-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathansible_playbook.yml
More file actions
144 lines (122 loc) · 3.78 KB
/
Copy pathansible_playbook.yml
File metadata and controls
144 lines (122 loc) · 3.78 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
138
139
140
141
142
143
144
---
- hosts: localhost
become: true
vars:
project_dir: "/srv/opt/jarm_online"
tasks:
- name: Install aptitude
apt:
name: aptitude
state: latest
update_cache: true
- name: Install required system packages
apt:
pkg:
- apt-transport-https
- bridge-utils
- ca-certificates
- curl
- git
- gnupg
- python3-pip
- virtualenv
- python3-setuptools
state: latest
update_cache: true
- name: get architecture
shell: dpkg --print-architecture
register: deb_architecture
- name: get gpg key
get_url:
url: https://download.docker.com/linux/debian/gpg
dest: /etc/apt/keyrings/docker.asc
mode: 0644
force: true
tags: install_docker
- name: add docker apt repository key.
get_url:
url: https://download.docker.com/linux/debian/gpg
dest: /etc/apt/trusted.gpg.d/docker.asc
mode: 0644
force: true
tags: install_docker
- name: add docker apt repository.
apt_repository:
repo: "deb [arch={{ deb_architecture.stdout }} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
state: present
update_cache: yes
filename: docker
tags: install_docker
- name: install docker and related components
apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
state: latest
update_cache: true
tags: install_docker
- name: restart Docker
systemd:
name: docker
state: restarted
masked: no
tags: install_docker
- name: Clone repo
ansible.builtin.git:
repo: https://github.com/Hugo-C/jarm-online.git
dest: /git/jarm-online
single_branch: true
version: master
update: true
depth: 1
- name: Create project directory
file:
path: "{{ project_dir }}"
state: directory
- name: Copy docker-compose.yml
ansible.builtin.copy:
src: /git/jarm-online/docker-compose.yml.prod # we use the production one
dest: "{{ project_dir }}/docker-compose.yml"
force: false # don't overwrite files
- name: Create nginx directory
file:
path: "{{ project_dir }}/nginx"
state: directory
- name: Create nginx logs directory
file:
path: "{{ project_dir }}/nginx_logs"
state: directory
- name: Copy nginx conf
ansible.builtin.copy:
src: /git/jarm-online/jarm_online_gui/nginx.conf.prod
dest: "{{ project_dir }}/nginx/nginx.conf"
force: false # don't overwrite files
- name: Check that cert file exist
stat:
path: "{{ project_dir }}/nginx/www.hugocjarm.software.pem"
register: cert_result
- name: Remind cert file has to be manually set
fail:
msg: "Warning: {{ project_dir }}/nginx/www.hugocjarm.software.pem and its key has to be manually set"
when: not cert_result.stat.exists
ignore_errors: True
- name: Check that .env file exist
stat:
path: "{{ project_dir }}/.env"
register: env_result
- name: Remind .env file has to be manually set
fail:
msg: "Warning: {{ project_dir }}/.env has to be manually set"
when: not env_result.stat.exists
- name: Start containers
community.docker.docker_compose_v2:
project_src: "{{ project_dir }}"
pull: always
- name: Add logrotate to nginx
ansible.builtin.copy:
src: /git/jarm-online/nginx_log_rotate
dest: "/etc/logrotate.d/nginx"
force: true