From 2558786ef315e580ff717ba3c9342e89051ba973 Mon Sep 17 00:00:00 2001 From: meaz Date: Tue, 24 Jan 2023 08:45:17 +0000 Subject: [PATCH] add possibility to choose between forgejo or gitea (#22) Co-authored-by: meaz Co-authored-by: muppeth Reviewed-on: https://git.disroot.org/Disroot-Ansible/gitea/pulls/22 Reviewed-by: muppeth Co-authored-by: meaz Co-committed-by: meaz --- README.md | 14 +++++++++++++- defaults/main.yml | 6 +++++- tasks/install.yml | 17 +++++++++++++---- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c79b955..7eb7418 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Gitea - Ansible Role -This role covers deployment, configuration and software updates of Gitea. This role is released under MIT Licence and we give no warranty for this piece of software. Currently supported OS - Debian. +This role covers deployment, configuration and software updates of Gitea/Forgejo. This role is released under MIT Licence and we give no warranty for this piece of software. Currently supported OS - Debian. You can deploy test instance using `Vagrantfile` attached to the role. `vagrant up` @@ -9,6 +9,18 @@ You can deploy test instance using `Vagrantfile` attached to the role. Then you can then access gitea from your computer on `http://192.168.33.14:3000` +# Gitea or Forgejo +This role allows for deployment of gitea and forgejo. By default the role deploys forgejo and this is the flavor that is supported and maintained. Installing Gitea using the role is possible however starting from version 1.18.2 is no longer maintained by Disroot team. +To switch to gitea, update following variables in your Playbook/host_vars: + + +``` +gitea_flavour: 'gitea' +gitea_version: '1.18.2' +gitea_arch: 'linux-amd64' +gitea_download_url: 'https://github.com/go-gitea/gitea/releases/download/v{{ gitea_version }}/gitea-{{ gitea_version }}-{{ gitea_arch }}' +``` + ## Playbook The playbook includes postgresql role and deploys entire stack needed to run Gitea. Additional roles are also available in the Ansible roles repos in git. diff --git a/defaults/main.yml b/defaults/main.yml index babb22f..f154819 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -5,8 +5,11 @@ gitea_lib_dir: "/var/lib/gitea" gitea_user: 'git' gitea_group: 'git' gitea_confdir: '/etc/gitea/app.ini' -gitea_version: '1.18.0' +gitea_flavor: 'forgejo' +gitea_version: '1.18.2-1' +gitea_arch: 'linux-amd64' +#gitea_download_url: 'https://github.com/go-gitea/gitea/releases/download/v{{ gitea_version }}/gitea-{{ gitea_version }}-{{ gitea_arch }}' #[CONFIG] @@ -20,6 +23,7 @@ gitea_oauth2_config: - 'JWT_SECRET = ' #41 random chars gitea_ui_config: + - 'THEMES = auto,arc-green,gitea' - 'DEFAULT_THEME = arc-green' gitea_security_config: diff --git a/tasks/install.yml b/tasks/install.yml index e7a773a..6f0432e 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -5,10 +5,20 @@ name: "{{ gitea_apt_list }}" update_cache: yes +- name: '[INSTALL] - Get forgejo download url' + shell: + cmd: wget -O - https://codeberg.org/forgejo/forgejo/releases | grep -B 1 forgejo-{{ gitea_version }}-{{ gitea_arch }}\< | sed -n 's/.*href="\(.*\)".*/\1/p' + register: forgejo_url + when: gitea_flavor == 'forgejo' + +- name: "[INSTALL] - Set forgejo download url" + set_fact: + gitea_download_url: '{{ forgejo_url.stdout }}' + when: gitea_flavor == 'forgejo' - name: '[INSTALL] - Download gitea binary' get_url: - url: 'https://github.com/go-gitea/gitea/releases/download/v{{ gitea_version }}/gitea-{{ gitea_version }}-linux-amd64' + url: '{{ gitea_download_url }}' dest: '{{ gitea_bindir }}/gitea' mode: '0750' owner: '{{ gitea_user }}' @@ -16,13 +26,12 @@ force: 'yes' notify: 'Restart gitea' - -- name: '[INSTALL] - Set rights to read-only' +- name: '[INSTALL] - Set /etc/gitea rights to read-only' file: path: '/etc/gitea' mode: '0750' -- name: '[INSTALL] - Set rights to read-only' +- name: '[INSTALL] - Set app.ini rights to read-only' file: path: '/etc/gitea/app.ini' mode: '0640'