Skip to content

Commit

Permalink
Remove symlinks; snap doesnt recognize 'certbot-auto' as a valid app …
Browse files Browse the repository at this point in the history
…name
  • Loading branch information
dale-c-anderson committed Feb 23, 2021
1 parent 81ea26f commit 5d80349
Showing 1 changed file with 8 additions and 33 deletions.
41 changes: 8 additions & 33 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,51 +46,26 @@

when: ansible_distribution == 'Ubuntu'

- name: Check if old certbot-auto exists
stat:
path: /usr/local/bin/certbot-auto
register: certbot_auto_file

- name: debug certbot_auto_file
debug:
var: certbot_auto_file
- name: Remove old "certbot-auto" scripts or symlinks; it won't work any more. The new snap version is just a symlink to the snap binary, and the name "certbot-auto" won't be recognized as a valid app. Legacy apps will need to call certbot instead.
file:
dest: /usr/local/bin/certbot-auto
state: absent

- name: Remove old certbot-auto when its not just a symlink
shell: >
if [ -f /usr/local/bin/certbot-auto ] && [ ! -L /usr/local/bin/certbot-auto ]; then
rm /usr/local/bin/certbot-auto;
fi
when: certbot_auto_file.stat.exists
ignore_errors: "{{ ansible_check_mode }}"
- name: Remove old "certbot" script or symlink, just in case it wasn't removed by apt.
file:
dest: /usr/bin/certbot
state: absent

- name: Install certbot snap package
snap:
name: certbot
classic: true
notify: "restart {{ letsencrypt_webserver }}"

- name: Create links to the new snap binary for use by legacy apps
file:
state: link
src: /snap/bin/certbot
dest: "{{ item }}"
with_items:
- /usr/local/bin/certbot-auto
- /usr/bin/certbot

- name: Remove old certbot-update job. Snaps update automatically.
cron:
state: absent
name: "Update certbot-auto once a month"
minute: "0"
hour: "0"
day: "1"
# The sed commands after the certbot script keep this job quiet when there is no upgrade and there are no errors.
job: >
/usr/local/bin/certbot-auto --version 2>&1 | /bin/sed -r 's/^certbot ([0-9]+)(\.[0-9]+)+$//' |/bin/sed '/^\s*$/d'
tags:
- letsencrypt_cron
when: ansible_distribution == 'Ubuntu'

- name: Create a destination for dhparams
file:
Expand Down

0 comments on commit 5d80349

Please sign in to comment.