fiaasco / borgbackup

Borg backup role
MIT License
16 stars 19 forks source link

check_mode suppor #40

Open Ofthestreet opened 3 years ago

Ofthestreet commented 3 years ago

In borg-client.yml, running the playbook in check mode is not possible since sshkey is undefined in the following task

- name: client | put sshpubkey on the normal backupserver
  authorized_key:
    user: "{{ item.user }}"
 ->   key: "{{ sshkey.stdout }}"

I would suggest to add a check_mode: no when fetching the ssh-key in order to validate the usage of sshkey.stdout

- name: client | fetch ssh-key
  command: "cat {{ borgbackup_ssh_key }}.pub"
  register: sshkey
  changed_when: false
  -> check_mode: no
  tags:
    - skip_ansible_lint

Note : As I am not a old ansible coder feel free to indicate why this is not already the case

stroobl commented 2 years ago

Check mode was never tested while implementing the role, so I'm not sure if this would be the only issue? I expect that anything with ssh keys involved will fail if the key is not generated, so it probably doesn't make sense to implement check mode then?