This repository has been archived by the owner on Dec 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook.yaml
163 lines (147 loc) · 3.53 KB
/
playbook.yaml
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
---
- hosts: vps
roles:
- role: hifis.unattended_upgrades
unattended_automatic_reboot: true
unattended_automatic_reboot_time: "07:00"
unattended_remove_unused_dependencies: true
unattended_remove_new_unused_dependencies: true
become: true
tags:
- setup
tasks:
- name: Install required system packages for docker
become: true
tags:
- setup
apt:
pkg:
- apt-transport-https
- ca-certificates
- curl
- software-properties-common
state: latest
update_cache: true
- name: Add Docker GPG apt Key
become: true
tags:
- setup
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker Repository
become: true
tags:
- setup
apt_repository:
repo: deb https://download.docker.com/linux/ubuntu jammy stable
state: present
- name: Update apt and install docker-ce
become: true
tags:
- setup
apt:
pkg:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-compose-plugin
state: latest
update_cache: true
- name: Increase SSH timeout
tags:
- setup
become: true
blockinfile:
path: "/etc/ssh/sshd_config"
block: |
ClientAliveInterval 1200
ClientAliveCountMax 3
PubkeyAuthentication yes
PasswordAuthentication no
PermitRootLogin prohibit-password
PermitEmptyPasswords no
- name: Restart ssh
tags:
- setup
become: true
service:
name: ssh
state: restarted
- name: Allow everything and enable UFW
become: true
community.general.ufw:
state: enabled
policy: allow
- name: Allow all outgoing
become: true
tags:
- setup
community.general.ufw:
state: enabled
policy: allow
direction: outgoing
- name: Allow all access to tcp port 22
become: true
tags:
- setup
community.general.ufw:
rule: allow
port: "22"
proto: tcp
- name: Allow all access to tcp port 80
become: true
tags:
- setup
community.general.ufw:
rule: allow
port: "80"
proto: tcp
- name: Allow all access to tcp port 443
become: true
tags:
- setup
community.general.ufw:
rule: allow
port: "443"
proto: tcp
- name: Disable all incoming
become: true
tags:
- setup
community.general.ufw:
state: enabled
policy: deny
direction: incoming
- name: Create stacks directory
tags:
- setup
- stacks
file:
state: directory
path: "{{ stacks.dest }}"
- name: Copy stacks to VPS
tags:
- setup
- stacks
- create
- deploy
copy:
src: "{{ playbook_dir }}/stacks"
dest: "{{ stacks.dest }}"
decrypt: true
- name: Create docker network
tags:
- stacks
- setup
shell:
cmd: "docker network create --driver bridge selfhost"
ignore_errors: true
- name: Start services
tags:
- stacks
- deploy
shell:
cmd: "docker compose -f docker-compose.yaml up --build -d --force-recreate"
chdir: "{{ stacks.dest }}/stacks/{{ item.dir }}"
loop: "{{ stacks.order }}"