rsync_backup: Add support for configuring clients

This commit is contained in:
Timo Makinen 2025-08-03 14:37:34 +00:00
parent f8dba6d387
commit 381b681550
7 changed files with 43 additions and 4 deletions

View file

@ -67,6 +67,12 @@
loop_control:
loop_var: role
- name: Configure rsync backup client
ansible.builtin.include_role:
name: rsync_backup
tasks_from: client
when: "'rsyncbackup' in group_names"
- name: Install roles for physical hardware
ansible.builtin.include_role:
name: "{{ role }}"

View file

@ -0,0 +1,2 @@
---
rsync_backup_client: "{{ inventory_hostname }}"

View file

@ -1,4 +0,0 @@
---
dependencies:
- {role: backup_base}
- {role: ssh_known_hosts}

View file

@ -0,0 +1,15 @@
---
- name: Add backup server ssh key
ansible.posix.authorized_key:
user: root
key: "{{ lookup('file', '../../files/ssh/rsync-backup.pub') }}"
delegate_to: "{{ rsync_backup_client }}"
- name: Create client config
ansible.builtin.template:
dest: "/etc/rsync-backup/{{ rsync_backup_client }}.conf"
src: client.conf.j2
mode: "0750"
owner: root
group: "{{ hostvars['backup02.home.foo.sh']['ansible_wheel'] }}"
delegate_to: backup02.home.foo.sh

View file

@ -1,4 +1,11 @@
---
- name: Add dependencies
ansible.builtin.include_role:
name: "{{ item }}"
with_items:
- backup_base
- ssh_known_hosts
- name: Copy backup script
ansible.builtin.copy:
dest: /usr/local/sbin/backup-daily
@ -49,3 +56,12 @@
job: /usr/local/sbin/backup-daily -a -p -r
hour: "00"
minute: "30"
- name: Create client configs
ansible.builtin.include_tasks:
file: client.yml
vars:
rsync_backup_client: "{{ item }}"
rsync_backup_dirs: >-
{{ hostvars[item]['rsync_backup_dirs'] | default(['/export']) }}
with_items: "{{ groups['rsyncbackup'] }}"

View file

@ -0,0 +1 @@
dirs="{{ rsync_backup_dirs | default(['/export']) | join(' ') }}"