ansible/roles/matrix-appservice-discord/tasks/main.yml
2019-05-03 22:50:48 +02:00

69 lines
1.7 KiB
YAML

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