2022-12-08 18:50:03 +00:00
|
|
|
---
|
2022-12-10 20:12:07 +00:00
|
|
|
- name: Gather variables for each operating system
|
|
|
|
include_vars: "{{ ansible_distribution | lower }}.yml"
|
|
|
|
|
|
|
|
- name: "Check gitea version"
|
|
|
|
ansible.builtin.shell: "set -eo pipefail; /usr/local/bin/gitea -v | cut -d' ' -f 3"
|
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
|
|
|
register: gitea_active_version
|
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
|
|
|
when: gitea_version_check|bool
|
|
|
|
|
|
|
|
- include_tasks: create_user.yml
|
|
|
|
|
|
|
|
- include_tasks: install.yml
|
|
|
|
|
|
|
|
- name: "Create config and data directory"
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
|
|
|
owner: "{{ gitea_user }}"
|
|
|
|
group: "{{ gitea_group }}"
|
|
|
|
mode: '0755'
|
|
|
|
with_items:
|
|
|
|
- "/etc/gitea"
|
|
|
|
|
|
|
|
- name: "Create data directory"
|
|
|
|
file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
|
|
|
owner: "{{ gitea_user }}"
|
|
|
|
group: "{{ gitea_group }}"
|
|
|
|
mode: 'u=rwX,g=rX,o='
|
|
|
|
recurse: true
|
|
|
|
with_items:
|
|
|
|
- "{{ gitea_home }}"
|
|
|
|
- "{{ gitea_home }}/data"
|
|
|
|
- "{{ gitea_home }}/custom"
|
|
|
|
- "{{ gitea_home }}/custom/https"
|
|
|
|
- "{{ gitea_home }}/custom/mailer"
|
|
|
|
- "{{ gitea_home }}/indexers"
|
|
|
|
- "{{ gitea_home }}/log"
|
|
|
|
- "{{ gitea_repository_root }}"
|
|
|
|
|
|
|
|
- include_tasks: install_systemd.yml
|
|
|
|
when: ansible_service_mgr == "systemd"
|
|
|
|
|
|
|
|
- include_tasks: jwt_secrets.yml
|
|
|
|
|
|
|
|
- name: 'Install git'
|
|
|
|
ansible.builtin.package:
|
|
|
|
name: 'git'
|
|
|
|
state: 'present'
|
|
|
|
|
|
|
|
- name: "Configure gitea"
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: gitea.ini.j2
|
|
|
|
dest: /etc/gitea/gitea.ini
|
|
|
|
owner: "{{ gitea_user }}"
|
|
|
|
group: "{{ gitea_group }}"
|
|
|
|
mode: 0600
|
|
|
|
notify: "Restart gitea"
|
|
|
|
|
|
|
|
- name: "Service gitea"
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: gitea
|
|
|
|
state: started
|
|
|
|
enabled: true
|
|
|
|
when: ansible_service_mgr == "systemd"
|
|
|
|
|