ansible-role-gitea/tasks/main.yaml
Marius Meyer c28214c517
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 25s
move data to /var/lib/gitea
2024-06-03 14:02:58 +02:00

98 lines
2.3 KiB
YAML

# - name: Install Dependencies
# apt:
# pkg:
# - apparmor
# - docker.io
# - python3-docker
- name: Ensure git user exists
ansible.builtin.user:
name: git
register: git_user
- name: Ensure Gitea directories exist
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: root
mode: "755"
recurse: yes
with_items: ["/opt/gitea", "/var/lib/gitea"]
- name: Ensure data directory exists
ansible.builtin.file:
path: "/var/lib/gitea/data"
state: directory
owner: "{{ git_user.uid }}"
group: "{{ git_user.group }}"
mode: "700"
- name: Ensure config directory exists
ansible.builtin.file:
path: "/var/lib/gitea/config"
state: directory
owner: "{{ git_user.uid }}"
group: "{{ git_user.group }}"
mode: "700"
- name: Ensure docker daemon is started
ansible.builtin.systemd:
name: docker
enabled: true
state: started
- name: Ensure old backups will get deleted
ansible.builtin.cron:
name: gitea backup cleanup
minute: "0"
hour: "8"
user: root
job: find /var/backups -path '/var/backups/gitea-*' -mtime +7 -type f -exec rm {} +
cron_file: gitea-backup-cleanup
- name: Check if environment.env will get changed
ansible.builtin.template:
src: environment.env.j2
dest: "/opt/gitea/environment.env"
owner: root
mode: "600"
register: env_diff
check_mode: true
notify:
- Backup Gitea
- name: Check if docker-compose.yaml will get changed
ansible.builtin.template:
src: docker-compose.yaml.j2
dest: /opt/gitea/docker-compose.yaml
owner: root
mode: "600"
register: docker_compose_diff
check_mode: true
notify:
- Backup Gitea
- name: Execute handlers before changing configfiles
ansible.builtin.meta: flush_handlers
- name: Upload environment.env
ansible.builtin.template:
src: environment.env.j2
dest: "/opt/gitea/environment.env"
owner: root
mode: "600"
notify:
- Ensure Gitea is restarted
- Wait until Gitea is up
- name: Upload docker-compose.yaml
ansible.builtin.template:
src: docker-compose.yaml.j2
dest: /opt/gitea/docker-compose.yaml
owner: root
mode: "600"
notify:
- Output docker compose state
- Ensure Gitea is restarted
- Wait until Gitea is up