2018-04-09 21:28:36 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Create user
|
|
|
|
user: name=hackmd
|
|
|
|
|
|
|
|
- name: Enable https for apt
|
|
|
|
apt: name=apt-transport-https
|
|
|
|
|
|
|
|
- name: Enable nodesource apt-key
|
2019-07-23 12:00:59 +02:00
|
|
|
apt_key: url="https://deb.nodesource.com/gpgkey/nodesource.gpg.key"
|
2018-04-09 21:28:36 +02:00
|
|
|
|
|
|
|
- name: Enable nodesource repository
|
2021-05-11 17:04:32 +02:00
|
|
|
apt_repository: repo="deb https://deb.nodesource.com/node_14.x/ {{ ansible_distribution_release }} main"
|
2018-04-09 21:28:36 +02:00
|
|
|
|
2019-09-18 13:08:08 +02:00
|
|
|
- name: Enable yarnpkg apt-key
|
|
|
|
apt_key: url="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
|
|
|
|
|
|
|
- name: Enable yarnpkg repository
|
|
|
|
apt_repository: repo="deb https://dl.yarnpkg.com/debian/ stable main"
|
|
|
|
|
|
|
|
- name: Pin nodejs repository
|
|
|
|
blockinfile:
|
|
|
|
path: /etc/apt/preferences.d/nodejs
|
|
|
|
create: yes
|
|
|
|
block: |
|
|
|
|
Package: *
|
|
|
|
Pin: origin deb.nodesource.com
|
|
|
|
Pin-Priority: 600
|
|
|
|
|
2018-04-09 21:28:36 +02:00
|
|
|
- name: Install packages
|
2020-11-13 18:29:32 +01:00
|
|
|
apt:
|
|
|
|
name:
|
|
|
|
- build-essential
|
|
|
|
- git
|
|
|
|
- nodejs
|
|
|
|
- postgresql
|
|
|
|
- python-psycopg2
|
|
|
|
- yarn
|
2018-04-09 21:28:36 +02:00
|
|
|
|
|
|
|
- name: Unpack hackmd
|
2020-12-28 17:53:02 +01:00
|
|
|
unarchive: src={{ hackmd_archive }} dest=/opt owner=hackmd group=hackmd remote_src=yes creates=/opt/hedgedoc-{{ hackmd_version }}
|
2018-04-09 21:28:36 +02:00
|
|
|
register: hackmd_unarchive
|
|
|
|
|
2018-10-15 18:46:34 +02:00
|
|
|
- name: Create hackmd upload path
|
2020-12-28 17:53:02 +01:00
|
|
|
file: path=/opt/hedgedoc/uploads state=directory recurse=yes owner=hackmd group=hackmd
|
2018-10-15 18:46:34 +02:00
|
|
|
|
2019-09-06 16:17:34 +02:00
|
|
|
- name: Remove old hackmd upload path
|
2020-12-28 17:53:02 +01:00
|
|
|
file: path=/opt/hedgedoc-{{ hackmd_version }}/public/uploads state=absent force=yes
|
2019-09-06 16:17:34 +02:00
|
|
|
|
2018-10-15 18:46:34 +02:00
|
|
|
- name: Link hackmd upload path
|
2020-12-28 17:53:02 +01:00
|
|
|
file: path=/opt/hedgedoc-{{ hackmd_version }}/public/uploads src=/opt/hedgedoc/uploads state=link owner=hackmd group=hackmd
|
2018-10-15 18:46:34 +02:00
|
|
|
|
2018-04-09 21:28:36 +02:00
|
|
|
- name: Setup hackmd
|
2020-12-28 17:53:02 +01:00
|
|
|
command: bin/setup chdir=/opt/hedgedoc-{{ hackmd_version }} creates=/opt/hedgedoc-{{ hackmd_version }}/config.json
|
2018-04-09 21:28:36 +02:00
|
|
|
become: true
|
|
|
|
become_user: hackmd
|
|
|
|
|
|
|
|
- name: Configure hackmd
|
2020-12-28 17:53:02 +01:00
|
|
|
template: src=config.json.j2 dest=/opt/hedgedoc-{{ hackmd_version }}/config.json owner=hackmd
|
2018-04-09 21:28:36 +02:00
|
|
|
register: hackmd_config
|
2018-09-20 22:57:51 +02:00
|
|
|
notify: Restart hackmd
|
2018-04-09 21:28:36 +02:00
|
|
|
|
2021-05-11 17:04:32 +02:00
|
|
|
- name: Install hackmd frontend deps
|
|
|
|
command: /usr/bin/yarn install chdir=/opt/hedgedoc-{{ hackmd_version }}
|
|
|
|
become: true
|
|
|
|
become_user: hackmd
|
|
|
|
when: hackmd_unarchive.changed or hackmd_config.changed
|
|
|
|
|
2018-04-09 21:28:36 +02:00
|
|
|
- name: Build hackmd frontend
|
2021-05-11 17:04:32 +02:00
|
|
|
command: /usr/bin/yarn build chdir=/opt/hedgedoc-{{ hackmd_version }}
|
2018-04-09 21:28:36 +02:00
|
|
|
become: true
|
|
|
|
become_user: hackmd
|
2018-10-08 21:46:29 +02:00
|
|
|
when: hackmd_unarchive.changed or hackmd_config.changed
|
2018-04-09 21:28:36 +02:00
|
|
|
|
|
|
|
- name: Configure PostgreSQL database
|
|
|
|
postgresql_db: name={{ hackmd_dbname }}
|
|
|
|
become: true
|
|
|
|
become_user: postgres
|
|
|
|
|
|
|
|
- name: Configure PostgreSQL user
|
|
|
|
postgresql_user: db={{ hackmd_dbname }} name={{ hackmd_dbuser }} password={{ hackmd_dbpass }} priv=ALL state=present
|
|
|
|
become: true
|
|
|
|
become_user: postgres
|
|
|
|
|
|
|
|
- name: Ensure certificates are available
|
|
|
|
command: openssl req -x509 -nodes -newkey rsa:2048 -keyout /etc/nginx/ssl/{{ hackmd_domain }}.key -out /etc/nginx/ssl/{{ hackmd_domain }}.crt -days 730 -subj "/CN={{ hackmd_domain }}" creates=/etc/nginx/ssl/{{ hackmd_domain }}.crt
|
|
|
|
notify: Restart nginx
|
|
|
|
|
|
|
|
- name: Configure certificate manager for hackmd
|
2019-05-20 19:49:08 +02:00
|
|
|
template: src=certs.j2 dest=/etc/acertmgr/{{ hackmd_domain }}.conf
|
2019-02-23 23:54:24 +01:00
|
|
|
notify: Run acertmgr
|
2018-04-09 21:28:36 +02:00
|
|
|
|
|
|
|
- name: Configure vhost
|
|
|
|
template: src=vhost.j2 dest=/etc/nginx/sites-available/hackmd
|
|
|
|
notify: Restart nginx
|
|
|
|
|
|
|
|
- name: Enable vhost
|
|
|
|
file: src=/etc/nginx/sites-available/hackmd dest=/etc/nginx/sites-enabled/hackmd state=link
|
|
|
|
notify: Restart nginx
|
|
|
|
|
|
|
|
- name: Systemd unit for hackmd
|
|
|
|
template: src=hackmd.service.j2 dest=/etc/systemd/system/hackmd.service
|
|
|
|
notify:
|
|
|
|
- Reload systemd
|
|
|
|
- Restart hackmd
|
|
|
|
|
|
|
|
- name: Start the hackmd service
|
|
|
|
service: name=hackmd state=started enabled=yes
|