39 lines
1.1 KiB
YAML
39 lines
1.1 KiB
YAML
---
|
|
- name: "Create directory for backups"
|
|
ansible.builtin.file:
|
|
path: "{{rsnapshot_snapshot_root}}"
|
|
state: directory
|
|
|
|
- name: "Deploy configuration from template"
|
|
template:
|
|
src: etc.rsnapshot.conf.j2
|
|
dest: /etc/rsnapshot.conf
|
|
mode: 0644
|
|
owner: root
|
|
group: root
|
|
|
|
- name: "Deploy cronjob from file"
|
|
ansible.builtin.copy:
|
|
src: etc.cron.d.rsnapshot
|
|
dest: /etc/cron.d/rsnapshot
|
|
mode: 0644
|
|
owner: root
|
|
group: root
|
|
|
|
- name: "Create a SSH keypair for backups"
|
|
ansible.builtin.command:
|
|
cmd: "ssh-keygen -t rsa -b 4096 -f /root/.ssh/{{ rsnapshot_ssh_private_key }} -N ''"
|
|
|
|
- name: "Register content of public key as ansible variable"
|
|
ansible.builtin.command:
|
|
cmd: "cat /root/.ssh/{{ rsnapshot_ssh_public_key }} >> /root/.ssh/authorized_keys"
|
|
register: rsnapshot_ssh_public_key
|
|
|
|
- name: "Deploy SSH keypair"
|
|
ansible.builtin.authorized_key:
|
|
path: /root/.ssh/authorized_keys
|
|
user: root
|
|
key: "{{ rsnapshot_ssh_public_key.stdout }}"
|
|
delegate_to: "{{ item.remote.host }}"
|
|
loop: "{{ rsnapshot_backups }}"
|
|
#
|