ansible-role-borgbackup/tasks/ssh.yml

31 lines
890 B
YAML

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