[BREAKING] Rename to hedgedoc, remove saml, update config vars

* Use already build version by hedgedoc team
* SAML options should be set in additional config
* config varaibles are now starting with hedgedoc
  * `hedgedoc_version` is added and required by now
main
Leo Maroni 2 years ago
parent 9206a004ac
commit 4070945091
Signed by: em0lar
GPG Key ID: B1ADA545CD2CBACD
  1. 47
      defaults/main.yml
  2. 4
      handlers/main.yml
  3. 14
      tasks/build.yml
  4. 16
      tasks/config.yml
  5. 37
      tasks/install.yml
  6. 76
      tasks/main.yml
  7. 4
      templates/.sequelizerc.j2
  8. 56
      templates/config.json.j2
  9. 10
      templates/hedgedoc.service

@ -1,21 +1,26 @@
codimd_source: https://static.labcode.de/build/codimd/codimd-normal-1.6.0.tar.gz
codimd_temp_path: /tmp/codimd.tar.gz
codimd_base_path: /opt/codimd
codimd_build: false
codimd_user: codimd
codimd_group: codimd
codimd_db_dialect: postgres
codimd_db_host: localhost
codimd_db_database: codimd
codimd_db_port: 5432
codimd_db_username: codimd
codimd_config_template_path: config.json.j2
codimd_allow_email_login: true
codimd_allow_email_register: true
codimd_allow_free_url: true
codimd_allow_anonymous_edits: true
codimd_allow_anonymous: true
codimd_csp_enable: true
codimd_hsts_enable: true
codimd_allow_pdf_export: true
codimd_upload_type: "filesystem"
hedgedoc_version: 1.7.0-rc1
hedgedoc_source: https://github.com/hedgedoc/hedgedoc/releases/download/{{ hedgedoc_version }}/hedgedoc-{{ hedgedoc_version }}.tar.gz
hedgedoc_base_path: /opt/hedgedoc
hedgedoc_user: hedgedoc
hedgedoc_group: hedgedoc
hedgedoc_db_dialect: postgres
hedgedoc_db_host: localhost
hedgedoc_db_database: hedgedoc
hedgedoc_db_port: 5432
hedgedoc_db_username: hedgedoc
hedgedoc_config_template_path: config.json.j2
hedgedoc_allow_email_login: true
hedgedoc_allow_email_register: true
hedgedoc_allow_free_url: true
hedgedoc_allow_anonymous_edits: true
hedgedoc_allow_anonymous: true
hedgedoc_csp_enable: true
hedgedoc_hsts_enable: true
hedgedoc_allow_pdf_export: true
hedgedoc_upload_type: "filesystem"

@ -1,5 +1,5 @@
---
- name: restart systemd service
systemd:
name: "codimd.service"
state: restarted
name: "hedgedoc.service"
state: restarted

@ -1,14 +0,0 @@
---
- name: Run codimd setup script
command:
chdir: "{{ codimd_base_path }}"
cmd: "{{ codimd_base_path }}/bin/setup"
become: yes
become_user: "{{ codimd_user }}"
- name: Run codimd build script
command:
chdir: "{{ codimd_base_path }}"
cmd: "yarn run build"
become: yes
become_user: "{{ codimd_user }}"

@ -0,0 +1,16 @@
---
- name: Upload config.json
template:
src: "{{ hedgedoc_config_template_path }}"
dest: "{{ hedgedoc_base_path }}/config.json"
owner: "{{ hedgedoc_user }}"
group: "{{ hedgedoc_group }}"
notify: restart systemd service
- name: Upload .sequelizerc
template:
src: ".sequelizerc.j2"
dest: "{{ hedgedoc_base_path }}/.sequelizerc"
owner: "{{ hedgedoc_user }}"
group: "{{ hedgedoc_group }}"
notify: restart systemd service

