infrastructure/roles/lvm-self-backup/tasks/main.yml

62 lines
1.7 KiB
YAML
Raw Normal View History

2020-08-10 01:37:13 +02:00
---
# 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
file:
path: "/backup_snapshots/{{ item.vg_name }}-{{ item.lv_name }}"
state: directory
recurse: true
with_items:
- "{{ backup_vols }}"
become: true
- name: Install backup scripts.
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: '1700'
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 service & timer.
template:
src: "{{ item }}"
dest: /etc/systemd/system/
mode: '0755'
owner: root
group: root
with_items:
- "backup-lvm.service"
- "backup-lvm.timer"
become: true
- name: Start & enable backup service timer.
systemd:
daemon_reload: yes
name: backup-lvm.timer
enabled: '{{ backup_timer_enabled | bool }}'
state: '{{ backup_timer_state }}'
become: true