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.
# 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_force_binary_download: False
gitea_bin_path: /usr/local/bin/gitea
@ -55,11 +55,11 @@ gitea_required_packages:
gitea_db_name: gitea
gitea_db_user: gitea_u
#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_ssl_mode: 'disable'
gitea_app_name: "Gitea"
gitea_app_name: "Gitea git server"
gitea_disable_registration: 'false'
gitea_install_lock: 'false'
gitea_mailer_enabled: False

View File

@ -1,6 +1,14 @@
---
- name: reload gitea
service: name=gitea state=reloaded
- name: Reload gitea
ansible.builtin.service:
name: gitea
state: reloaded
- name: restart gitea
service: name=gitea state=restarted
- name: Restart gitea
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: Create the gitea service user
user: name={{ gitea_user }} home=/srv/gitea createhome=yes shell=/bin/bash system=yes
when: gitea_create_service_user
- name: gitea | Manage the gitea installation and configuration
tags: ['git', 'gitea']
block:
- 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
file: dest={{ gitea_data_dir }}/{{ item }} state=directory owner={{ gitea_user }} group={{ gitea_group }}
with_items: '{{ gitea_data_subdirs }}'
when: gitea_create_service_user
- name: gitea | Create the gitea directory tree
ansible.builtin.file:
dest: "{{ gitea_data_dir }}/{{ item }}"
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
become: True
become_user: '{{ gitea_user }}'
file: dest={{ gitea_data_dir }}/{{ item }} state=directory
with_items: '{{ gitea_data_subdirs }}'
when: not gitea_create_service_user
- name: gitea | Create the gitea subdirs when we are using a pre existing user
become: true
become_user: '{{ gitea_user }}'
ansible.builtin.file:
dest: "{{ gitea_data_dir }}/{{ item }}"
state: directory
mode: "0750"
with_items: '{{ gitea_data_subdirs }}'
when: not gitea_create_service_user
- name: Create the gitea conf directory
file: dest={{ gitea_conf_dir }} state=directory owner=root group={{ gitea_group }} mode=0750
- name: gitea | Create the gitea conf directory
ansible.builtin.file:
dest: "{{ gitea_conf_dir }}"
state: directory
owner: root
group: "{{ gitea_group }}"
mode: "0750"
- name: Create the gitea socket directory
file:
dest: '{{ gitea_socket_dir }}'
state: directory
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: 0755
- name: gitea | Create the gitea socket directory
ansible.builtin.file:
dest: '{{ gitea_socket_dir }}'
state: directory
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: "0755"
- name: Create the gitea log directory
file:
dest: '{{ gitea_log_dir }}'
state: directory
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: 0755
- name: gitea | Create the gitea log directory
ansible.builtin.file:
dest: '{{ gitea_log_dir }}'
state: directory
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: "0755"
- name: Download the gitea binary
get_url:
url: '{{ gitea_download_url }}'
dest: '{{ gitea_bin_path }}'
owner: root
group: '{{ gitea_group }}'
mode: 0750
notify: restart gitea
- name: gitea | Download the gitea binary
ansible.builtin.get_url:
url: '{{ gitea_download_url }}'
dest: '{{ gitea_bin_path }}'
owner: root
group: '{{ gitea_group }}'
mode: "0750"
notify: restart gitea
- name: Force the download of the gitea binary to upgrade it
get_url:
url: '{{ gitea_download_url }}'
dest: '{{ gitea_bin_path }}'
owner: root
group: '{{ gitea_group }}'
mode: 0750
force: true
when: gitea_force_binary_download
- name: gitea | Force the download of the gitea binary to upgrade it
ansible.builtin.get_url:
url: '{{ gitea_download_url }}'
dest: '{{ gitea_bin_path }}'
owner: root
group: '{{ gitea_group }}'
mode: "0750"
force: true
when: gitea_force_binary_download
- name: Install the required packages
package: state=present use=auto name={{ gitea_required_packages }}
- name: gitea | Install the required packages
ansible.builtin.package:
state: present
use: auto
name: "{{ gitea_required_packages }}"
- 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: gitea | Install the gitea configuration file. At install time only
ansible.builtin.template:
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
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
loop: '{{ gitea_app_configurations }}'
when: gitea_app_configurations is defined
notify: restart gitea
tags: [ 'git', 'gitea', 'gitea_conf' ]
- name: gitea | Change the gitea configuration. After the installation
community.general.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: false
loop: '{{ gitea_app_configurations }}'
when: gitea_app_configurations is defined
notify: restart gitea
tags: ['git', 'gitea', 'gitea_conf']
- name: Prometheus metrics
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
loop: '{{ gitea_prometheus_conf }}'
notify: restart gitea
tags: [ 'git', 'gitea', 'gitea_conf' ]
- name: gitea | Prometheus metrics
community.general.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: false
loop: '{{ gitea_prometheus_conf }}'
notify: restart gitea
tags: ['git', 'gitea', 'gitea_conf']
- name: Create the tmpfile entry for the gitea socket directory
template:
src: tmpfile_gitea.conf.j2
dest: /usr/lib/tmpfiles.d/gitea.conf
owner: root
group: root
mode: 0644
- name: gitea | Create the tmpfile entry for the gitea socket directory
ansible.builtin.template:
src: tmpfile_gitea.conf.j2
dest: /usr/lib/tmpfiles.d/gitea.conf
owner: root
group: root
mode: "0644"
- name: Create some custom subdirectories
become: true
become_user: '{{ gitea_user }}'
file:
dest: '{{ gitea_data_dir }}/custom/{{ item }}'
state: directory
loop:
- 'templates/custom'
- 'public/css'
- 'public/components'
tags: [ 'git', 'gitea', 'gitea_conf' ]
tags: [ 'git', 'gitea' ]
- name: gitea | Create some custom subdirectories
become: true
become_user: '{{ gitea_user }}'
ansible.builtin.file:
dest: '{{ gitea_data_dir }}/custom/{{ item }}'
state: directory
mode: "0750"
loop:
- 'templates/custom'
- 'public/css'
- 'public/components'
tags: ['git', 'gitea', 'gitea_conf']
- name: Gitea systemd service
- name: gitea | Gitea systemd service
tags: ['git', 'gitea', 'gitea_service']
block:
- name: Install the gitea systemd unit
template: src=gitea.service.systemd.j2 dest=/etc/systemd/system/gitea.service
register: gitea_systemd_unit
- name: gitea | Install the gitea systemd unit
ansible.builtin.template:
src: gitea.service.systemd.j2
dest: /etc/systemd/system/gitea.service
mode: "0644"
notify: Reload the systemd configuration
- 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
- name: gitea | Flush the handlers
ansible.builtin.meta: flush_handlers
- 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:
- name: Global renderers config
ini_file:
- name: renderers | Global renderers config
community.general.ini_file:
path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}'
option: '{{ item.option }}'
@ -11,17 +12,16 @@
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: '0640'
create: no
create: false
loop: '{{ gitea_renderers_global_conf }}'
when: gitea_install_viewer_addons
notify: restart gitea
notify: Restart gitea
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_renderers' ]
- name: Configure asciidoc
- name: renderers | Configure asciidoc
tags: ['git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_asciidoc']
block:
- name: Configure asciidoc
ini_file:
- name: renderers | Configure asciidoc
community.general.ini_file:
path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}'
option: '{{ item.option }}'
@ -30,17 +30,16 @@
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: '0640'
create: no
create: false
loop: '{{ gitea_markup_asciidoc_conf }}'
when: gitea_install_viewer_addons
notify: restart gitea
notify: Restart gitea
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_asciidoc' ]
- name: Configure jupyter markup
- name: renderers | Configure jupyter markup
tags: ['git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_jupyter']
block:
- name: Configure jupyter markup
ini_file:
- name: renderers | Configure jupyter markup
community.general.ini_file:
path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}'
option: '{{ item.option }}'
@ -49,47 +48,46 @@
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: '0640'
create: no
create: false
loop: '{{ gitea_markup_jupyter_conf }}'
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_user: '{{ gitea_user }}'
copy:
ansible.builtin.copy:
src: 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_user: '{{ gitea_user }}'
copy:
ansible.builtin.copy:
src: header.tmpl
dest: '{{ gitea_data_dir }}/custom/templates/custom/header.tmpl'
mode: 0444
mode: "0444"
- name: Check if the awesome fonts are installed
stat:
- name: renderers | Check if the awesome fonts are installed
ansible.builtin.stat:
path: /usr/share/fonts-font-awesome
register: awesome_fonts_dir
- name: Link to the awesome fonts directory
- name: renderers | Link to the awesome fonts directory
become: true
become_user: '{{ gitea_user }}'
file:
ansible.builtin.file:
src: /usr/share/fonts-font-awesome
dest: '{{ gitea_data_dir }}/custom/public/components/font-awesome'
state: link
when: awesome_fonts_dir.stat.exists
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_jupyter' ]
- name: Configure restructuredtext markup
- name: renderers | Configure restructuredtext markup
tags: ['git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_restructuredtext']
block:
- name: Configure restructuredtext markup
ini_file:
- name: renderers | Configure restructuredtext markup
community.general.ini_file:
path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}'
option: '{{ item.option }}'
@ -98,17 +96,16 @@
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: '0640'
create: no
create: false
loop: '{{ gitea_markup_restructuredtext_conf }}'
when: gitea_install_viewer_addons
notify: restart gitea
notify: Restart gitea
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_restructuredtext' ]
- name: Configure sanitizer TeX markup
- name: renderers | Configure sanitizer TeX markup
tags: ['git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_sanitizer_tex']
block:
- name: Configure sanitizer TeX markup
ini_file:
- name: renderers | Configure sanitizer TeX markup
community.general.ini_file:
path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}'
option: '{{ item.option }}'
@ -117,17 +114,16 @@
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: '0640'
create: no
create: false
loop: '{{ gitea_markup_sanitizer_tex_conf }}'
when: gitea_install_viewer_addons
notify: restart gitea
notify: Restart gitea
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_sanitizer_tex' ]
- name: Configure markdown markup
- name: renderers | Configure markdown markup
tags: ['git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_markdown']
block:
- name: Configure markdown markup
ini_file:
- name: renderers | Configure markdown markup
community.general.ini_file:
path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}'
option: '{{ item.option }}'
@ -136,17 +132,17 @@
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: '0640'
create: no
create: false
loop: '{{ gitea_markup_markdown_conf }}'
when: gitea_install_viewer_addons
notify: restart gitea
notify: Restart gitea
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_markdown' ]
- name: Configure docx markup
- name: renderers | Configure docx markup
when: gitea_install_viewer_addons
tags: ['git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_docx']
block:
- name: Configure the docx markup
ini_file:
- name: renderers | Configure the docx markup
community.general.ini_file:
path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}'
option: '{{ item.option }}'
@ -155,17 +151,14 @@
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: '0640'
create: no
create: false
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_user: '{{ gitea_user }}'
copy:
ansible.builtin.copy:
content: "$body$"
dest: '{{ gitea_data_dir }}/custom/templates/docx-basic.html'
when: gitea_install_viewer_addons
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_docx' ]
mode: "0644"