rsync_backup: Add support for configuring clients
This commit is contained in:
parent
f8dba6d387
commit
381b681550
7 changed files with 43 additions and 4 deletions
2
roles/rsync_backup/defaults/main.yml
Normal file
2
roles/rsync_backup/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
rsync_backup_client: "{{ inventory_hostname }}"
|
|
@ -1,4 +0,0 @@
|
|||
---
|
||||
dependencies:
|
||||
- {role: backup_base}
|
||||
- {role: ssh_known_hosts}
|
15
roles/rsync_backup/tasks/client.yml
Normal file
15
roles/rsync_backup/tasks/client.yml
Normal 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
|
|
@ -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'] }}"
|
||||
|
|
1
roles/rsync_backup/templates/client.conf.j2
Normal file
1
roles/rsync_backup/templates/client.conf.j2
Normal file
|
@ -0,0 +1 @@
|
|||
dirs="{{ rsync_backup_dirs | default(['/export']) | join(' ') }}"
|
Loading…
Add table
Add a link
Reference in a new issue