style(borgbackup): linting

This commit is contained in:
VC
2024-07-05 11:53:13 +02:00
parent 9b3649ea74
commit 2996773e1e
4 changed files with 42 additions and 35 deletions

View File

@@ -1,3 +1,5 @@
---
borg_pass: !vault | borg_pass: !vault |
$ANSIBLE_VAULT;1.1;AES256 $ANSIBLE_VAULT;1.1;AES256
62333166623737363731663766353330633335306532306366356536376232396664376430613434 62333166623737363731663766353330633335306532306366356536376232396664376430613434

View File

@@ -1,6 +1,8 @@
---
- name: create SSH key - name: create SSH key
openssh_keypair: openssh_keypair:
path: ~/.ssh/id_rsa path: ~/.ssh/id_rsa
- name: get SSH pub key - name: get SSH pub key
command: cat ~/.ssh/id_rsa.pub command: cat ~/.ssh/id_rsa.pub
@@ -8,19 +10,19 @@
- name: put backup script - name: put backup script
template: template:
src: borgbackup.sh.j2 src: borgbackup.sh.j2
dest: /usr/local/bin/borgbackup.sh dest: /usr/local/bin/borgbackup.sh
owner: root owner: root
group: root group: root
mode: '0750' mode: '0750'
- name: cron the backup script - name: cron the backup script
cron: cron:
name: "borg backup script" name: "borg backup script"
hour: "{{ borg_backup_hour }}" hour: "{{ borg_backup_hour }}"
minute: "{{ borg_backup_minute }}" minute: "{{ borg_backup_minute }}"
job: /usr/local/bin/borgbackup.sh job: /usr/local/bin/borgbackup.sh
- name: warns about borg init - name: warns about borg init
debug: debug:
msg: "Borg has been installed. Dont forget to init with: \nborg init --encryption=repokey-blake2 backup@{{ hostvars[groups['borg_server'][0]]['ansible_fqdn'] }}:home" msg: "Borg has been installed. Dont forget to init with: \nborg init --encryption=repokey-blake2 backup@{{ hostvars[groups['borg_server'][0]]['ansible_fqdn'] }}:home"

View File

@@ -1,34 +1,36 @@
---
- name: mount backup disk - name: mount backup disk
mount: mount:
path: /backup path: /backup
src: LABEL=BACKUP src: LABEL=BACKUP
fstype: ext4 fstype: ext4
opts: noatime,nofail opts: noatime,nofail
state: mounted state: mounted
- name: create backup user - name: create backup user
user: user:
name: backup name: backup
comment: Backup comment: Backup
create_home: yes create_home: true
home: /backup home: /backup
shell: /bin/bash shell: /bin/bash
system: yes system: true
state: present state: present
- name: "create directory for borg clients" - name: "create directory for borg clients"
file: file:
path: "/backup/repos/{{ hostvars[item]['ansible_fqdn'] }}" path: "/backup/repos/{{ hostvars[item]['ansible_fqdn'] }}"
state: directory state: directory
mode: '0750' mode: '0750'
owner: backup owner: backup
group: backup group: backup
loop: "{{ groups['borg_client'] }}" loop: "{{ groups['borg_client'] }}"
- name: "set authorized_keys for borg clients" - name: "set authorized_keys for borg clients"
authorized_key: authorized_key:
user: backup user: backup
key: "{{ hostvars[item]['ssh_keys']['stdout'] }}" key: "{{ hostvars[item]['ssh_keys']['stdout'] }}"
key_options: "command=\"cd /backup/repos/{{ hostvars[item]['ansible_fqdn'] }}; borg serve --restrict-to-path /backup/repos/{{ hostvars[item]['ansible_fqdn'] }}\"" key_options: "command=\"cd /backup/repos/{{ hostvars[item]['ansible_fqdn'] }}; borg serve --restrict-to-path /backup/repos/{{ hostvars[item]['ansible_fqdn'] }}\""
state: present state: present
loop: "{{ groups['borg_client'] }}" loop: "{{ groups['borg_client'] }}"

View File

@@ -1,3 +1,5 @@
---
- set_fact: - set_fact:
borgbackup: borg borgbackup: borg
when: ansible_facts['distribution'] == "Archlinux" when: ansible_facts['distribution'] == "Archlinux"
@@ -6,6 +8,5 @@
when: ansible_facts['distribution'] == "Debian" when: ansible_facts['distribution'] == "Debian"
- name: install borg package - name: install borg package
package: package:
name: "{{ borgbackup }}" name: "{{ borgbackup }}"
state: present state: present
# when: ansible_facts['distribution'] == "Debian"