2019-03-10 11:50:07 +01:00
|
|
|
---
|
2019-03-29 19:25:11 +01:00
|
|
|
# Create service user
|
|
|
|
- include_tasks: service_user.yml
|
2019-03-10 11:50:07 +01:00
|
|
|
|
2019-03-30 13:26:20 +01:00
|
|
|
- name: "Clone {{ service_name }} project"
|
2019-03-10 11:50:07 +01:00
|
|
|
git:
|
2019-03-30 13:26:20 +01:00
|
|
|
repo: "{{ service_repo }}"
|
|
|
|
dest: "{{ service_path }}"
|
2019-03-10 11:50:07 +01:00
|
|
|
version: 0.11.2
|
|
|
|
become: true
|
2019-03-30 13:26:20 +01:00
|
|
|
become_user: "{{ service_user }}"
|
2019-03-10 11:50:07 +01:00
|
|
|
|
|
|
|
# Setup dependencies
|
2019-03-30 13:26:20 +01:00
|
|
|
- name: "Install {{ service_name }} dependencies"
|
2019-03-11 17:44:42 +01:00
|
|
|
npm:
|
2019-03-30 13:26:20 +01:00
|
|
|
path: "{{ service_path }}"
|
2019-03-11 17:44:42 +01:00
|
|
|
production: true
|
2019-03-10 11:50:07 +01:00
|
|
|
become: true
|
2019-03-30 13:26:20 +01:00
|
|
|
become_user: "{{ service_user }}"
|
2019-03-11 18:12:55 +01:00
|
|
|
register: npm_result
|
|
|
|
retries: 3
|
|
|
|
until: npm_result is succeeded
|
2019-03-10 11:50:07 +01:00
|
|
|
|
2019-03-30 13:26:20 +01:00
|
|
|
- name: "Configure {{ service_name }}"
|
2019-03-10 11:50:07 +01:00
|
|
|
template:
|
|
|
|
src: config.yaml.j2
|
2019-03-30 13:26:20 +01:00
|
|
|
dest: "{{ service_path }}/config.yaml"
|
|
|
|
owner: "{{ service_user }}"
|
2019-03-29 19:25:11 +01:00
|
|
|
group: nogroup
|
2019-03-10 11:50:07 +01:00
|
|
|
mode: 0600
|
|
|
|
|
|
|
|
# Service file
|
2019-03-30 13:26:20 +01:00
|
|
|
- name: "Install {{ service_name }} systemd unit"
|
2019-03-10 11:50:07 +01:00
|
|
|
template:
|
2019-03-30 13:26:20 +01:00
|
|
|
src: systemd/appservice.service.j2
|
|
|
|
dest: "/etc/systemd/system/{{ service_name }}.service"
|
2019-03-10 11:50:07 +01:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
|
2019-03-29 19:25:11 +01:00
|
|
|
# TODO generate registration
|
2019-05-03 22:50:48 +02:00
|
|
|
# node app.js -r -f irc-registration.yaml \
|
|
|
|
# -u "http://localhost:9999" -c config.yaml -l ircbot
|
2019-03-29 19:25:11 +01:00
|
|
|
|
2019-04-01 18:53:37 +02:00
|
|
|
- name: Copy appservice registration file
|
|
|
|
copy:
|
|
|
|
src: "{{ service_path }}/irc-registration.yaml"
|
|
|
|
dest: "/etc/matrix-synapse/{{ service_name }}-registration.yaml"
|
|
|
|
owner: matrix-synapse
|
|
|
|
group: nogroup
|
|
|
|
mode: 0600
|
2019-05-03 22:50:48 +02:00
|
|
|
remote_src: true
|
2019-03-29 19:25:11 +01:00
|
|
|
|
2019-03-10 11:50:07 +01:00
|
|
|
# Run
|
2019-04-01 18:53:37 +02:00
|
|
|
- name: "Ensure that {{ service_name }} is started"
|
2019-04-06 15:19:52 +02:00
|
|
|
systemd:
|
2019-04-01 18:53:37 +02:00
|
|
|
name: "{{ service_name }}"
|
|
|
|
state: started
|
|
|
|
enabled: true
|
2019-04-06 15:19:52 +02:00
|
|
|
daemon_reload: true
|