infrastructure/roles/lvm_self_backup/tasks/main.yml

79 lines
2.2 KiB
YAML
Raw Normal View History

2020-08-10 01:37:13 +02:00
---
# Tasks file for the lvm_self_backup role
2020-08-10 01:37:13 +02:00
# 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
2022-08-13 17:50:54 +02:00
ansible.builtin.file:
path: "/lvm_self_backup_snapshots/{{ item.vg_name }}-{{ item.lv_name }}"
2020-08-10 01:37:13 +02:00
state: directory
mode: "0700"
owner: "root"
group: "root"
2020-08-10 01:37:13 +02:00
recurse: true
with_items:
- "{{ lvm_self_backup_vols }}"
2020-08-10 01:37:13 +02:00
become: true
- name: Create backup status directory
2022-08-13 17:50:54 +02:00
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
2020-08-10 01:37:13 +02:00
- name: Install backup scripts.
2022-08-13 17:50:54 +02:00
ansible.builtin.template:
2020-08-10 01:37:13 +02:00
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "0700"
owner: "root"
group: "root"
2020-08-10 01:37:13 +02:00
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.
2022-08-13 17:50:54 +02:00
ansible.builtin.template:
2020-08-10 01:37:13 +02:00
src: "{{ item }}"
dest: /etc/systemd/system/
mode: "0600"
owner: "root"
group: "root"
2020-08-10 01:37:13 +02:00
with_items:
- "backup-error.service"
2020-08-10 01:37:13 +02:00
- "backup-lvm.service"
- "backup-lvm.timer"
notify: Reload systemd config
2020-08-10 01:37:13 +02:00
become: true
- name: Start & enable backup service timer.
2022-08-13 17:50:54 +02:00
ansible.builtin.systemd:
2021-03-05 13:02:55 +01:00
daemon_reload: true
2020-08-10 01:37:13 +02:00
name: backup-lvm.timer
enabled: "{{ lvm_self_backup_timer_enabled | bool }}"
state: "{{ lvm_self_backup_timer_state }}"
2020-08-10 01:37:13 +02:00
become: true