2021-02-13 05:32:27 +01:00
|
|
|
---
|
|
|
|
- name: Get service facts
|
2021-03-22 21:21:25 +01:00
|
|
|
ansible.builtin.service_facts:
|
2021-02-13 05:32:27 +01:00
|
|
|
|
2022-06-08 11:20:53 +02:00
|
|
|
- name: Backup block
|
2022-09-29 23:09:19 +02:00
|
|
|
when:
|
|
|
|
- ansible_facts.services["gitea.service"] is defined
|
|
|
|
- ansible_facts.services["gitea.service"].state == "running"
|
|
|
|
- gitea_active_version.stdout != gitea_version_target
|
2022-06-08 11:20:53 +02:00
|
|
|
block:
|
2021-02-13 05:32:27 +01:00
|
|
|
- name: Stopping gitea before upgrade
|
2021-03-22 21:21:25 +01:00
|
|
|
become: true
|
|
|
|
ansible.builtin.systemd:
|
2021-02-13 05:32:27 +01:00
|
|
|
name: gitea
|
|
|
|
state: stopped
|
2021-03-22 21:21:25 +01:00
|
|
|
when: ansible_service_mgr == "systemd"
|
2021-02-13 05:32:27 +01:00
|
|
|
|
|
|
|
- name: "Create backup directory"
|
2021-03-22 21:21:25 +01:00
|
|
|
become: true
|
|
|
|
ansible.builtin.file:
|
2021-02-13 05:32:27 +01:00
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
|
|
|
owner: "{{ gitea_user }}"
|
|
|
|
group: "{{ gitea_group }}"
|
|
|
|
mode: 'u=rwx,g=rx,o='
|
|
|
|
with_items:
|
|
|
|
- "{{ gitea_backup_location }}"
|
|
|
|
|
|
|
|
- name: Backing up gitea before upgrade
|
2022-01-23 14:08:46 +01:00
|
|
|
become: true
|
2021-03-22 21:21:25 +01:00
|
|
|
ansible.builtin.command:
|
2022-08-22 13:33:20 +02:00
|
|
|
cmd: "sudo -u {{ gitea_user }} {{ gitea_executable_path }} dump -c {{ gitea_configuraion_path }}/gitea.ini"
|
2021-02-13 05:32:27 +01:00
|
|
|
chdir: "{{ gitea_backup_location }}"
|
2022-03-27 05:19:36 +02:00
|
|
|
changed_when: true
|
2022-05-04 20:42:23 +02:00
|
|
|
rescue:
|
|
|
|
- name: Starting gitea because backup failed
|
|
|
|
become: true
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: gitea
|
|
|
|
state: stopped
|
|
|
|
when: ansible_service_mgr == "systemd"
|
|
|
|
|
2022-09-29 23:09:19 +02:00
|
|
|
- name: Print updateing error
|
2022-05-04 20:42:23 +02:00
|
|
|
ansible.builtin.debug:
|
|
|
|
msg: "failed to backup gitea"
|