ansible/roles/codimd/tasks/main.yml

61 lines
1.3 KiB
YAML
Raw Normal View History

2019-02-07 13:37:11 +01:00
---
# Install APT dependencies
- include_tasks: 0_apt_dependencies.yml
2019-03-30 13:34:25 +01:00
# Create service user
- include_tasks: service_user.yml
2019-02-07 13:37:11 +01:00
2019-03-30 13:34:25 +01:00
- name: "Clone {{ service_name }} project"
2019-03-04 15:08:05 +01:00
git:
2019-03-30 13:34:25 +01:00
repo: "{{ service_repo }}"
dest: "{{ service_path }}"
2019-03-04 15:08:05 +01:00
version: 1.3.0
become: true
2019-03-30 13:34:25 +01:00
become_user: "{{ service_user }}"
2019-03-04 15:08:05 +01:00
notify: Build front-end for CodiMD
2019-02-07 13:37:11 +01:00
2019-03-30 13:34:25 +01:00
# Setup dependencies
- name: "Install {{ service_name }} dependencies"
2019-03-11 17:49:48 +01:00
yarn:
2019-03-30 13:34:25 +01:00
path: "{{ service_path }}"
2019-03-11 17:49:48 +01:00
production: true
2019-03-03 09:16:52 +01:00
become: true
2019-03-30 13:34:25 +01:00
become_user: "{{ service_user }}"
2019-03-11 18:12:55 +01:00
register: yarn_result
retries: 3
until: yarn_result is succeeded
2019-02-07 13:37:11 +01:00
# Connection to database
2019-02-09 08:07:10 +01:00
- name: Connect CodiMD to PostgreSQL db
2019-02-07 13:37:11 +01:00
template:
2019-02-09 10:02:53 +01:00
src: sequelizerc.j2
2019-03-30 13:34:25 +01:00
dest: "{{ service_path }}/.sequelizerc"
owner: "{{ service_user }}"
group: nogroup
2019-02-07 13:37:11 +01:00
mode: 0600
2019-03-30 13:34:25 +01:00
- name: "Configure {{ service_name }}"
2019-02-09 10:02:53 +01:00
template:
src: config.json.j2
2019-03-30 13:34:25 +01:00
dest: "{{ service_path }}/config.json"
owner: "{{ service_user }}"
group: nogroup
2019-02-09 10:02:53 +01:00
mode: 0600
# Service file
2019-03-30 13:34:25 +01:00
- name: "Install {{ service_name }} systemd unit"
2019-02-09 10:02:53 +01:00
template:
src: systemd/codimd.service.j2
2019-03-30 13:34:25 +01:00
dest: "/etc/systemd/system/{{ service_name }}.service"
2019-02-09 10:02:53 +01:00
owner: root
group: root
mode: 0644
2019-02-09 09:29:14 +01:00
2019-02-09 10:02:53 +01:00
# Run
2019-03-30 13:34:25 +01:00
- name: "Ensure that {{ service_name }} is started"
2019-04-06 15:19:52 +02:00
systemd:
2019-03-30 13:34:25 +01:00
name: "{{ service_name }}"
2019-02-09 10:02:53 +01:00
state: started
enabled: true
2019-04-06 15:19:52 +02:00
daemon_reload: true