feat: make ansible-lint happier
This commit is contained in:
13
roles/borg_client/defaults/main.yml
Normal file
13
roles/borg_client/defaults/main.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
|
||||
borg_pass: !vault |
|
||||
$ANSIBLE_VAULT;1.1;AES256
|
||||
62333166623737363731663766353330633335306532306366356536376232396664376430613434
|
||||
3966376539303238376461386262663066376338386537660a376365643761653463393539316232
|
||||
30653130383761653432306136333733653062356635643662616133366663646132383136313530
|
||||
3866343664393330610a623930316330626166343934623230313232626131386132393866373661
|
||||
6336
|
||||
borg_backup_path: ["/srv", "/home", "/etc"]
|
||||
borg_backup_excluded_path: ["/srv/NOBACKUP"]
|
||||
borg_backup_hour: 6
|
||||
borg_backup_minute: 0
|
28
roles/borg_client/tasks/main.yml
Normal file
28
roles/borg_client/tasks/main.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
|
||||
- name: create SSH key
|
||||
openssh_keypair:
|
||||
path: ~/.ssh/id_rsa
|
||||
|
||||
- name: get SSH pub key
|
||||
command: cat ~/.ssh/id_rsa.pub
|
||||
register: ssh_keys
|
||||
|
||||
- name: put backup script
|
||||
template:
|
||||
src: borgbackup.sh.j2
|
||||
dest: /usr/local/bin/borgbackup.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0750'
|
||||
|
||||
- name: cron the backup script
|
||||
cron:
|
||||
name: "borg backup script"
|
||||
hour: "{{ borg_backup_hour }}"
|
||||
minute: "{{ borg_backup_minute }}"
|
||||
job: /usr/local/bin/borgbackup.sh
|
||||
|
||||
- name: warns about borg init
|
||||
debug:
|
||||
msg: "Borg has been installed. Don’t forget to init with: \nborg init --encryption=repokey-blake2 backup@{{ hostvars[groups['borg_server'][0]]['ansible_fqdn'] }}:home"
|
12
roles/borg_client/templates/borgbackup.sh.j2
Normal file
12
roles/borg_client/templates/borgbackup.sh.j2
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
## Variable
|
||||
export BORG_PASSPHRASE="{{ borg_pass }}"
|
||||
|
||||
## lancement de la sauvegarde
|
||||
borg create --exclude-caches {% for f in borg_backup_excluded_path %}-e {{ f }} {% endfor %} -s backup@{{ hostvars[groups['borg_server'][0]]['ansible_fqdn'] }}:home::{now:%Y-%m-%d} {% for f in borg_backup_path %}{{ f }} {% endfor %}
|
||||
|
||||
|
||||
## récupération de l'espace
|
||||
borg prune -d 7 -w 4 -m 3 backup@{{ hostvars[groups['borg_server'][0]]['ansible_fqdn'] }}:home
|
||||
|
Reference in New Issue
Block a user