--- - 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: 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: 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: gitea | Create the gitea conf directory ansible.builtin.file: dest: "{{ gitea_conf_dir }}" state: directory owner: root group: "{{ gitea_group }}" mode: "0750" - 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: gitea | Create the gitea log directory ansible.builtin.file: dest: '{{ gitea_log_dir }}' state: directory owner: '{{ gitea_user }}' group: '{{ gitea_group }}' mode: "0755" - 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: 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: gitea | Install the required packages ansible.builtin.package: state: present use: auto name: "{{ gitea_required_packages }}" - 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: gitea | Manage the gitea configuration settings tags: [git, gitea, gitea_conf] block: - 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: 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/assets/css' - 'public/assets/components' - 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 - 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 - name: gitea | Configure some repository archives cron jobs 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_rep_archives_configuration }}' when: gitea_enable_repository_archives_cron_jobs notify: Restart gitea - name: gitea | Gitea systemd service tags: ['git', 'gitea', 'gitea_service'] block: - 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: 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