Browse Source

added return variable `borgbackup_sshd_repository_initialized`

Fabian Peter Hammerle 2 years ago
parent
commit
07c4771dea
2 changed files with 7 additions and 1 deletions
  1. 1 0
      README.md
  2. 6 1
      tasks/main.yml

+ 1 - 0
README.md

@@ -27,4 +27,5 @@ borgbackup_sshd_client_public_keys_append_only: |-
 
 ```yaml
 borgbackup_sshd_host_keys
+borgbackup_sshd_repository_initialized
 ```

+ 6 - 1
tasks/main.yml

@@ -69,7 +69,12 @@
     src: '{{ item }}'
   loop: "{{ _host_keys_files.results | map(attribute='path') | list }}"
   register: _host_keys_base64
-- name: decode host keys
+- name: check if repository is initialized
+  stat:
+    path: '{{ _repo_dir.path }}/config'
+  register: _repository_config_file
+- name: decode host keys & set return variables
   set_fact:
     borgbackup_sshd_host_keys: >-
       {{ _host_keys_base64.results | map(attribute='content') | map('b64decode') | map('trim') | list }}
+    borgbackup_sshd_repository_initialized: '{{ _repository_config_file.stat.exists }}'