-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgregorian.playbook.yaml
120 lines (106 loc) · 3.02 KB
/
gregorian.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
- name: Set up the Greg or Ian web app
hosts: gregorian-server
tasks:
- name: Create the installation dir
ansible.builtin.file:
path: /opt/gregorian
state: directory
owner: gregorian
group: gregorian
mode: 'u=rwx,g=,o='
become: true
- name: Copy over the project files
ansible.builtin.copy:
src: '{{ item }}'
dest: /opt/gregorian
mode: 'u=rwx,g=,o='
loop:
- ./requirements.txt
- ./main.py
- ./index.html
- name: Create the static assets dir
ansible.builtin.file:
path: /opt/gregorian/assets
state: directory
owner: gregorian
group: gregorian
mode: 'u=rwx,g=,o='
become: true
- name: Copy over the static assets
ansible.builtin.copy:
src: './assets/{{ item }}'
dest: /opt/gregorian/assets
mode: 'u=rwx,g=,o='
loop:
- logo.svg
- name: Install python
ansible.builtin.apt:
name:
- python3
- python3-pip
- python3-venv
- python-is-python3
update_cache: true
cache_valid_time: 86400 # One day
become: true
- name: Install the python packages
ansible.builtin.pip:
requirements: /opt/gregorian/requirements.txt
virtualenv: /opt/gregorian/.venv
virtualenv_command: python -m venv
- name: Copy over the systemd service
ansible.builtin.copy:
src: ./gregorian.service
dest: /opt/gregorian/gregorian.service
mode: 'u=rw,g=r,o=r'
- name: Link in the systemd service
ansible.builtin.file:
src: /opt/gregorian/gregorian.service
dest: /etc/systemd/system/gregorian.service
state: link
become: true
- name: Start the Greg or Ian web app
ansible.builtin.systemd:
daemon_reload: true
name: gregorian.service
enabled: true
state: restarted
become: true
- name: Set up the Caddy reverse proxy
hosts: gregorian-server
tasks:
- name: Create the sites directories
ansible.builtin.file:
path: '/etc/caddy/{{item}}'
state: directory
owner: root
group: root
mode: 'u=rwx,g=rx,o=rx'
loop:
- sites-available
- sites-enabled
become: true
- name: Copy over the caddyfile
ansible.builtin.copy:
src: ./gregorian.caddyfile
dest: /etc/caddy/sites-available/
owner: root
group: root
mode: 'u=rw,g=r,o=r'
become: true
- name: Link in the caddyfile to enable it
ansible.builtin.file:
state: link
src: /etc/caddy/sites-available/gregorian.caddyfile
dest: /etc/caddy/sites-enabled/gregorian.caddyfile
owner: root
group: root
mode: 'u=rw,g=r,o=r'
become: true
- name: Reload and restart caddy
ansible.builtin.systemd:
daemon_reload: true
name: caddy.service
enabled: true
state: restarted
become: true