Make the linter happy.

This commit is contained in:
Andrea Dell'Amico 2024-04-28 14:45:21 +02:00
parent 80de76635f
commit 36fd443b9c
Signed by: adellam
GPG Key ID: 147ABE6CEB9E20FF
4 changed files with 214 additions and 180 deletions

View File

@ -5,7 +5,7 @@
# We use the server ssh daemon, and nginx in front of the service by default. # We use the server ssh daemon, and nginx in front of the service by default.
# So we do not start in http mode and we do not use the embedded letsencrypt support # So we do not start in http mode and we do not use the embedded letsencrypt support
# #
gitea_version: 1.19.4 gitea_version: 1.21.11
gitea_download_url: 'https://dl.gitea.io/gitea/{{ gitea_version }}/gitea-{{ gitea_version }}-linux-amd64' gitea_download_url: 'https://dl.gitea.io/gitea/{{ gitea_version }}/gitea-{{ gitea_version }}-linux-amd64'
gitea_force_binary_download: False gitea_force_binary_download: False
gitea_bin_path: /usr/local/bin/gitea gitea_bin_path: /usr/local/bin/gitea
@ -55,11 +55,11 @@ gitea_required_packages:
gitea_db_name: gitea gitea_db_name: gitea
gitea_db_user: gitea_u gitea_db_user: gitea_u
#gitea_db_pwd: put it into a vault file #gitea_db_pwd: put it into a vault file
gitea_db_host: postgres.priv.isti.cnr.it gitea_db_host: "localhost"
gitea_db_port: 5432 gitea_db_port: 5432
gitea_db_ssl_mode: 'disable' gitea_db_ssl_mode: 'disable'
gitea_app_name: "Gitea" gitea_app_name: "Gitea git server"
gitea_disable_registration: 'false' gitea_disable_registration: 'false'
gitea_install_lock: 'false' gitea_install_lock: 'false'
gitea_mailer_enabled: False gitea_mailer_enabled: False

View File

@ -1,6 +1,14 @@
--- ---
- name: reload gitea - name: Reload gitea
service: name=gitea state=reloaded ansible.builtin.service:
name: gitea
state: reloaded
- name: restart gitea - name: Restart gitea
service: name=gitea state=restarted ansible.builtin.service:
name: gitea
state: restarted
- name: Reload the systemd configuration
ansible.builtin.systemd_service:
daemon-reload: true

View File

