aboutsummaryrefslogtreecommitdiffstats
path: root/playbooks/webserver_public_example.yml
blob: d9cb468f1a61aef9b5cd2438531aa3339dbfa028 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
- name: configure public web server
  hosts: dmz-www1
  roles:
    - role: common
      tags: common

    - role: apache_vhost
      apache_server_name: www.example.com
      apache_server_aliases: [example.com]
      apache_canonical_hostname: www.example.com
      apache_letsencrypt: yes
      apache_document_root: /var/www/www.example.com
      apache_config: |
        Alias /.well-known/matrix /var/www/well-known/example.com/matrix
      tags: apache

    - role: archive_job
      archive_name: www
      archive_shell: >-
        TIMESTAMP=$(date +%Y%m%d%H%M%S);
        tar czf "www-${TIMESTAMP}.tar.gz"
        --transform "s|^\.|www-${TIMESTAMP}|"
        -C "{{ apache_public_dir }}" {% for dir in apache_backup_dirs %}{{ dir | quote }} {% endfor %}
      tags: archive

    # prosody letsencrypt proxy
    - role: prosody_letsencrypt_proxy
      prosody_le_role: master
      tags: prosody

  tasks:
    - name: create webroot
      file:
        path: /var/www/www.example.com
        state: directory
        owner: root
        group: webmasters
        mode: 02770
      tags: apache

    - name: create well-known directories
      file:
        path: '/var/www/well-known/{{ item }}'
        state: directory
        recurse: yes
      loop:
        - example.com/matrix
      tags: apache

    - name: create .well-known/matrix/server for example.com
      copy:
        content: '{"m.server": "matrix.example.com:8448"}'
        dest: /var/www/well-known/example.com/matrix/server
      tags: apache

    - name: create .well-known/matrix/client for example.com
      copy:
        content: '{"m.homeserver": {"base_url": "https://matrix.example.com:8443"}}'
        dest: /var/www/well-known/example.com/matrix/client
      tags: apache