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
|
|
|
|
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"
|
|
|
|
|
|
|
|
- name: print updateing error
|
|
|
|
ansible.builtin.debug:
|
|
|
|
msg: "failed to backup gitea"
|
2021-02-13 05:32:27 +01:00
|
|
|
when:
|
|
|
|
- ansible_facts.services["gitea.service"] is defined
|
|
|
|
- ansible_facts.services["gitea.service"].state == "running"
|
2021-07-16 02:43:58 +02:00
|
|
|
- gitea_active_version.stdout != gitea_version_target
|