69 lines
No EOL
1.7 KiB
YAML
69 lines
No EOL
1.7 KiB
YAML
---
|
|
- hosts: backup_server
|
|
tasks:
|
|
# - name: install necessary packages
|
|
# ansible.builtin.apt:
|
|
# name:
|
|
# - rsnapshot
|
|
# - nfs-common
|
|
# state: present
|
|
# update_cache: yes
|
|
|
|
- name: Copy systemd mount file
|
|
ansible.builtin.copy:
|
|
src: files/systemd-mount.conf
|
|
dest: /etc/systemd/system/mnt-syno-InfraBackups.mount
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
register: systemd_mount
|
|
|
|
- name: Reload systemd
|
|
ansible.builtin.systemd:
|
|
daemon_reload: yes
|
|
when: systemd_mount.changed
|
|
|
|
- name: Start & Enable systemd mount
|
|
ansible.builtin.systemd:
|
|
name: mnt-syno-InfraBackups.mount
|
|
state: started
|
|
enabled: yes
|
|
when: systemd_mount.changed
|
|
|
|
- name: Generate ssh key
|
|
ansible.builtin.openssh_keypair:
|
|
path: /root/.ssh/id_rsa_rsnapshot
|
|
type: rsa
|
|
size: 4096
|
|
state: present
|
|
|
|
- name: Register ssh public key in variable
|
|
slurp:
|
|
src: /root/.ssh/id_rsa_rsnapshot.pub
|
|
register: rsnapshot_ssh_key_slurp
|
|
- name: Set ssh public key in variable
|
|
set_fact:
|
|
rsnapshot_ssh_key: "{{ rsnapshot_ssh_key_slurp['content'] | b64decode }}"
|
|
|
|
|
|
- name: Copy rsnapshot template file
|
|
ansible.builtin.template:
|
|
src: files/rsnapshot.conf.j2
|
|
dest: /etc/rsnapshot.conf
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
register: rsnapshot_conf
|
|
tags: rsnapshot
|
|
|
|
|
|
- hosts: backup_clients
|
|
gather_facts: no
|
|
vars:
|
|
backup_server: backup.lan.k3s.fr
|
|
tasks:
|
|
- name: Allow ssh from rsnapshot server
|
|
authorized_key:
|
|
user: root
|
|
state: present
|
|
key: "{{ hostvars[backup_server]['rsnapshot_ssh_key'] | trim }} root@{{ hostvars[backup_server]['ansible_default_ipv4']['address'] }}" |