Add repos tasks for forgejo

This commit is contained in:
flyingscorpio@clevo 2023-01-18 10:29:33 +01:00
parent 60461a192b
commit bf6ddb08e6
2 changed files with 37 additions and 0 deletions

View file

@ -23,3 +23,6 @@
# fail2ban tasks need the forgejo log file, which should be created when forgejo runs
- name: Include fail2ban tasks
ansible.builtin.include_tasks: fail2ban.yml
- name: Include repos tasks
ansible.builtin.include_tasks: repos.yml

View file

@ -0,0 +1,34 @@
---
- name: Ask to push latest forgejo_dump zipfile
ansible.builtin.pause:
prompt: "Local path to forgejo dump, so we can push it [leave empty to not push]"
echo: true
register: user_forgejo_dump_path
- name: Push latest forgejo dump zipfile
become: true
ansible.builtin.copy:
src: "{{ user_forgejo_dump_path.user_input }}"
dest: "{{ forgejo_run_dir }}/forgejo-dumps/{{ user_forgejo_dump_path.user_input | basename }}"
owner: git
group: git
mode: 0640
when: user_forgejo_dump_path.user_input != ''
- name: Find all forgejo dumps on the server
become: true
ansible.builtin.find:
paths: "{{ forgejo_run_dir }}/forgejo-dumps/"
register: all_forgejo_dumps
- name: Find latest forgejo dump on the server
ansible.builtin.set_fact:
latest_forgejo_dump: "{{ all_forgejo_dumps.files | sort(attribute='mtime') | last }}"
- name: Deploy repos from latest forgejo dump
become: true
become_user: git
ansible.builtin.command:
cmd: "/usr/local/bin/forgejo_backup.sh restore {{ latest_forgejo_dump.path }}"
# when this dir exists, the command won't run, so we don't overwrite existing repos
creates: "{{ forgejo_run_dir }}/forgejo-repositories"