2021-01-21 09:07:19 +01:00
|
|
|
---
|
2022-01-10 09:01:52 +01:00
|
|
|
- name: Gather variables for each operating system
|
|
|
|
include_vars: "{{ item }}"
|
|
|
|
with_first_found:
|
|
|
|
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
|
|
|
|
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
|
|
|
|
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
|
|
|
|
- "{{ ansible_distribution | lower }}.yml"
|
|
|
|
- "{{ ansible_os_family | lower }}.yml"
|
2021-01-21 09:07:19 +01:00
|
|
|
|
2022-01-10 09:01:52 +01:00
|
|
|
- name: Gather installed packages for checks in the role (fail2ban)
|
|
|
|
ansible.builtin.package_facts:
|
|
|
|
manager: auto
|
2021-01-21 09:07:19 +01:00
|
|
|
|
|
|
|
- name: "Check gitea version"
|
2022-01-10 09:01:52 +01:00
|
|
|
ansible.builtin.shell: "set -eo pipefail; /usr/local/bin/gitea -v | cut -d' ' -f 3"
|
2021-01-21 09:07:19 +01:00
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
|
|
|
register: gitea_active_version
|
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
|
|
|
when: gitea_version_check|bool
|
|
|
|
|
|
|
|
- name: "Download the binary"
|
2022-01-10 09:01:52 +01:00
|
|
|
ansible.builtin.get_url:
|
2021-01-21 09:07:19 +01:00
|
|
|
url: "{{ gitea_dl_url }}"
|
|
|
|
dest: /usr/local/bin/gitea
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0755
|
|
|
|
force: true
|
|
|
|
notify: "Restart gitea"
|
|
|
|
when: (not gitea_version_check|bool) or (not ansible_check_mode and (gitea_active_version.stdout != gitea_version))
|
|
|
|
|
|
|
|
- include: create_user.yml
|
|
|
|
|
|
|
|
- name: "Create config and data directory"
|
2022-01-10 09:01:52 +01:00
|
|
|
ansible.builtin.file:
|
2021-01-21 09:07:19 +01:00
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
|
|
|
owner: "{{ gitea_user }}"
|
2022-01-10 09:01:52 +01:00
|
|
|
group: "{{ gitea_group }}"
|
|
|
|
mode: '0755'
|
2021-01-21 09:07:19 +01:00
|
|
|
with_items:
|
|
|
|
- "/etc/gitea"
|
2022-01-10 09:01:52 +01:00
|
|
|
|
|
|
|
- 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:
|
2021-01-21 09:07:19 +01:00
|
|
|
- "{{ gitea_home }}"
|
|
|
|
- "{{ gitea_home }}/data"
|
|
|
|
- "{{ gitea_home }}/custom"
|
|
|
|
- "{{ gitea_home }}/custom/https"
|
|
|
|
- "{{ gitea_home }}/custom/mailer"
|
|
|
|
- "{{ gitea_home }}/indexers"
|
|
|
|
- "{{ gitea_home }}/log"
|
2022-01-10 09:01:52 +01:00
|
|
|
- "{{ gitea_repository_root }}"
|
2021-01-21 09:07:19 +01:00
|
|
|
|
|
|
|
- include: install_systemd.yml
|
|
|
|
when: ansible_service_mgr == "systemd"
|
|
|
|
|
2022-01-10 09:01:52 +01:00
|
|
|
- include_tasks: jwt_secrets.yml
|
2021-01-21 09:07:19 +01:00
|
|
|
- name: 'Install git'
|
2022-01-10 09:01:52 +01:00
|
|
|
ansible.builtin.package:
|
2021-01-21 09:07:19 +01:00
|
|
|
name: 'git'
|
|
|
|
state: 'present'
|
|
|
|
|
|
|
|
- name: "Configure gitea"
|
2022-01-10 09:01:52 +01:00
|
|
|
ansible.builtin.template:
|
2021-01-21 09:07:19 +01:00
|
|
|
src: gitea.ini.j2
|
|
|
|
dest: /etc/gitea/gitea.ini
|
|
|
|
owner: "{{ gitea_user }}"
|
2022-01-10 09:01:52 +01:00
|
|
|
group: "{{ gitea_group }}"
|
2021-01-21 09:07:19 +01:00
|
|
|
mode: 0600
|
|
|
|
notify: "Restart gitea"
|
|
|
|
|
|
|
|
- name: "Service gitea"
|
2022-01-10 09:01:52 +01:00
|
|
|
ansible.builtin.service:
|
2021-01-21 09:07:19 +01:00
|
|
|
name: gitea
|
|
|
|
state: started
|
|
|
|
enabled: true
|
|
|
|
when: ansible_service_mgr == "systemd"
|
|
|
|
|
|
|
|
- include: fail2ban.yml
|
|
|
|
when: gitea_fail2ban_enabled|bool
|