mirror of
https://github.com/borgbase/ansible-role-borgbackup.git
synced 2025-05-20 01:15:09 +02:00
Refactored
This commit is contained in:
parent
c80257320f
commit
cd7a054f98
22
tasks/07_install_timer.yml
Normal file
22
tasks/07_install_timer.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
- name: Create borgbackup timer
|
||||||
|
when:
|
||||||
|
- install_backup is not defined or install_backup
|
||||||
|
- borgmatic_timer is defined and borgmatic_timer == "systemd"
|
||||||
|
tags:
|
||||||
|
- install_backup
|
||||||
|
block:
|
||||||
|
- name: Timer Systemd
|
||||||
|
ansible.builtin.include_tasks:
|
||||||
|
file: noauto_create_timer.yml
|
||||||
|
|
||||||
|
- name: Create borgbackup cron
|
||||||
|
when:
|
||||||
|
- install_backup is not defined or install_backup
|
||||||
|
- borgmatic_timer is defined or borgmatic_timer == "cron"
|
||||||
|
tags:
|
||||||
|
- install_backup
|
||||||
|
block:
|
||||||
|
- name: Install cron backup job
|
||||||
|
ansible.builtin.include_tasks:
|
||||||
|
file: noauto_create_cronjobs.yml
|
39
tasks/noauto_create_backup_user_and_group.yml
Normal file
39
tasks/noauto_create_backup_user_and_group.yml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
---
|
||||||
|
- name: Setup backup environment
|
||||||
|
tags:
|
||||||
|
- install_backup
|
||||||
|
when:
|
||||||
|
- install_backup is not defined or install_backup
|
||||||
|
- backup_create_local_user is not defined or backup_create_local_user
|
||||||
|
- borgbackup_user != "root"
|
||||||
|
block:
|
||||||
|
- name: Add local backup group
|
||||||
|
ansible.builtin.group:
|
||||||
|
name: "{{ borgbackup_group }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Add local backup user
|
||||||
|
ansible.builtin.user:
|
||||||
|
name: "{{ borgbackup_user }}"
|
||||||
|
shell: "/bin/bash"
|
||||||
|
groups: "{{ borgbackup_group }}"
|
||||||
|
comment: "Backup User Account"
|
||||||
|
append: true
|
||||||
|
register: user_info
|
||||||
|
|
||||||
|
- name: Save the user_info, we need them for the home_dir
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
backup_user_info: "{{ user_info }}"
|
||||||
|
|
||||||
|
- name: Add sudo users
|
||||||
|
community.general.sudoers:
|
||||||
|
name: "backup"
|
||||||
|
state: present
|
||||||
|
user: "{{ borgbackup_user }}"
|
||||||
|
nopassword: true
|
||||||
|
commands:
|
||||||
|
- "/opt/borgmatic/bin/borg"
|
||||||
|
- "/usr/local/bin/borgmatic -C -p -c /etc/borgmatic/{{ borgmatic_config_name }}"
|
||||||
|
- "/usr/local/bin/borgmatic -k -c /etc/borgmatic/{{ borgmatic_config_name }}"
|
||||||
|
- "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}"
|
||||||
|
...
|
Loading…
Reference in New Issue
Block a user