homelab/roles/gitea/tasks/main.yml

74 lines
1.5 KiB
YAML

---
- name: Ensure data directory is present
ansible.builtin.file:
path: '/mnt/data1/gitea'
state: directory
mode: '0755'
owner: 'root'
group: 'root'
- name: Ensure data subvolumes are present
community.general.btrfs_subvolume:
name: '/gitea/{{ item }}'
loop:
- 'data'
- 'lfs'
- 'repositories'
- 'postgres'
- name: Ensure configuration directory is present
ansible.builtin.file:
path: '/etc/gitea'
state: directory
mode: '0755'
- name: Ensure compose file is present
ansible.builtin.copy:
src: 'compose.yml'
dest: '/etc/gitea/compose.yml'
mode: '0644'
owner: 'root'
group: 'root'
notify: 'restart gitea'
- name: Ensure config file is present
ansible.builtin.template:
src: 'app.ini.j2'
dest: '/etc/gitea/app.ini'
mode: '0644'
owner: 'root'
group: 'root'
notify: 'restart gitea'
- name: Ensure backup scripts are present
ansible.builtin.copy:
src: "gitea.{{ item }}.backup.sh"
dest: "/etc/backups/gitea.{{ item }}.backup.sh"
owner: 'root'
group: 'root'
mode: '0644'
loop:
- 'postgres'
- 'data'
- 'lfs'
- 'repositories'
- name: Ensure service file is present
ansible.builtin.copy:
src: 'gitea.service'
dest: '/lib/systemd/system/gitea.service'
owner: 'root'
group: 'root'
mode: '0644'
register: res
- name: systemd-reload
ansible.builtin.systemd_service:
daemon_reload: true
when: 'res.changed'
- name: Ensure gitea service is enabled
ansible.builtin.service:
name: 'gitea'
enabled: true