@ -0,0 +1,37 @@
---
- name: Check if file with current installed version exists
stat:
path: "{{ hedgedoc_base_path }}/VERSION"
register: stat_version_file
- name: Get content of file with current installed version
slurp:
src: "{{ hedgedoc_base_path }}/VERSION"
register: slurp_version_file
when: stat_version_file.stat.exists
- block:
- name: Extract package tgz
unarchive:
src: "{{ hedgedoc_source }}"
dest: "{{ hedgedoc_base_path }}"
remote_src: yes
extra_opts: [--strip-components=1]
become: yes
become_user: "{{ hedgedoc_user }}"
- name: Run hedgedoc setup script
command:
chdir: "{{ hedgedoc_base_path }}"
cmd: "{{ hedgedoc_base_path }}/bin/setup"
become: yes
become_user: "{{ hedgedoc_user }}"
- name: Create file for saving current installed version
copy:
content: "{{ hedgedoc_version }}"
dest: "{{ hedgedoc_base_path }}/VERSION"
owner: "{{ hedgedoc_user }}"
group: "{{ hedgedoc_group }}"
when: (not stat_version_file.stat.exists) or (slurp_version_file.content | b64decode != hedgedoc_version)

@ -1,77 +1,29 @@
---
- name: Create group
group:
name: "{{ codimd_group }}"
name: "{{ hedgedoc_group }}"
state: present
- name: Create user
user:
name: "{{ codimd_user }}"
group: "{{ codimd_group }}"
name: "{{ hedgedoc_user }}"
group: "{{ hedgedoc_group }}"
create_home: yes
home: "{{ codimd_base_path }}"
shell: "/bin/bash"
home: "{{ hedgedoc_base_path }}"
shell: "/bin/false"
system: yes
- name: Download package tgz
get_url:
url: "{{ codimd_source }}"
dest: "/tmp/codimd.tar.gz"
- import_tasks: "install.yml"
- import_tasks: "config.yml"
- name: Extract package tgz
unarchive:
src: "/tmp/codimd.tar.gz"
dest: "{{ codimd_base_path }}"
remote_src: yes
become: yes
become_user: "{{ codimd_group }}"
- name: Delete package tgz
file:
path: "/tmp/codimd.tar.gz"
state: absent
- import_tasks: build.yml
when: codimd_build
- name: Install production requirements
npm:
path: "{{ codimd_base_path }}"
production: yes
state: present
become: yes
become_user: "{{ codimd_user }}"
when: not codimd_build
- name: Upload config.json
- name: Upload hedgedoc.service
template:
src: "{{ codimd_config_template_path }}"
dest: "{{ codimd_base_path }}/config.json"
owner: "{{ codimd_user }}"
group: "{{ codimd_group }}"
notify: restart systemd service
- name: Upload .sequelizerc
template:
src: ".sequelizerc.j2"
dest: "{{ codimd_base_path }}/.sequelizerc"
owner: "{{ codimd_user }}"
group: "{{ codimd_group }}"
notify: restart systemd service
- name: Upload codimd.service
template:
src: "codimd.service"
dest: "/etc/systemd/system/codimd.service"
- name: Upload saml cert
copy:
dest: "{{ codimd_saml.idpCertPath | default(codimd_base_path + '/idp_cert.pem') }}"
content: "{{ codimd_saml.idpCert }}"
when: codimd_saml is defined
src: "hedgedoc.service"
dest: "/etc/systemd/system/hedgedoc.service"
- name: Enable/Start codimd service
- name: Enable/Start hedgedoc service
systemd:
name: "codimd.service"
name: "hedgedoc.service"
enabled: yes
daemon_reload: yes
state: started
state: started

@ -4,5 +4,5 @@ module.exports = {
'config': path.resolve('config.json'),
'migrations-path': path.resolve('lib', 'migrations'),
'models-path': path.resolve('lib', 'models'),
'url': '{{ codimd_db_dialect }}://{{ codimd_db_username }}:{{ codimd_db_password }}@{{ codimd_db_host }}:{{ codimd_db_port }}/{{ codimd_db_database }}'
}
'url': '{{ hedgedoc_db_dialect }}://{{ hedgedoc_db_username }}:{{ hedgedoc_db_password }}@{{ hedgedoc_db_host }}:{{ hedgedoc_db_port }}/{{ hedgedoc_db_database }}'
}

