ansible/roles/matrix-appservice-discord/tasks/main.yml

70 lines
1.7 KiB
YAML
Raw Normal View History

2019-03-10 11:10:59 +01:00
---
2019-03-29 19:25:11 +01:00
# Create service user
- include_tasks: service_user.yml
2019-03-10 11:10:59 +01:00
- name: "Clone {{ service_name }} project"
2019-03-10 11:10:59 +01:00
git:
repo: "{{ service_repo }}"
dest: "{{ service_path }}"
2019-03-24 17:05:24 +01:00
version: 14cf2829510e8b7b99b3238e2deaddf296ab4b76
2019-03-10 11:10:59 +01:00
become: true
become_user: "{{ service_user }}"
2019-03-10 11:10:59 +01:00
# Setup dependencies
# May create issues with package-lock.json not in gitignore
- name: "Install {{ service_name }} dependencies"
npm:
path: "{{ service_path }}"
2019-03-29 19:25:11 +01:00
production: true
2019-03-10 11:10:59 +01:00
become: true
become_user: "{{ service_user }}"
2019-03-12 16:56:01 +01:00
register: npm_result
retries: 3
until: npm_result is succeeded
2019-03-10 11:10:59 +01:00
# Typescript into javascript
- name: Compile matrix-appservice-discord
command: ./node_modules/.bin/tsc
2019-03-10 11:10:59 +01:00
args:
chdir: "{{ service_path }}"
register: npm_build_result
changed_when: npm_build_result
2019-03-10 11:10:59 +01:00
become: true
become_user: "{{ service_user }}"
2019-03-10 11:10:59 +01:00
- name: "Configure {{ service_name }}"
2019-03-10 11:10:59 +01:00
template:
src: config.yaml.j2
dest: "{{ service_path }}/config.yaml"
owner: "{{ service_user }}"
2019-03-29 19:25:11 +01:00
group: nogroup
2019-03-10 11:10:59 +01:00
mode: 0600
# Service file
- name: "Install {{ service_name }} systemd unit"
2019-03-10 11:10:59 +01:00
template:
src: systemd/appservice.service.j2
dest: "/etc/systemd/system/{{ service_name }}.service"
2019-03-10 11:10:59 +01:00
owner: root
group: root
mode: 0644
2019-03-29 19:25:11 +01:00
# TODO generate registration
- name: Copy appservice registration file
copy:
src: "{{ service_path }}/discord-registration.yaml"
dest: "/etc/matrix-synapse/{{ service_name }}-registration.yaml"
2019-03-29 19:25:11 +01:00
owner: matrix-synapse
group: nogroup
mode: 0600
remote_src: yes
2019-03-10 11:10:59 +01:00
# Run
- name: "Ensure that {{ service_name }} is started"
2019-04-06 15:19:52 +02:00
systemd:
name: "{{ service_name }}"
2019-03-29 19:25:11 +01:00
state: started
enabled: true
2019-04-06 15:19:52 +02:00
daemon_reload: true