Add SSH configuration

This commit is contained in:
phil 2023-04-08 22:33:17 +02:00
parent 90153baf93
commit 2e76b13610
3 changed files with 25 additions and 4 deletions

View file

@ -45,3 +45,5 @@ borgmatic_store_atime: true
borgmatic_store_ctime: true
borgmatic_relocated_repo_access_is_ok: false
borgmatic_version: false
ssh_config_path: /root/.ssh/config

View file

@ -3,10 +3,9 @@
ansible.builtin.import_tasks: packages.yml
tags: packages
- name: Generate an OpenSSH keypair
community.crypto.openssh_keypair:
path: "{{ borg_ssh_key_file_path }}"
type: "{{ borg_ssh_key_type }}"
- name: Create SSH key
ansible.builtin.import_tasks: ssh.yml
tags: ssh
- name: Setup borgbase backup
ansible.builtin.import_tasks: borgbase.yml
@ -33,3 +32,4 @@
command: "borgmatic init -e {{ borg_repo_key }}"
responses:
^.*want to continue connecting.*$: "yes"

19
tasks/ssh.yml Normal file
View file

@ -0,0 +1,19 @@
---
- name: "SSH | Generate an OpenSSH keypair"
community.crypto.openssh_keypair:
path: "{{ borg_ssh_key_file_path }}"
type: "{{ borg_ssh_key_type }}"
- name: "SSH | Ensure configuration file is present"
ansible.builtin.file:
path: "{{ ssh_config_name }}"
state: touch
mode: "644"
- name: "SSH | Insert borgbase configuration"
ansible.builtin.blockinfile:
path: "{{ ssh_config_name }}"
marker: "### {mark} ANSIBLE MANAGED BLOCK"
block: |
Host *.repo.borgbase.com
IdentityFile {{ borg_ssh_key_file_path }}