main.yml 4.25 KB
Newer Older
1
2
3
4
5
6
7
---

- stat: path="/etc/letsencrypt/live/{{ matrix_domain }}/fullchain.pem"
  register: certfile
  when: 'matrix_domain != ""'

- name: install packages
8
  pacman: name=python2-virtualenv,git,npm
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
18
19
20
21
22
  file: path={{ item }} state=directory owner=synapse group=synapse mode=0755
  with_items:
    - /var/lib/synapse
    - /var/lib/synapse/irc-nedb
    - /var/lib/synapse/media_store
    - /var/lib/synapse/uploads
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

- name: create venv
  command: virtualenv2 /var/lib/synapse/venv
  args:
    creates: /var/lib/synapse/venv/bin/python
  become: yes
  become_user: synapse
  become_method: sudo

- name: download synapse
  command: git clone https://github.com/matrix-org/synapse /var/lib/synapse/synapse
  args:
    creates: /var/lib/synapse/synapse/setup.py
  become: yes
  become_user: synapse
  become_method: sudo

40
41
42
43
44
45
46
47
- name: download matrix-appservice-irc
  command: git clone https://github.com/heftig/matrix-appservice-irc /var/lib/synapse/matrix-appservice-irc
  args:
    creates: /var/lib/synapse/matrix-appservice-irc/package.json
  become: yes
  become_user: synapse
  become_method: sudo

48
49
50
51
52
53
54
55
- name: install synapse
  command: /var/lib/synapse/venv/bin/pip install -e /var/lib/synapse/synapse psycopg2 systemd-python lxml
  args:
    creates: /var/lib/synapse/venv/bin/synctl
  become: yes
  become_user: synapse
  become_method: sudo

56
57
58
59
60
61
62
63
64
- name: install matrix-appservice-irc
  command: npm install
  args:
    chdir: /var/lib/synapse/matrix-appservice-irc
    creates: /var/lib/synapse/matrix-appservice-irc/node_modules
  become: yes
  become_user: synapse
  become_method: sudo

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

- name: add synapse postgres user
  postgresql_user: db=synapse name=synapse password={{ postgres_users.synapse }}
  become: yes
  become_user: postgres
  become_method: su

77
- name: create synapse config dir
78
79
80
81
82
83
84
85
  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

- name: install log config
  copy: src=log_config.yaml dest=/etc/synapse/log_config.yaml owner=root group=root mode=0644

86
87
88
89
90
91
- name: install irc-bridge config
  template: src=irc-bridge.yaml.j2 dest=/etc/synapse/irc-bridge.yaml owner=root group=synapse mode=0640

- 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

92
93
- name: install federation certificate
  copy:
94
    content: '{{ matrix_secrets[matrix_server_name].federation_crt }}'
95
96
    dest: /etc/synapse/{{ matrix_server_name }}.tls.crt
    owner: root
97
98
    group: root
    mode: 0644
99
100
101

- name: install federation key
  copy:
102
    content: '{{ matrix_secrets[matrix_server_name].federation_key }}'
103
104
105
106
107
108
109
    dest: /etc/synapse/{{ matrix_server_name }}.tls.key
    owner: root
    group: synapse
    mode: 0640

- name: install signing key
  copy:
110
    content: '{{ matrix_secrets[matrix_server_name].signing_key }}'
111
112
113
114
115
    dest: /etc/synapse/{{ matrix_server_name }}.signing.key
    owner: root
    group: synapse
    mode: 0640

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

- 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
  when: 'matrix_domain != ""'
132
133
134
135
136
137
138
139
140
141
142
143
144
145

- name: install matrix units
  copy: src={{ item }} dest=/etc/systemd/system/{{ item }} owner=root group=root mode=0644
  with_items:
    - synapse.service
    - matrix-appservice-irc.service
  notify:
    - daemon reload

- name: start and enable synapse
  service: name={{ item }} enabled=yes state=started
  with_items:
    - synapse.service
    - matrix-appservice-irc.service