make it work on infra.opendoor.fr

This commit is contained in:
2026-01-01 16:49:44 +01:00
parent 1ce512d844
commit 17d54301f7
9 changed files with 59 additions and 57 deletions

View File

@@ -4,17 +4,17 @@
# * configure authorized key for backup user
- name: create root ssh private key
openssh_keypair:
comment: "passwordless access to vm2, as backup user"
comment: "passwordless access to {{ borg_server }}, as backup user"
path: /root/.ssh/id_rsa
owner: root
group: root
- name: create repo
file:
path: "/var/backups/borg/{{ ansible_hostname }}"
path: "{{ borg_remote_dir }}{{ inventory_hostname }}"
state: directory
owner: backup
group: backup
owner: "{{ borg_account }}"
group: "{{ borg_account }}"
delegate_to: "{{ borg_server }}"
- name: get public key
@@ -28,12 +28,26 @@
# can't use authorized_key module here
- name: install ssh key
lineinfile:
path: /var/backups/.ssh/authorized_keys
line: 'command="borg serve --restrict-to-path /var/backups/borg/" {{ public_key }} from {{ ansible_hostname }}'
path: "{{ borg_remote_dir }}/.ssh/authorized_keys"
line: 'command="borg serve --restrict-to-path {{ borg_remote_dir }}" {{ public_key }} from {{ inventory_hostname }}'
create: true
owner: backup
group: backup
owner: "{{ borg_account }}"
group: "{{ borg_account }}"
mode: 0600
delegate_to: "{{ borg_server }}"
- name: check if repository is created
tags: wip
delegate_to: "{{ borg_server }}"
ansible.builtin.stat:
path: "{{ borg_remote_dir }}{{ inventory_hostname }}/config"
register: repo_content
- name: create repository
tags: wip
when: repo_content.stat.isfile is not defined
ansible.builtin.command: "/usr/bin/borg init --encryption=keyfile {{ borg_account }}@{{ borg_server }}:{{ borg_remote_dir }}{{ inventory_hostname }}"
environment:
BORG_PASSPHRASE: "{{ borg_passphrase }}"