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
|
@ -11,5 +11,8 @@ firewall_in:
|
||||||
- {proto: tcp, port: 2049, from: [172.20.30.0/24]}
|
- {proto: tcp, port: 2049, from: [172.20.30.0/24]}
|
||||||
- {proto: tcp, port: 9100, from: [172.20.20.0/22]}
|
- {proto: tcp, port: 9100, from: [172.20.20.0/22]}
|
||||||
|
|
||||||
|
rsync_backup_dirs:
|
||||||
|
- /export/home
|
||||||
|
- /export/roles
|
||||||
sssd_allow_groups:
|
sssd_allow_groups:
|
||||||
- root
|
- root
|
||||||
|
|
|
@ -67,6 +67,12 @@
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: role
|
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
|
- name: Install roles for physical hardware
|
||||||
ansible.builtin.include_role:
|
ansible.builtin.include_role:
|
||||||
name: "{{ role }}"
|
name: "{{ role }}"
|
||||||
|
|
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
|
- name: Copy backup script
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
dest: /usr/local/sbin/backup-daily
|
dest: /usr/local/sbin/backup-daily
|
||||||
|
@ -49,3 +56,12 @@
|
||||||
job: /usr/local/sbin/backup-daily -a -p -r
|
job: /usr/local/sbin/backup-daily -a -p -r
|
||||||
hour: "00"
|
hour: "00"
|
||||||
minute: "30"
|
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