@ -1,129 +1,162 @@
--- ---
- block: - name: gitea | Manage the gitea installation and configuration
- name: Create the gitea service user tags: ['git', 'gitea']
user: name={{ gitea_user }} home=/srv/gitea createhome=yes shell=/bin/bash system=yes block:
when: gitea_create_service_user - name: gitea | Create the gitea service user
ansible.builtin.user:
name: "{{ gitea_user }}"
home: /srv/gitea
createhome: true
shell: /bin/bash
system: true
when: gitea_create_service_user
- name: Create the gitea directory tree - name: gitea | Create the gitea directory tree
file: dest={{ gitea_data_dir }}/{{ item }} state=directory owner={{ gitea_user }} group={{ gitea_group }} ansible.builtin.file:
with_items: '{{ gitea_data_subdirs }}' dest: "{{ gitea_data_dir }}/{{ item }}"
when: gitea_create_service_user state: directory
owner: "{{ gitea_user }}"
group: "{{ gitea_group }}"
mode: "0750"
loop: '{{ gitea_data_subdirs }}'
when: gitea_create_service_user
- name: Create the gitea subdirs when we are using a pre existing user - name: gitea | Create the gitea subdirs when we are using a pre existing user
become: True become: true
become_user: '{{ gitea_user }}' become_user: '{{ gitea_user }}'
file: dest={{ gitea_data_dir }}/{{ item }} state=directory ansible.builtin.file:
with_items: '{{ gitea_data_subdirs }}' dest: "{{ gitea_data_dir }}/{{ item }}"
when: not gitea_create_service_user state: directory
mode: "0750"
with_items: '{{ gitea_data_subdirs }}'
when: not gitea_create_service_user
- name: Create the gitea conf directory - name: gitea | Create the gitea conf directory
file: dest={{ gitea_conf_dir }} state=directory owner=root group={{ gitea_group }} mode=0750 ansible.builtin.file:
dest: "{{ gitea_conf_dir }}"
state: directory
owner: root
group: "{{ gitea_group }}"
mode: "0750"
- name: Create the gitea socket directory - name: gitea | Create the gitea socket directory
file: ansible.builtin.file:
dest: '{{ gitea_socket_dir }}' dest: '{{ gitea_socket_dir }}'
state: directory state: directory
owner: '{{ gitea_user }}' owner: '{{ gitea_user }}'
group: '{{ gitea_group }}' group: '{{ gitea_group }}'
mode: 0755 mode: "0755"
- name: Create the gitea log directory - name: gitea | Create the gitea log directory
file: ansible.builtin.file:
dest: '{{ gitea_log_dir }}' dest: '{{ gitea_log_dir }}'
state: directory state: directory
owner: '{{ gitea_user }}' owner: '{{ gitea_user }}'
group: '{{ gitea_group }}' group: '{{ gitea_group }}'
mode: 0755 mode: "0755"
- name: Download the gitea binary - name: gitea | Download the gitea binary
get_url: ansible.builtin.get_url:
url: '{{ gitea_download_url }}' url: '{{ gitea_download_url }}'
dest: '{{ gitea_bin_path }}' dest: '{{ gitea_bin_path }}'
owner: root owner: root
group: '{{ gitea_group }}' group: '{{ gitea_group }}'
mode: 0750 mode: "0750"
notify: restart gitea notify: restart gitea
- name: Force the download of the gitea binary to upgrade it - name: gitea | Force the download of the gitea binary to upgrade it
get_url: ansible.builtin.get_url:
url: '{{ gitea_download_url }}' url: '{{ gitea_download_url }}'
dest: '{{ gitea_bin_path }}' dest: '{{ gitea_bin_path }}'
owner: root owner: root
group: '{{ gitea_group }}' group: '{{ gitea_group }}'
mode: 0750 mode: "0750"
force: true force: true
when: gitea_force_binary_download when: gitea_force_binary_download
- name: Install the required packages - name: gitea | Install the required packages
package: state=present use=auto name={{ gitea_required_packages }} ansible.builtin.package:
state: present
use: auto
name: "{{ gitea_required_packages }}"
- name: Install the gitea configuration file. At install time only - name: gitea | 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 ansible.builtin.template:
notify: restart gitea src: app.ini.j2
dest: "{{ gitea_conf_dir }}/app.ini"
owner: "{{ gitea_user }}"
group: "{{ gitea_group }}"
mode: "0640"
force: false
notify: restart gitea
- name: Change the gitea configuration. After the installation - name: gitea | Change the gitea configuration. After the installation
ini_file: community.general.ini_file:
path: '{{ gitea_conf_dir }}/app.ini' path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}' section: '{{ item.section }}'
option: '{{ item.option }}' option: '{{ item.option }}'
value: '{{ item.value }}' value: '{{ item.value }}'
state: '{{ item.state }}' state: '{{ item.state }}'
owner: '{{ gitea_user }}' owner: '{{ gitea_user }}'
group: '{{ gitea_group }}' group: '{{ gitea_group }}'
mode: '0640' mode: '0640'
create: no create: false
loop: '{{ gitea_app_configurations }}' loop: '{{ gitea_app_configurations }}'
when: gitea_app_configurations is defined when: gitea_app_configurations is defined
notify: restart gitea notify: restart gitea
tags: [ 'git', 'gitea', 'gitea_conf' ] tags: ['git', 'gitea', 'gitea_conf']
- name: Prometheus metrics - name: gitea | Prometheus metrics
ini_file: community.general.ini_file:
path: '{{ gitea_conf_dir }}/app.ini' path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}' section: '{{ item.section }}'
option: '{{ item.option }}' option: '{{ item.option }}'
value: '{{ item.value }}' value: '{{ item.value }}'
state: '{{ item.state }}' state: '{{ item.state }}'
owner: '{{ gitea_user }}' owner: '{{ gitea_user }}'
group: '{{ gitea_group }}' group: '{{ gitea_group }}'
mode: '0640' mode: '0640'
create: no create: false
loop: '{{ gitea_prometheus_conf }}' loop: '{{ gitea_prometheus_conf }}'
notify: restart gitea notify: restart gitea
tags: [ 'git', 'gitea', 'gitea_conf' ] tags: ['git', 'gitea', 'gitea_conf']
- name: Create the tmpfile entry for the gitea socket directory - name: gitea | Create the tmpfile entry for the gitea socket directory
template: ansible.builtin.template:
src: tmpfile_gitea.conf.j2 src: tmpfile_gitea.conf.j2
dest: /usr/lib/tmpfiles.d/gitea.conf dest: /usr/lib/tmpfiles.d/gitea.conf
owner: root owner: root
group: root group: root
mode: 0644 mode: "0644"
- name: Create some custom subdirectories - name: gitea | Create some custom subdirectories
become: true become: true
become_user: '{{ gitea_user }}' become_user: '{{ gitea_user }}'
file: ansible.builtin.file:
dest: '{{ gitea_data_dir }}/custom/{{ item }}' dest: '{{ gitea_data_dir }}/custom/{{ item }}'
state: directory state: directory
loop: mode: "0750"
- 'templates/custom' loop:
- 'public/css' - 'templates/custom'
- 'public/components' - 'public/css'
tags: [ 'git', 'gitea', 'gitea_conf' ] - 'public/components'
tags: [ 'git', 'gitea' ] tags: ['git', 'gitea', 'gitea_conf']
- name: Gitea systemd service - name: gitea | Gitea systemd service
tags: ['git', 'gitea', 'gitea_service'] tags: ['git', 'gitea', 'gitea_service']
block: block:
- name: Install the gitea systemd unit - name: gitea | Install the gitea systemd unit
template: src=gitea.service.systemd.j2 dest=/etc/systemd/system/gitea.service ansible.builtin.template:
register: gitea_systemd_unit src: gitea.service.systemd.j2
dest: /etc/systemd/system/gitea.service
mode: "0644"
notify: Reload the systemd configuration
- name: Reload the systemd configuration - name: gitea | Flush the handlers
command: systemctl daemon-reload ansible.builtin.meta: flush_handlers
when: gitea_systemd_unit is changed
- name: Ensure that the gitea service is running and enabled
service: name=gitea state=started enabled=yes
- name: gitea | Ensure that the gitea service is running and enabled
ansible.builtin.service:
name: gitea
state: started
enabled: true

