feat: add keypair generation
This commit is contained in:
parent
a21d9b3d98
commit
22448a2f4d
2 changed files with 20 additions and 0 deletions
|
@ -3,6 +3,10 @@
|
||||||
"title": "rsnapshot Configuration",
|
"title": "rsnapshot Configuration",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"rsnapshot_ssh_private_key": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Name of the SSH private key for backups"
|
||||||
|
},
|
||||||
"rsnapshot_snapshot_root": {
|
"rsnapshot_snapshot_root": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Root directory where all snapshots will be stored"
|
"description": "Root directory where all snapshots will be stored"
|
||||||
|
|
|
@ -20,4 +20,20 @@
|
||||||
owner: root
|
owner: root
|
||||||
group: 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 }}"
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue