Refactored

This commit is contained in:
Frank Dornheim 2023-03-10 18:24:27 +01:00
parent c80257320f
commit cd7a054f98
2 changed files with 61 additions and 0 deletions

View 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

View 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 }}"
...