infrastructure/roles/lvm_self_backup/tasks/main.yml
saibotk 4dfd382a75
feat(lvm_self_backup): Add error service when systemd service fails
This is to be notified when the systemd service fails to e.g. unmount the partition.
2024-02-21 22:25:46 +01:00

78 lines
2.2 KiB
YAML

---
# Tasks file for the lvm_self_backup role
# Infrastructure
# Ansible instructions to deploy the infrastructure
# Copyright (C) 2020 Saibotk
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
- name: Create backup mount directories
ansible.builtin.file:
path: "/lvm_self_backup_snapshots/{{ item.vg_name }}-{{ item.lv_name }}"
state: directory
mode: "0700"
owner: "root"
group: "root"
recurse: true
with_items:
- "{{ lvm_self_backup_vols }}"
become: true
- name: Create backup status directory
ansible.builtin.file:
path: "{{ item }}"
state: directory
mode: "0700"
owner: "{{ lvm_self_backup_status_directory_uid }}"
group: "{{ lvm_self_backup_status_directory_gid }}"
recurse: true
with_items:
- "{{ lvm_self_backup_status_directory }}"
become: true
- name: Install backup scripts.
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "0700"
owner: "root"
group: "root"
with_items:
- src: "backup-lvm.sh"
dest: "/usr/local/bin/backup-lvm"
- src: "backup-lvm-ls.sh"
dest: "/usr/local/bin/backup-lvm-ls"
become: true
- name: Install backup services & timer.
ansible.builtin.template:
src: "{{ item }}"
dest: /etc/systemd/system/
mode: "0600"
owner: "root"
group: "root"
with_items:
- "backup-error.service"
- "backup-lvm.service"
- "backup-lvm.timer"
notify: Reload systemd config
become: true
- name: Start & enable backup service timer.
ansible.builtin.systemd:
daemon_reload: true
name: backup-lvm.timer
enabled: "{{ lvm_self_backup_timer_enabled | bool }}"
state: "{{ lvm_self_backup_timer_state }}"
become: true