commit 2d8d83aedc1a85581f6991f9a52acce365f18a45 Author: phil Date: Sat Apr 8 19:17:38 2023 +0200 Initial commit diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..a19056c --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,3 @@ +--- +backup_ssh_key_path: /root/.ssh/borgbase_backup +borgbase_ssh_key_name: "backup@{{ inventory_hostname }}" diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..682b8d2 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,12 @@ +galaxy_info: + author: Sense.Lab e.V. administrators + description: Role to configure borgbase repositories and ssh keys + company: Sense.Lab e.V. + license: GPLv3 + min_ansible_version: "2.9" + platforms: + - name: Debian + versions: + - bullseye +dependencies: + - name: adhawkins.borgbase diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..0f33054 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,29 @@ +--- +- name: Generate an OpenSSH keypair + community.crypto.openssh_keypair: + path: "{{ backup_ssh_key_path }}" + type: "ed25519" + +- name: Read key from file + ansible.builtin.slurp: + src: "{{ backup_ssh_key_path }}.pub" + register: ssh_key + check_mode: true + +- name: Add key to borgbase + adhawkins.borgbase.borgbase_ssh: + state: present + apikey: "{{ borgbase_api_key }}" + name: "{{ borgbase_ssh_key_name }}" + key: "{{ (ssh_key.content | b64decode).split()[:2] | join(' ') }}" + register: borgbase_key + +- name: Create repo + adhawkins.borgbase_repo: + state: present + apikey: "{{ borgbase_api_key }}" + name: "{{ ansible_hostname }}" + full_access_keys: ["{{ borgbase_key.key_id }}"] + quota_enabled: false + alert_days: 1 + register: borgbase_repo