@ -1,27 +1,27 @@
{
"production": {
"loglevel": "{{ codimd_loglevel | default('warn') }}",
"imageUploadType": "{{ codimd_upload_type }}",
"allowPDFExport": {{ codimd_allow_pdf_export | bool | lower }},
"loglevel": "{{ hedgedoc_loglevel | default('warn') }}",
"imageUploadType": "{{ hedgedoc_upload_type }}",
"allowPDFExport": {{ hedgedoc_allow_pdf_export | bool | lower }},
"db": {
"username": "{{ codimd_db_username }}",
"password": "{{ codimd_db_password }}",
"database": "{{ codimd_db_database }}",
"host": "{{ codimd_db_host }}",
"port": "{{ codimd_db_port }}",
"dialect": "{{ codimd_db_dialect }}"
"username": "{{ hedgedoc_db_username }}",
"password": "{{ hedgedoc_db_password }}",
"database": "{{ hedgedoc_db_database }}",
"host": "{{ hedgedoc_db_host }}",
"port": "{{ hedgedoc_db_port }}",
"dialect": "{{ hedgedoc_db_dialect }}"
},
"tmpPath": "/tmp/",
"docsPath": "./public/docs",
"viewPath": "./public/views",
"uploadsPath": "./public/uploads",
"domain": "{{ codimd_domain }}",
"port": "{{ codimd_port }}",
"domain": "{{ hedgedoc_domain }}",
"port": "{{ hedgedoc_port }}",
"protocolUseSSL": true,
"urlAddPort": false,
"allowOrigin": "{{ codimd_allowed_origins }}",
"allowOrigin": "{{ hedgedoc_allowed_origins }}",
"hsts": {
"enable": {{ codimd_hsts_enable | bool | lower }},
"enable": {{ hedgedoc_hsts_enable | bool | lower }},
"maxAgeSeconds": 31536000,
"includeSubDomains": true,
"preload": true
@ -29,30 +29,22 @@
"csp": {
"enable": true,
"directives": {
"scriptSrc": "{{ codimd_domain }}",
"styleSrc": "{{ codimd_domain }}",
"fontSrc": "{{ codimd_domain }}"
"scriptSrc": "{{ hedgedoc_domain }}",
"styleSrc": "{{ hedgedoc_domain }}",
"fontSrc": "{{ hedgedoc_domain }}"
},
"upgradeInsecureRequests": "auto",
"addDefaults": {{ codimd_csp_enable | bool | lower }}
"addDefaults": {{ hedgedoc_csp_enable | bool | lower }}
},
"allowAnonymous": {{ codimd_allow_anonymous | bool | lower }},
"allowAnonymousEdits": {{ codimd_allow_anonymous_edits | bool | lower }},
"allowFreeURL": {{ codimd_allow_free_url | bool | lower }},
"allowAnonymous": {{ hedgedoc_allow_anonymous | bool | lower }},
"allowAnonymousEdits": {{ hedgedoc_allow_anonymous_edits | bool | lower }},
"allowFreeURL": {{ hedgedoc_allow_free_url | bool | lower }},
"defaultPermission": "editable",
"sessionLife": 1209600000,
"sessionSecret": "{{ codimd_session_secret }}",
"email": {{ codimd_allow_email_login | bool | lower }},
"allowEmailRegister": {{ codimd_allow_email_register | bool | lower }}{% if codimd_saml is defined %},
"saml": {
"issuer": "{{ codimd_saml.issuer }}",
"identifierFormat": "{{ codimd_saml.identifierFormat | default('urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified') }}",
"idpSsoUrl": "{{ codimd_saml.idpSSOUrl }}",
"idpCert": "{{ codimd_saml.idpCertPath | default(codimd_base_path + '/idp_cert.pem') }}",
"attribute": {{ codimd_saml.attributes | default({}) | to_nice_json }}
}
{% endif %}{% if codimd_additional_config is defined %},
{{ codimd_additional_config }}
"sessionSecret": "{{ hedgedoc_session_secret }}",
"email": {{ hedgedoc_allow_email_login | bool | lower }},
"allowEmailRegister": {{ hedgedoc_allow_email_register | bool | lower }}{% if hedgedoc_additional_config is defined %},
{{ hedgedoc_additional_config }}
{% endif %}
}
}

@ -1,17 +1,17 @@
[Unit]
Description=CodiMD
Description=hedgedoc
After=network.target
[Service]
Type=exec
RestartSec=2s
User={{ codimd_user }}
Group={{ codimd_group }}
WorkingDirectory={{ codimd_base_path }}
User={{ hedgedoc_user }}
Group={{ hedgedoc_group }}
WorkingDirectory={{ hedgedoc_base_path }}
ExecStart=/usr/bin/env npm start --production
Restart=always
PrivateTmp=true
PrivateDevices=true
[Install]
WantedBy=multi-user.target
WantedBy=multi-user.target
Loading…
Cancel
Save