Support external renderers

This commit is contained in:
Andrea Dell'Amico 2021-06-16 12:18:43 +02:00
parent 645905efa4
commit 3401312672
Signed by: adellam
GPG Key ID: 147ABE6CEB9E20FF
7 changed files with 138 additions and 59 deletions

View File

@ -9,7 +9,7 @@ Role Variables
The most important variables are listed below:
``` yaml
gitea_version: 1.11.3
gitea_version: 1.14.2
gitea_local_postgresql: True
gitea_local_mysql: False
gitea_local_mariadb: False
@ -23,6 +23,20 @@ gitea_app_configurations:
- { section: 'mailer', option: 'SENDMAIL_PATH', value: '{{ gitea_sendmail_path }}', state: 'present' }
- { section: 'metrics', option: 'ENABLED', value: 'true', state: 'present' }
- { section: 'metrics', option: 'TOKEN', value: '{{ gitea_prometheus_bearer_token }}', state: 'present' }
gitea_install_viewer_addons: True
gitea_addons_deb_packages:
- jupyter
- asciidoctor
- pandoc
gitea_markup_asciidoc_enabled: True
gitea_markup_jupyter_enabled: True
gitea_markup_restructuredtext_enabled: True
gitea_markup_sanitizer_tex_enabled: True
gitea_markup_markdown_enabled: True
gitea_prometheus_metrics: False
gitea_prometheus_bearer_token: 'Use a vault'
gitea_log_level: Info
```
Dependencies

View File

@ -66,6 +66,18 @@ gitea_session_config: 'network=tcp,addr=127.0.0.1:6379,db=0,pool_size=100,idle_t
gitea_require_signin_view: 'false'
gitea_users_page_enabled: 'false'
gitea_install_viewer_addons: True
gitea_addons_deb_packages:
- jupyter
- asciidoctor
- pandoc
gitea_markup_asciidoc_enabled: True
gitea_markup_jupyter_enabled: True
gitea_markup_restructuredtext_enabled: True
gitea_markup_sanitizer_tex_enabled: True
gitea_markup_markdown_enabled: True
gitea_prometheus_metrics: False
#gitea_prometheus_bearer_token: put it into a vault file
gitea_prometheus_bearer_token: ''

View File

@ -16,13 +16,9 @@ galaxy_info:
- name: Ubuntu
versions:
- bionic
- name: EL
versions:
- 7
- 8
galaxy_tags:
- users
- git
dependencies:
- src: git+https://gitea-s2i2s.isti.cnr.it/ISTI-ansible-roles/ansible-role-postgresql.git

10
tasks/deb-addons.yml Normal file
View File

@ -0,0 +1,10 @@
---
- name:
block: Install the packages required by the gitea viewers
- name:
apt:
pkg: '{{ gitea_addons_deb_packages }}'
state: present
cache_valid_time: 1800
tags: [ 'git', 'gitea', 'gitea_addons' ]

54
tasks/gitea.yml Normal file
View File

@ -0,0 +1,54 @@
---
- block:
- name: Create the gitea service user
user: name={{ gitea_user }} home=/srv/gitea createhome=yes shell=/bin/bash system=yes
- name: Create the gitea directory tree
file: dest={{ gitea_data_dir }}/{{ item }} state=directory owner={{ gitea_user }} group={{ gitea_group }}
with_items: '{{ gitea_data_subdirs }}'
- name: Create the gitea conf directory
file: dest={{ gitea_conf_dir }} state=directory owner=root group={{ gitea_group }} mode=0750
- name: Download the gitea binary
get_url: url={{ gitea_download_url }} dest={{ gitea_bin_path }} owner=root group={{ gitea_group }} mode=0750
- name: Install the required packages
package: state=present use=auto name={{ gitea_required_packages }}
- name: Check if the gitea configuration file exists
stat: path={{ gitea_conf_dir }}/app.ini
register: gitea_app_ini
- name: Change the gitea configuration. After the installation
ini_file:
path: '{{ gitea_conf_dir }}/app.ini section={{ item.section }}'
option: '{{ item.option }}'
value: '{{ item.value }}'
state: '{{ item.state }}'
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: '0640'
create: no
with_items: '{{ gitea_app_configurations }}'
when:
- gitea_app_ini.stat.exists
- gitea_app_configurations is defined
notify: restart gitea
- name: Install the gitea configuration file. At install time only
template: src=app.ini.j2 dest={{ gitea_conf_dir }}/app.ini owner={{ gitea_user }} group={{ gitea_group }} mode=0640 force=no
notify: restart gitea
- name: Install the gitea systemd unit
template: src=gitea.service.systemd dest=/etc/systemd/system/gitea.service
register: gitea_systemd_unit
- name: Reload the systemd configuration
command: systemctl daemon-reload
when: gitea_systemd_unit is changed
- name: Ensure that the gitea service is running and enabled
service: name=gitea state=started enabled=yes
tags: [ 'git', 'gitea' ]

