summaryrefslogtreecommitdiff
path: root/website.yaml
blob: 818fa8196fe3bcc78a819793f2c968c912daddf3 (plain)
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
---
- name: Setup website
  hosts: raspberry
  tasks:
     - name: Install packages
       become: true
       tags:
       - slow
       apt:
         pkg:
         - nginx
         - certbot
         - python3-certbot-nginx

     - name: Copy nginx configuration
       become: true
       copy:
         src: ./files/nginx/website
         dest: /etc/nginx/sites-available

     - name: Enable website
       become: true
       command: "ln -sf /etc/nginx/sites-available/website /etc/nginx/sites-enabled"

     - name: Install SSL certificate
       become: true
       shell: "certbot --nginx --non-interactive --agree-tos -m eugene@eug-vs.xyz -d eug-vs.xyz -d www.eug-vs.xyz"

     - name: Allow user to write to website location
       become: true
       shell: |
         mkdir -p /var/www/website
         chown -R eug-vs:eug-vs /var/www/website

     - name: Restart and enable nginx
       become: true
       systemd:
         name: nginx
         enabled: yes
         state: restarted