make it work on infra.opendoor.fr
This commit is contained in:
@@ -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 }}"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user