main.yml 4.8 KB
Newer Older
1
2
---

3
- name: create ssl cert
4
  command: certbot certonly --email webmaster@archlinux.org --agree-tos --rsa-key-size 4096 --renew-by-default --webroot -w {{ letsencrypt_validation_dir }} -d '{{ matrix_domain }}' creates='/etc/letsencrypt/live/{{ matrix_domain }}/fullchain.pem'
5
  when: 'matrix_domain is defined'
6
7

- name: install packages
8
  pacman: name=python,git,npm,make,jemalloc,gcc,pkgconf,python2
9
10
11
12
13
14
15
16

- name: add synapse group
  group: name=synapse system=yes gid=198

- name: add synapse user
  user: name=synapse system=yes uid=198 group=synapse home=/var/lib/synapse shell=/bin/false createhome=no

- name: create synapse home
17
  file: path={{ item }} state=directory owner=synapse group=synapse mode=0700
18
19
20
21
  with_items:
    - /var/lib/synapse
    - /var/lib/synapse/irc-nedb
    - /var/lib/synapse/media_store
22

23
24
25
26
27
28
29
30
- name: make virtualenv
  command: python -m venv /var/lib/synapse/venv
  args:
    creates: /var/lib/synapse/venv/bin/python
  become: true
  become_user: synapse
  become_method: sudo

31
32
33
34
35
- name: install synapse
  pip:
    name:
      - 'matrix-synapse[postgres,systemd,url_preview]'
      - pip
36
    state: latest
37
38
    extra_args: '-U --upgrade-strategy=eager'
    virtualenv: /var/lib/synapse/venv
39
40
41
  become: yes
  become_user: synapse
  become_method: sudo
42
43
  notify:
    - restart synapse
44

45
- name: download matrix-appservice-irc
46
  git:
47
    repo: https://github.com/matrix-org/matrix-appservice-irc
48
    dest: /var/lib/synapse/matrix-appservice-irc
49
    version: master
50
51
52
  become: yes
  become_user: synapse
  become_method: sudo
53
54
  notify:
    - restart matrix-appservice-irc
55
56

- name: install matrix-appservice-irc
57
58
  npm:
    path: /var/lib/synapse/matrix-appservice-irc
59
60
61
  become: yes
  become_user: synapse
  become_method: sudo
62
63
  notify:
    - restart matrix-appservice-irc
64

65
66
67
68
69
70
71
- name: add synapse postgres db
  postgresql_db: db=synapse
  become: yes
  become_user: postgres
  become_method: su

- name: add synapse postgres user
72
  postgresql_user: db=synapse name=synapse password={{ vault_postgres_users.synapse }} encrypted=true
73
74
75
76
  become: yes
  become_user: postgres
  become_method: su

77
- name: create synapse config dir
78
79
80
81
  file: state=directory path=/etc/synapse owner=root group=synapse mode=0750

- name: install homeserver config
  template: src=homeserver.yaml.j2 dest=/etc/synapse/homeserver.yaml owner=root group=synapse mode=0640
82
83
  notify:
    - restart synapse
84

85
86
87
88
89
90
- name: install static config
  copy: src={{ item }} dest=/etc/synapse/{{ item }} owner=root group=root mode=0644
  with_items:
    - log_config.yaml
    - worker-appservice.yaml
    - worker-federation_sender.yaml
91
    - worker-media_repository.yaml
92
93
  notify:
    - restart synapse
94

95
96
- name: install irc-bridge config
  template: src=irc-bridge.yaml.j2 dest=/etc/synapse/irc-bridge.yaml owner=root group=synapse mode=0640
97
98
  notify:
    - restart matrix-appservice-irc
99
100
101

- name: install irc-bridge registration
  template: src=appservice-registration-irc.yaml.j2 dest=/etc/synapse/appservice-registration-irc.yaml owner=root group=synapse mode=0640
102
103
  notify:
    - restart synapse
104

105
106
- name: install signing key
  copy:
107
    content: '{{ vault_matrix_secrets[matrix_server_name].signing_key }}'
108
109
110
111
112
    dest: /etc/synapse/{{ matrix_server_name }}.signing.key
    owner: root
    group: synapse
    mode: 0640

113
114
- name: install ircpass key
  copy:
115
    content: '{{ vault_matrix_secrets[matrix_server_name].ircpass_key }}'
116
117
118
119
    dest: /etc/synapse/{{ matrix_server_name }}.ircpass.key
    owner: root
    group: synapse
    mode: 0640
120
121
122
123
124
125
126
127

- name: make nginx log dir
  file: path=/var/log/nginx/{{ matrix_domain }} state=directory owner=root group=root mode=0755

- name: set up nginx
  template: src=nginx.d.conf.j2 dest=/etc/nginx/nginx.d/matrix.conf owner=root group=root mode=0644
  notify:
    - reload nginx
128
  when: 'matrix_domain is defined'
129
  tags: ['nginx']
130

131
- name: install synapse units
132
133
134
  copy: src={{ item }} dest=/etc/systemd/system/{{ item }} owner=root group=root mode=0644
  with_items:
    - synapse.service
135
136
137
138
139
140
141
    - synapse-worker@.service
  notify:
    - restart synapse

- name: install matrix-appservice-irc units
  copy: src={{ item }} dest=/etc/systemd/system/{{ item }} owner=root group=root mode=0644
  with_items:
142
    - matrix-appservice-irc.service
143
144
145
146
147
148
149
150
151
  notify:
    - restart matrix-appservice-irc

- name: enable synapse units
  service: name={{ item }} enabled=yes
  with_items:
    - synapse.service
    - synapse-worker@appservice.service
    - synapse-worker@federation_sender.service
152
    - synapse-worker@media_repository.service
153
  notify:
154
    - restart synapse
155
156
157
158
159
160

- name: enable matrix-appservice-irc units
  service: name={{ item }} enabled=yes
  with_items:
    - matrix-appservice-irc.service
  notify:
161
    - restart matrix-appservice-irc
162

163
- name: open firewall holes
164
165
166
  firewalld: port={{ item }} permanent=true state=enabled immediate=yes
  with_items:
    - 113/tcp
167
168
  when: configure_firewall
  tags:
169
    - firewall