View File

@ -1,8 +1,9 @@
--- ---
- name: Global renderers config - name: renderers | Global renderers config
tags: ['git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_renderers']
block: block:
- name: Global renderers config - name: renderers | Global renderers config
ini_file: community.general.ini_file:
path: '{{ gitea_conf_dir }}/app.ini' path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}' section: '{{ item.section }}'
option: '{{ item.option }}' option: '{{ item.option }}'
@ -11,17 +12,16 @@
owner: '{{ gitea_user }}' owner: '{{ gitea_user }}'
group: '{{ gitea_group }}' group: '{{ gitea_group }}'
mode: '0640' mode: '0640'
create: no create: false
loop: '{{ gitea_renderers_global_conf }}' loop: '{{ gitea_renderers_global_conf }}'
when: gitea_install_viewer_addons when: gitea_install_viewer_addons
notify: restart gitea notify: Restart gitea
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_renderers' ] - name: renderers | Configure asciidoc
tags: ['git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_asciidoc']
- name: Configure asciidoc
block: block:
- name: Configure asciidoc - name: renderers | Configure asciidoc
ini_file: community.general.ini_file:
path: '{{ gitea_conf_dir }}/app.ini' path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}' section: '{{ item.section }}'
option: '{{ item.option }}' option: '{{ item.option }}'
@ -30,17 +30,16 @@
owner: '{{ gitea_user }}' owner: '{{ gitea_user }}'
group: '{{ gitea_group }}' group: '{{ gitea_group }}'
mode: '0640' mode: '0640'
create: no create: false
loop: '{{ gitea_markup_asciidoc_conf }}' loop: '{{ gitea_markup_asciidoc_conf }}'
when: gitea_install_viewer_addons when: gitea_install_viewer_addons
notify: restart gitea notify: Restart gitea
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_asciidoc' ] - name: renderers | Configure jupyter markup
tags: ['git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_jupyter']
- name: Configure jupyter markup
block: block:
- name: Configure jupyter markup - name: renderers | Configure jupyter markup
ini_file: community.general.ini_file:
path: '{{ gitea_conf_dir }}/app.ini' path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}' section: '{{ item.section }}'
option: '{{ item.option }}' option: '{{ item.option }}'
@ -49,47 +48,46 @@
owner: '{{ gitea_user }}' owner: '{{ gitea_user }}'
group: '{{ gitea_group }}' group: '{{ gitea_group }}'
mode: '0640' mode: '0640'
create: no create: false
loop: '{{ gitea_markup_jupyter_conf }}' loop: '{{ gitea_markup_jupyter_conf }}'
when: gitea_install_viewer_addons when: gitea_install_viewer_addons
notify: restart gitea notify: Restart gitea
- name: Install the jupyter CSS - name: renderers | Install the jupyter CSS
become: true become: true
become_user: '{{ gitea_user }}' become_user: '{{ gitea_user }}'
copy: ansible.builtin.copy:
src: jupyter.css src: jupyter.css
dest: '{{ gitea_data_dir }}/custom/public/css/jupyter.css' dest: '{{ gitea_data_dir }}/custom/public/css/jupyter.css'
mode: 0444 mode: "0444"
- name: Install html template that loads the CSS - name: renderers | Install html template that loads the CSS
become: true become: true
become_user: '{{ gitea_user }}' become_user: '{{ gitea_user }}'
copy: ansible.builtin.copy:
src: header.tmpl src: header.tmpl
dest: '{{ gitea_data_dir }}/custom/templates/custom/header.tmpl' dest: '{{ gitea_data_dir }}/custom/templates/custom/header.tmpl'
mode: 0444 mode: "0444"
- name: Check if the awesome fonts are installed - name: renderers | Check if the awesome fonts are installed
stat: ansible.builtin.stat:
path: /usr/share/fonts-font-awesome path: /usr/share/fonts-font-awesome
register: awesome_fonts_dir register: awesome_fonts_dir
- name: Link to the awesome fonts directory - name: renderers | Link to the awesome fonts directory
become: true become: true
become_user: '{{ gitea_user }}' become_user: '{{ gitea_user }}'
file: ansible.builtin.file:
src: /usr/share/fonts-font-awesome src: /usr/share/fonts-font-awesome
dest: '{{ gitea_data_dir }}/custom/public/components/font-awesome' dest: '{{ gitea_data_dir }}/custom/public/components/font-awesome'
state: link state: link
when: awesome_fonts_dir.stat.exists when: awesome_fonts_dir.stat.exists
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_jupyter' ] - name: renderers | Configure restructuredtext markup
tags: ['git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_restructuredtext']
- name: Configure restructuredtext markup
block: block:
- name: Configure restructuredtext markup - name: renderers | Configure restructuredtext markup
ini_file: community.general.ini_file:
path: '{{ gitea_conf_dir }}/app.ini' path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}' section: '{{ item.section }}'
option: '{{ item.option }}' option: '{{ item.option }}'
@ -98,17 +96,16 @@
owner: '{{ gitea_user }}' owner: '{{ gitea_user }}'
group: '{{ gitea_group }}' group: '{{ gitea_group }}'
mode: '0640' mode: '0640'
create: no create: false
loop: '{{ gitea_markup_restructuredtext_conf }}' loop: '{{ gitea_markup_restructuredtext_conf }}'
when: gitea_install_viewer_addons when: gitea_install_viewer_addons
notify: restart gitea notify: Restart gitea
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_restructuredtext' ] - name: renderers | Configure sanitizer TeX markup
tags: ['git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_sanitizer_tex']
- name: Configure sanitizer TeX markup
block: block:
- name: Configure sanitizer TeX markup - name: renderers | Configure sanitizer TeX markup
ini_file: community.general.ini_file:
path: '{{ gitea_conf_dir }}/app.ini' path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}' section: '{{ item.section }}'
option: '{{ item.option }}' option: '{{ item.option }}'
@ -117,17 +114,16 @@
owner: '{{ gitea_user }}' owner: '{{ gitea_user }}'
group: '{{ gitea_group }}' group: '{{ gitea_group }}'
mode: '0640' mode: '0640'
create: no create: false
loop: '{{ gitea_markup_sanitizer_tex_conf }}' loop: '{{ gitea_markup_sanitizer_tex_conf }}'
when: gitea_install_viewer_addons when: gitea_install_viewer_addons
notify: restart gitea notify: Restart gitea
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_sanitizer_tex' ] - name: renderers | Configure markdown markup
tags: ['git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_markdown']
- name: Configure markdown markup
block: block:
- name: Configure markdown markup - name: renderers | Configure markdown markup
ini_file: community.general.ini_file:
path: '{{ gitea_conf_dir }}/app.ini' path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}' section: '{{ item.section }}'
option: '{{ item.option }}' option: '{{ item.option }}'
@ -136,17 +132,17 @@
owner: '{{ gitea_user }}' owner: '{{ gitea_user }}'
group: '{{ gitea_group }}' group: '{{ gitea_group }}'
mode: '0640' mode: '0640'
create: no create: false
loop: '{{ gitea_markup_markdown_conf }}' loop: '{{ gitea_markup_markdown_conf }}'
when: gitea_install_viewer_addons when: gitea_install_viewer_addons
notify: restart gitea notify: Restart gitea
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_markdown' ] - name: renderers | Configure docx markup
when: gitea_install_viewer_addons
- name: Configure docx markup tags: ['git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_docx']
block: block:
- name: Configure the docx markup - name: renderers | Configure the docx markup
ini_file: community.general.ini_file:
path: '{{ gitea_conf_dir }}/app.ini' path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}' section: '{{ item.section }}'
option: '{{ item.option }}' option: '{{ item.option }}'
@ -155,17 +151,14 @@
owner: '{{ gitea_user }}' owner: '{{ gitea_user }}'
group: '{{ gitea_group }}' group: '{{ gitea_group }}'
mode: '0640' mode: '0640'
create: no create: false
loop: '{{ gitea_markup_docx_conf }}' loop: '{{ gitea_markup_docx_conf }}'
notify: restart gitea notify: Restart gitea
- name: Create the docx template - name: renderers | Create the docx template
become: true become: true
become_user: '{{ gitea_user }}' become_user: '{{ gitea_user }}'
copy: ansible.builtin.copy:
content: "$body$" content: "$body$"
dest: '{{ gitea_data_dir }}/custom/templates/docx-basic.html' dest: '{{ gitea_data_dir }}/custom/templates/docx-basic.html'
mode: "0644"
when: gitea_install_viewer_addons
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_docx' ]