ansible-role-borgbackup/tasks/ssh.yml

32 lines
890 B
YAML
Raw Normal View History

2023-04-08 22:33:17 +02:00
---
2023-04-09 10:05:37 +02:00
- name: "SSH | Ensure directory exist"
ansible.builtin.file:
path: "{{ borg_user }}/.ssh/"
state: directory
mode: "0700"
owner: "{{ borg_user }}"
group: "{{ borg_group }}"
2023-04-08 22:33:17 +02:00
- name: "SSH | Generate an OpenSSH keypair"
community.crypto.openssh_keypair:
path: "{{ borg_ssh_key_file_path }}"
type: "{{ borg_ssh_key_type }}"
2023-04-09 10:05:37 +02:00
owner: "{{ borg_user }}"
group: "{{ borg_group }}"
2023-04-08 22:33:17 +02:00
- name: "SSH | Ensure configuration file is present"
ansible.builtin.file:
2023-04-09 10:05:37 +02:00
path: "{{ borg_user_ssh_config_path }}"
2023-04-08 22:33:17 +02:00
state: touch
mode: "644"
2023-04-09 10:05:37 +02:00
owner: "{{ borg_user }}"
group: "{{ borg_group }}"
2023-04-08 22:33:17 +02:00
- name: "SSH | Insert borgbase configuration"
ansible.builtin.blockinfile:
2023-04-09 10:05:37 +02:00
path: "{{ borg_user_ssh_config_path }}"
2023-04-08 22:33:17 +02:00
marker: "### {mark} ANSIBLE MANAGED BLOCK"
block: |
Host *.repo.borgbase.com
IdentityFile {{ borg_ssh_key_file_path }}