diff --git a/README.md b/README.md index 1f13d04..59009bd 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/tasks/main.yml b/tasks/main.yml index 918d728..b396ad1 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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' @@ -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' @@ -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 }} @@ -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 }}" diff --git a/templates/app.ini.j2 b/templates/app.ini.j2 index b09c0db..bba7331 100644 --- a/templates/app.ini.j2 +++ b/templates/app.ini.j2 @@ -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 }} diff --git a/vars/main.yml b/vars/main.yml index 12a0399..d90865a 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -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: