ansible-role--rsnapshot/tasks/_configure.yml

40 lines
1.1 KiB
YAML
Raw Permalink Normal View History

2024-07-12 12:35:24 +00:00
---
- 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
2024-07-12 16:03:54 +00:00
- 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 }}"
2024-07-12 12:35:24 +00:00
#