geerlingguy / ansible-role-certbot

Ansible Role - Certbot (for Let's Encrypt)
https://galaxy.ansible.com/geerlingguy/certbot/
MIT License
789 stars 351 forks source link

Symlink generation fails in initial dry-run execution (snap) #165

Closed tobiashuste closed 2 years ago

tobiashuste commented 2 years ago

When executing the role initially via dry-run the task Symlink certbot into place. fails to execute because the src file is not present.

https://github.com/geerlingguy/ansible-role-certbot/blob/dd1f8bd22c884dbbf28c2991be735ad88fd3bde3/tasks/install-with-snap.yml#L32-L36

Error message:

FAILED! => {"changed": false, "msg": "src file does not exist, use \"force=yes\" if you really want to create the link: /snap/bin/certbot", "path": "/usr/bin/certbot", "src": "/snap/bin/certbot"}

My proposed change would be to ignore the error for this task when being run in check mode.

- name: Symlink certbot into place.
  file:
    src: /snap/bin/certbot
    dest: /usr/bin/certbot
    state: link
  ignore_errors: "{{ ansible_check_mode }}"