Skip to content

Commit

Permalink
Support for Gitea 1.17.0, drop support for older versions
Browse files Browse the repository at this point in the history
Gitea 1.17.0 changed the Gitea user's home directory. See:
go-gitea/gitea#20114
go-gitea/gitea#19732
  • Loading branch information
s-hamann committed Aug 20, 2022
1 parent c31ebaa commit f493175
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 21 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ It is also possible to configure external authentication sources.
Requirements
------------

Gitea versions older than 1.17.0 are not (fully) supported.
Depending on the exact configuration, they may or may not work.

If TLS encryption (i.e. HTTPS) is desired, the target system needs to have a suitable X.509 certificate.
This roles does not handle deploying certificates.

Expand Down
45 changes: 25 additions & 20 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,6 @@
state: present
when: "ansible_facts['service_mgr'] != 'systemd' and gitea_port | int < 1024"

- name: 'create required directories'
file:
path: "{{ directory.path }}"
state: directory
owner: "{{ directory.owner | default(gitea_user) }}"
group: "{{ directory.group | default(gitea_group) }}"
mode: "{{ directory.mode | default('0750') }}"
loop:
- path: '/etc/gitea'
owner: root
- path: "{{ gitea_data_path }}"
- path: "{{ gitea_custom_path }}"
owner: root
- path: "{{ gitea_log_path }}"
loop_control:
loop_var: directory
label: "{{ directory.path }}"

- name: 'check if Gitea is already configured'
stat:
path: '/etc/gitea/app.ini'
Expand All @@ -128,6 +110,29 @@
loop_control:
loop_var: secret

- name: 'combine default and custom options'
set_fact:
_gitea_options: "{{ gitea_default_options | combine(gitea_extra_options, recursive=True) }}"

- name: 'create required directories'
file:
path: "{{ directory.path }}"
state: directory
owner: "{{ directory.owner | default(gitea_user) }}"
group: "{{ directory.group | default(gitea_group) }}"
mode: "{{ directory.mode | default('0750') }}"
loop:
- path: '/etc/gitea'
owner: root
- path: "{{ gitea_data_path }}"
- path: "{{ _gitea_options['git']['HOME_PATH'] }}"
- path: "{{ gitea_custom_path }}"
owner: root
- path: "{{ gitea_log_path }}"
loop_control:
loop_var: directory
label: "{{ directory.path }}"

- name: 'configure Gitea'
template:
dest: '/etc/gitea/app.ini'
Expand All @@ -152,7 +157,7 @@
command: "su {{ gitea_user }} -c 'gpg --batch --generate-key'"
args:
warn: false # su is needed, otherwise Ansible might require a password to become the gitea user
creates: "{{ gitea_data_path }}/.gnupg/private-keys-v1.d/"
creates: "{{ _gitea_options['git']['HOME_PATH'] }}/.gnupg/private-keys-v1.d/"
stdin: |
%no-protection
Key-Type: {{ gitea_signing_key_type }}
Expand All @@ -166,7 +171,7 @@

- name: 'configure git command line client'
ini_file:
path: "{{ gitea_data_path }}/.gitconfig"
path: "{{ _gitea_options['git']['HOME_PATH'] }}/.gitconfig"
section: "{{ item.section }}"
option: "{{ item.option }}"
value: "{{ item.value }}"
Expand Down
2 changes: 1 addition & 1 deletion templates/app.ini.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{# vim: filetype=ini.jinja2 #}
{{ ansible_managed | comment }}

{% for key, options in (gitea_default_options | combine(gitea_extra_options, recursive=True)).items() %}
{% for key, options in _gitea_options.items() %}
[{{ key }}]
{% for k, v in options.items() if v != omit %}
{{ k }} = {{ v }}
Expand Down
2 changes: 2 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ gitea_default_options:
repository:
ROOT: "{{ gitea_data_path }}/repos"
SCRIPT_TYPE: "{{ _bin_bash.stat.exists | ternary('bash', 'sh') }}"
git:
HOME_PATH: "{{ _gitea_options['server']['APP_DATA_PATH'] | default(gitea_data_path) ~ '/data/' }}/home"
repository.signing:
SIGNING_KEY: "{{ gitea_enable_signing | bool | ternary('default', 'none') }}"
server:
Expand Down

0 comments on commit f493175

Please sign in to comment.