View File

@ -1,54 +1,4 @@
---
- block:
- name: Create the gitea service user
user: name={{ gitea_user }} home=/srv/gitea createhome=yes shell=/bin/bash system=yes
- name: Create the gitea directory tree
file: dest={{ gitea_data_dir }}/{{ item }} state=directory owner={{ gitea_user }} group={{ gitea_group }}
with_items: '{{ gitea_data_subdirs }}'
- name: Create the gitea conf directory
file: dest={{ gitea_conf_dir }} state=directory owner=root group={{ gitea_group }} mode=0750
- name: Download the gitea binary
get_url: url={{ gitea_download_url }} dest={{ gitea_bin_path }} owner=root group={{ gitea_group }} mode=0750
- name: Install the required packages
package: state=present use=auto name={{ gitea_required_packages }}
- name: Check if the gitea configuration file exists
stat: path={{ gitea_conf_dir }}/app.ini
register: gitea_app_ini
- name: Change the gitea configuration. After the installation
ini_file:
path: '{{ gitea_conf_dir }}/app.ini section={{ item.section }}'
option: '{{ item.option }}'
value: '{{ item.value }}'
state: '{{ item.state }}'
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: '0640'
create: no
with_items: '{{ gitea_app_configurations }}'
when:
- gitea_app_ini.stat.exists
- gitea_app_configurations is defined
notify: restart gitea
- name: Install the gitea configuration file. At install time only
template: src=app.ini.j2 dest={{ gitea_conf_dir }}/app.ini owner={{ gitea_user }} group={{ gitea_group }} mode=0640 force=no
notify: restart gitea
- name: Install the gitea systemd unit
template: src=gitea.service.systemd dest=/etc/systemd/system/gitea.service
register: gitea_systemd_unit
- name: Reload the systemd configuration
command: systemctl daemon-reload
when: gitea_systemd_unit is changed
- name: Ensure that the gitea service is running and enabled
service: name=gitea state=started enabled=yes
tags: [ 'git', 'gitea' ]
- import_tasks: gitea.yml
- import_tasks: deb-addons.yml
when: ansible_distribution_file_variety == "Debian"

View File

@ -61,6 +61,49 @@ ENABLED = true
TOKEN = '{{ gitea_prometheus_bearer_token }}'
{% endif %}
{% if gitea_install_viewer_addons %}
{% if gitea_markup_asciidoc_enabled %}
[markup.asciidoc]
ENABLED = true
FILE_EXTENSIONS = .adoc,.asciidoc
RENDER_COMMAND = "asciidoctor -s -a showtitle --out-file=- -"
; Input is not a standard input but a file
IS_INPUT_FILE = false
{%endif %}
{% if gitea_markup_jupyter_enabled %}
[markup.jupyter]
ENABLED = true
FILE_EXTENSIONS = .ipynb
RENDER_COMMAND = "jupyter nbconvert --stdout --to html --template basic "
IS_INPUT_FILE = true
{%endif %}
{% if gitea_markup_restructuredtext_enabled %}
[markup.restructuredtext]
ENABLED = true
FILE_EXTENSIONS = .rst
RENDER_COMMAND = "timeout 30s pandoc +RTS -M512M -RTS -f rst"
IS_INPUT_FILE = false
{%endif %}
{% if gitea_markup_sanitizer_tex_enabled %}
[markup.sanitizer.TeX]
; Pandoc renders TeX segments as <span>s with the "math" class, optionally
; with "inline" or "display" classes depending on context.
ELEMENT = span
ALLOW_ATTR = class
REGEXP = ^\s*((math(\s+|$)|inline(\s+|$)|display(\s+|$)))+
{%endif %}
{% if gitea_markup_markdown_enabled %}
[markup.markdown]
ENABLED = true
FILE_EXTENSIONS = .md,.markdown
RENDER_COMMAND = pandoc -f markdown -t html --katex
{%endif %}
{%endif %}
[other]
SHOW_FOOTER_VERSION = false
SHOW_FOOTER_TEMPLATE_LOAD_TIME = false