From 4c7f8d86bfce463f5355017788b790e8ae7b9f93 Mon Sep 17 00:00:00 2001 From: Matthias Stegmann Date: Thu, 3 Apr 2025 09:06:16 +0200 Subject: [PATCH] Add option to set ssh key comment --- EXAMPLES.md | 1 + README.md | 1 + defaults/main.yml | 1 + meta/argument_specs.yml | 4 ++++ tasks/03_create_key.yml | 1 + 5 files changed, 8 insertions(+) diff --git a/EXAMPLES.md b/EXAMPLES.md index 9e63152..5957818 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -10,6 +10,7 @@ borg_repository: ssh://m5vz9gp4@m5vz9gp4.repo.borgbase.com/./repo borgmatic_timer: systemd borg_ssh_key_name: id_backup + borg_ssh_key_comment: backup key borg_ssh_command: "ssh -i {{ borg_ssh_key_file_path }} -o StrictHostKeyChecking=accept-new" borg_user: backupuser borg_group: backupuser diff --git a/README.md b/README.md index 903f77b..c9f2a49 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,7 @@ $ git clone https://github.com/borgbase/ansible-role-borgbackup.git roles/ansibl - `borg_ssh_key_name`: Name of the SSH public and pivate key. Default `id_ed25519` - `borg_ssh_key_file_path`: SSH-key to be used. Default `~/.ssh/{{ borg_ssh_key_name }}` - `borg_ssh_key_type`: The algorithm used to generate the SSH private key. Choose: `rsa`, `dsa`, `rsa1`, `ecdsa`, `ed25519`. Default: `ed25519` +- `borg_ssh_key_comment`: Comment added to the SSH public key. - `borg_ssh_command`: Command to use instead of just "ssh". This can be used to specify SSH options. - `borg_version`: Force a specific borg version to be installed - `borg_venv_path`: Path to store the venv for `borg(backup)` and `borgmatic` diff --git a/defaults/main.yml b/defaults/main.yml index a928993..e2fdaa6 100755 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -7,6 +7,7 @@ borg_encryption_passcommand: false borg_lock_wait_time: 5 borg_ssh_key_type: "ed25519" borg_ssh_key_name: "id_{{ borg_ssh_key_type }}" +borg_ssh_key_comment: '' borg_ssh_key_file_path: "{{ backup_user_info.home }}/.ssh/{{ borg_ssh_key_name }}" borg_ssh_command: false borg_remote_path: false diff --git a/meta/argument_specs.yml b/meta/argument_specs.yml index bfb8226..0b3293f 100644 --- a/meta/argument_specs.yml +++ b/meta/argument_specs.yml @@ -192,3 +192,7 @@ argument_specs: type: str required: false description: Name of the SSH public and private key + borg_ssh_key_comment: + type: str + required: false + description: Comment added to the SSH public key. diff --git a/tasks/03_create_key.yml b/tasks/03_create_key.yml index 3827d77..3887856 100644 --- a/tasks/03_create_key.yml +++ b/tasks/03_create_key.yml @@ -16,6 +16,7 @@ type: "{{ borg_ssh_key_type }}" owner: "{{ borg_user }}" group: "{{ borg_group }}" + comment: "{{ borg_ssh_key_comment }}" - name: Read SSH key ansible.builtin.slurp: