Skip to content

Commit f493175

Browse files
committed
Support for Gitea 1.17.0, drop support for older versions
Gitea 1.17.0 changed the Gitea user's home directory. See: go-gitea/gitea#20114 go-gitea/gitea#19732
1 parent c31ebaa commit f493175

File tree

4 files changed

+31
-21
lines changed

4 files changed

+31
-21
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ It is also possible to configure external authentication sources.
99
Requirements
1010
------------
1111

12+
Gitea versions older than 1.17.0 are not (fully) supported.
13+
Depending on the exact configuration, they may or may not work.
14+
1215
If TLS encryption (i.e. HTTPS) is desired, the target system needs to have a suitable X.509 certificate.
1316
This roles does not handle deploying certificates.
1417

tasks/main.yml

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,6 @@
9090
state: present
9191
when: "ansible_facts['service_mgr'] != 'systemd' and gitea_port | int < 1024"
9292

93-
- name: 'create required directories'
94-
file:
95-
path: "{{ directory.path }}"
96-
state: directory
97-
owner: "{{ directory.owner | default(gitea_user) }}"
98-
group: "{{ directory.group | default(gitea_group) }}"
99-
mode: "{{ directory.mode | default('0750') }}"
100-
loop:
101-
- path: '/etc/gitea'
102-
owner: root
103-
- path: "{{ gitea_data_path }}"
104-
- path: "{{ gitea_custom_path }}"
105-
owner: root
106-
- path: "{{ gitea_log_path }}"
107-
loop_control:
108-
loop_var: directory
109-
label: "{{ directory.path }}"
110-
11193
- name: 'check if Gitea is already configured'
11294
stat:
11395
path: '/etc/gitea/app.ini'
@@ -128,6 +110,29 @@
128110
loop_control:
129111
loop_var: secret
130112

113+
- name: 'combine default and custom options'
114+
set_fact:
115+
_gitea_options: "{{ gitea_default_options | combine(gitea_extra_options, recursive=True) }}"
116+
117+
- name: 'create required directories'
118+
file:
119+
path: "{{ directory.path }}"
120+
state: directory
121+
owner: "{{ directory.owner | default(gitea_user) }}"
122+
group: "{{ directory.group | default(gitea_group) }}"
123+
mode: "{{ directory.mode | default('0750') }}"
124+
loop:
125+
- path: '/etc/gitea'
126+
owner: root
127+
- path: "{{ gitea_data_path }}"
128+
- path: "{{ _gitea_options['git']['HOME_PATH'] }}"
129+
- path: "{{ gitea_custom_path }}"
130+
owner: root
131+
- path: "{{ gitea_log_path }}"
132+
loop_control:
133+
loop_var: directory
134+
label: "{{ directory.path }}"
135+
131136
- name: 'configure Gitea'
132137
template:
133138
dest: '/etc/gitea/app.ini'
@@ -152,7 +157,7 @@
152157
command: "su {{ gitea_user }} -c 'gpg --batch --generate-key'"
153158
args:
154159
warn: false # su is needed, otherwise Ansible might require a password to become the gitea user
155-
creates: "{{ gitea_data_path }}/.gnupg/private-keys-v1.d/"
160+
creates: "{{ _gitea_options['git']['HOME_PATH'] }}/.gnupg/private-keys-v1.d/"
156161
stdin: |
157162
%no-protection
158163
Key-Type: {{ gitea_signing_key_type }}
@@ -166,7 +171,7 @@
166171

167172
- name: 'configure git command line client'
168173
ini_file:
169-
path: "{{ gitea_data_path }}/.gitconfig"
174+
path: "{{ _gitea_options['git']['HOME_PATH'] }}/.gitconfig"
170175
section: "{{ item.section }}"
171176
option: "{{ item.option }}"
172177
value: "{{ item.value }}"

templates/app.ini.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{# vim: filetype=ini.jinja2 #}
22
{{ ansible_managed | comment }}
33

4-
{% for key, options in (gitea_default_options | combine(gitea_extra_options, recursive=True)).items() %}
4+
{% for key, options in _gitea_options.items() %}
55
[{{ key }}]
66
{% for k, v in options.items() if v != omit %}
77
{{ k }} = {{ v }}

vars/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ gitea_default_options:
99
repository:
1010
ROOT: "{{ gitea_data_path }}/repos"
1111
SCRIPT_TYPE: "{{ _bin_bash.stat.exists | ternary('bash', 'sh') }}"
12+
git:
13+
HOME_PATH: "{{ _gitea_options['server']['APP_DATA_PATH'] | default(gitea_data_path) ~ '/data/' }}/home"
1214
repository.signing:
1315
SIGNING_KEY: "{{ gitea_enable_signing | bool | ternary('default', 'none') }}"
1416
server:

0 commit comments

Comments
 (0)