- with_items: "{{ client.value.repos }}" assert: that: - "item in borg__passphrases[client.key]" fail_msg: "{{ item }} is missing from borg-secrets.yml" success_msg: "" - set_fact: ssh_key: "{{ client.value.ssh_key_path if client.value.ssh_key_path is defined else default_file_path }}" vars: default_file_path: "files/borg/{{ client.key }}/ssh-key" - debug: var=ssh_key - with_items: "{{ client.value.repos }}" name: mkdir client dir file: path: "{{ path | dirname }}" state: directory owner: "{{ borg_target__user }}" group: "{{ borg_target__group }}" vars: path: "{{ borg_target__home }}/repos/{{ client.key }}/{{ item }}" - with_items: "{{ client.value.repos }}" become_user: "{{ borg_target__user }}" name: borg init command: "borg init --encryption repokey {{ path }}" args: creates: "{{ path }}" environment: BORG_PASSPHRASE: "{{ borg__passphrases[client.key][item] }}" vars: path: "{{ borg_target__home }}/repos/{{ client.key }}/{{ item }}" ansible_ssh_pipelining: true - local_action: module: stat path: "{{ ssh_key }}" register: ssh_key_stat - local_action: module: file path: "{{ (playbook_dir + '/' + ssh_key) | dirname }}" state: directory become: no - name: Generating SSH key local_action: command ssh-keygen -t ed25519 -N "" -f "{{ ssh_key }}" -C "borg@{{ client.key }}" when: not ssh_key_stat.stat.exists become: no