diff --git a/roles/hackmd/defaults/main.yml b/roles/hackmd/defaults/main.yml index 64445ac..ca8e06b 100644 --- a/roles/hackmd/defaults/main.yml +++ b/roles/hackmd/defaults/main.yml @@ -1,4 +1,4 @@ --- -hackmd_version: 1.5.0 -hackmd_archive: https://github.com/codimd/server/archive/{{ hackmd_version }}.tar.gz +hackmd_version: 1.7.1 +hackmd_archive: https://github.com/hedgedoc/hedgedoc/archive/{{ hackmd_version }}.tar.gz diff --git a/roles/hackmd/tasks/main.yml b/roles/hackmd/tasks/main.yml index eb875d8..a9aba06 100644 --- a/roles/hackmd/tasks/main.yml +++ b/roles/hackmd/tasks/main.yml @@ -38,34 +38,30 @@ - yarn - name: Unpack hackmd - unarchive: src={{ hackmd_archive }} dest=/opt owner=hackmd group=hackmd remote_src=yes creates=/opt/codimd-{{ hackmd_version }} + unarchive: src={{ hackmd_archive }} dest=/opt owner=hackmd group=hackmd remote_src=yes creates=/opt/hedgedoc-{{ hackmd_version }} register: hackmd_unarchive -- name: Rename hackmd - command: mv /opt/server-{{ hackmd_version }} /opt/codimd-{{ hackmd_version }} - when: hackmd_unarchive.changed - - name: Create hackmd upload path - file: path=/opt/codimd/uploads state=directory recurse=yes owner=hackmd group=hackmd + file: path=/opt/hedgedoc/uploads state=directory recurse=yes owner=hackmd group=hackmd - name: Remove old hackmd upload path - file: path=/opt/codimd-{{ hackmd_version }}/public/uploads state=absent force=yes + file: path=/opt/hedgedoc-{{ hackmd_version }}/public/uploads state=absent force=yes - name: Link hackmd upload path - file: path=/opt/codimd-{{ hackmd_version }}/public/uploads src=/opt/codimd/uploads state=link owner=hackmd group=hackmd + file: path=/opt/hedgedoc-{{ hackmd_version }}/public/uploads src=/opt/hedgedoc/uploads state=link owner=hackmd group=hackmd - name: Setup hackmd - command: bin/setup chdir=/opt/codimd-{{ hackmd_version }} creates=/opt/codimd-{{ hackmd_version }}/config.json + command: bin/setup chdir=/opt/hedgedoc-{{ hackmd_version }} creates=/opt/hedgedoc-{{ hackmd_version }}/config.json become: true become_user: hackmd - name: Configure hackmd - template: src=config.json.j2 dest=/opt/codimd-{{ hackmd_version }}/config.json owner=hackmd + template: src=config.json.j2 dest=/opt/hedgedoc-{{ hackmd_version }}/config.json owner=hackmd register: hackmd_config notify: Restart hackmd - name: Build hackmd frontend - command: /usr/bin/npm run build chdir=/opt/codimd-{{ hackmd_version }} + command: /usr/bin/yarn run build chdir=/opt/hedgedoc-{{ hackmd_version }} become: true become_user: hackmd when: hackmd_unarchive.changed or hackmd_config.changed @@ -81,10 +77,10 @@ become_user: postgres - name: Configure sequelize - template: src=_sequelizerc.j2 dest=/opt/codimd-{{ hackmd_version }}/.sequelizerc owner=hackmd + template: src=_sequelizerc.j2 dest=/opt/hedgedoc-{{ hackmd_version }}/.sequelizerc owner=hackmd - name: Upgrade database schema - command: node_modules/.bin/sequelize db:migrate chdir=/opt/codimd-{{ hackmd_version }} + command: node_modules/.bin/sequelize db:migrate chdir=/opt/hedgedoc-{{ hackmd_version }} become: true become_user: hackmd when: hackmd_unarchive.changed or hackmd_config.changed diff --git a/roles/hackmd/templates/hackmd.service.j2 b/roles/hackmd/templates/hackmd.service.j2 index 3cb89a6..86f7f44 100644 --- a/roles/hackmd/templates/hackmd.service.j2 +++ b/roles/hackmd/templates/hackmd.service.j2 @@ -4,10 +4,10 @@ After=network.target [Service] Environment=NODE_ENV=production -WorkingDirectory=/opt/codimd-{{ hackmd_version }} +WorkingDirectory=/opt/hedgedoc-{{ hackmd_version }} Type=simple User=hackmd -ExecStart=/usr/bin/node /opt/codimd-{{ hackmd_version }}/app.js +ExecStart=/usr/bin/node /opt/hedgedoc-{{ hackmd_version }}/app.js Restart=on-failure [Install] diff --git a/roles/hackmd/templates/vhost.j2 b/roles/hackmd/templates/vhost.j2 index c767857..4ce37e9 100644 --- a/roles/hackmd/templates/vhost.j2 +++ b/roles/hackmd/templates/vhost.j2 @@ -1,3 +1,8 @@ +map $http_upgrade $connection_upgrade { + default upgrade; + '' close; +} + server { listen 80; listen [::]:80; @@ -27,12 +32,21 @@ server { client_max_body_size 8M; location / { + proxy_pass http://localhost:3000; + proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_pass http://localhost:3000; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "Upgrade"; + proxy_set_header X-Forwarded-Proto $scheme; } + + location /socket.io/ { + proxy_pass http://127.0.0.1:3000; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + } }