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

3
- name: create ssl cert
4
5
6
7
  include_role:
    name: certificate
  vars:
    domains: ["{{ matrix_domain }}"]
8
  when: 'matrix_domain is defined'
9
10

- name: install packages
11
12
  pacman:
    name:
13
      - coturn
14
15
16
17
18
      - freetype2
      - gcc
      - git
      - jemalloc
      - libffi
19
      - libjpeg-turbo
20
21
22
23
24
25
26
27
28
29
30
      - libtiff
      - libwebp
      - libxslt
      - libzip
      - make
      - npm
      - openssl
      - pkgconf
      - postgresql-libs
      - python
      - python2
31
      - redis
32
33
34
      - tcl
      - tk
      - zlib
35
36
37
38
39
40
41
42

- 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
43
  file: path={{ item }} state=directory owner=synapse group=synapse mode=0700
44
45
46
  with_items:
    - /var/lib/synapse
    - /var/lib/synapse/media_store
47

48
49
50
51
52
53
54
55
- 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

56
57
58
- name: install synapse
  pip:
    name:
59
      - 'matrix-synapse[postgres,systemd,url_preview,redis]'
60
      - pip
61
    state: latest
62
63
    extra_args: '-U --upgrade-strategy=eager'
    virtualenv: /var/lib/synapse/venv
64
65
66
  become: yes
  become_user: synapse
  become_method: sudo
67
68
  notify:
    - restart synapse
69

70
- name: download matrix-appservice-irc
71
  git:
72
    repo: https://github.com/matrix-org/matrix-appservice-irc
73
    dest: /var/lib/synapse/matrix-appservice-irc
74
    version: master
75
76
77
  become: yes
  become_user: synapse
  become_method: sudo
78
79
  notify:
    - restart matrix-appservice-irc
80
81

- name: install matrix-appservice-irc
82
83
  npm:
    path: /var/lib/synapse/matrix-appservice-irc
84
85
86
  become: yes
  become_user: synapse
  become_method: sudo
87
88
  notify:
    - restart matrix-appservice-irc
89

90
91
92
93
94
- name: install pg_hba.conf
  copy: src=pg_hba.conf dest=/var/lib/postgres/data/pg_hba.conf owner=postgres group=postgres mode=0600
  notify:
    - restart postgres

95
96
97
98
99
100
101
- name: add synapse postgres db
  postgresql_db: db=synapse
  become: yes
  become_user: postgres
  become_method: su

- name: add synapse postgres user
102
103
104
105
106
107
108
  postgresql_user: db=synapse user=synapse password={{ vault_postgres_users.synapse }}
  become: yes
  become_user: postgres
  become_method: su

- name: add irc postgres db
  postgresql_db: db=irc
109
110
111
112
  become: yes
  become_user: postgres
  become_method: su

113
- name: create synapse config dir
114
115
116
117
  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
118
119
  notify:
    - restart synapse
120

121
122
123
124
125
- 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
126
    - worker-federation_reader.yaml
127
    - worker-federation_sender.yaml
128
    - worker-media_repository.yaml
129
130
  notify:
    - restart synapse
131

132
133
- name: install irc-bridge config
  template: src=irc-bridge.yaml.j2 dest=/etc/synapse/irc-bridge.yaml owner=root group=synapse mode=0640
134
135
  notify:
    - restart matrix-appservice-irc
136
137
138

- 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
139
140
  notify:
    - restart synapse
141

142
143
- name: install signing key
  copy:
144
    content: '{{ vault_matrix_secrets.signing_key }}'
145
146
147
148
149
    dest: /etc/synapse/{{ matrix_server_name }}.signing.key
    owner: root
    group: synapse
    mode: 0640

150
151
- name: install ircpass key
  copy:
152
    content: '{{ vault_matrix_secrets.ircpass_key }}'
153
154
155
156
    dest: /etc/synapse/{{ matrix_server_name }}.ircpass.key
    owner: root
    group: synapse
    mode: 0640
157
158
159
160
161
162
163
164

- 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
165
  when: 'matrix_domain is defined'
166
  tags: ['nginx']
167

168
- name: install turnserver.conf
169
  template: src=turnserver.conf.j2 dest=/etc/turnserver/turnserver.conf owner=turnserver group=turnserver mode=0600
170
171
172
173
174
175
  notify:
    - restart turnserver

- name: install turnserver cert renewal hook
  copy: src=letsencrypt.hook.d dest=/etc/letsencrypt/hook.d/turnserver owner=root group=root mode=0755

176
- name: install synapse units
177
178
179
  copy: src={{ item }} dest=/etc/systemd/system/{{ item }} owner=root group=root mode=0644
  with_items:
    - synapse.service
180
181
182
183
184
185
186
    - 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:
187
    - matrix-appservice-irc.service
188
189
190
  notify:
    - restart matrix-appservice-irc

191
192
193
194
195
196
197
- name: install turnserver units
  copy: src={{ item }} dest=/etc/systemd/system/{{ item }} owner=root group=root mode=0644
  with_items:
    - turnserver.service
  notify:
    - restart turnserver

198
199
200
201
202
- name: enable synapse units
  service: name={{ item }} enabled=yes
  with_items:
    - synapse.service
    - synapse-worker@appservice.service
203
    - synapse-worker@federation_reader.service
204
    - synapse-worker@federation_sender.service
205
    - synapse-worker@media_repository.service
206
  notify:
207
    - restart synapse
208
209
210
211
212
213

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

216
217
218
219
220
221
222
- name: enable turnserver units
  service: name={{ item }} enabled=yes
  with_items:
    - turnserver.service
  notify:
    - restart turnserver

223
- name: open firewall holes
224
  ansible.posix.firewalld: port={{ item }} permanent=true state=enabled immediate=yes
225
  with_items:
226
    # synapse's identd
227
    - 113/tcp
228
229
230
231
232
233
    # turnserver
    - 3478-3479/tcp
    - 3478-3479/udp
    - 5349-5350/tcp
    - 5349-5350/udp
    - 33000-33999/udp
234
235
  when: configure_firewall
  tags:
236
    - firewall