From a6a9b7cf95c906ab6a45daf759c5f15c3b722b62 Mon Sep 17 00:00:00 2001 From: Guilherme Balzana Date: Thu, 25 Feb 2021 14:58:02 +0000 Subject: [PATCH] Add epel repository for snap install method Remove the old cerbot package --- defaults/main.yml | 1 - tasks/create-cert-standalone.yml | 2 +- tasks/install-with-snap.yml | 13 ++++++++++++- tasks/renew-cron.yml | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 2166d50..ba81f0d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -45,4 +45,3 @@ certbot_dir: /opt/certbot # no-self-upgrade # pre-hook = systemctl stop httpd # post-hook = systemctl stop httpd - diff --git a/tasks/create-cert-standalone.yml b/tasks/create-cert-standalone.yml index 279e5b8..91df31a 100644 --- a/tasks/create-cert-standalone.yml +++ b/tasks/create-cert-standalone.yml @@ -14,7 +14,7 @@ - name: Add renew options to cli.ini file copy: path: /etc/letsencrypt/cli.ini - content: {{ certbot_cli_options }} + content: "{{ certbot_cli_options }}" when: certbot_cli_options is defined - name: Generate new certificate if one doesn't exist. diff --git a/tasks/install-with-snap.yml b/tasks/install-with-snap.yml index 0651e71..588c8f7 100644 --- a/tasks/install-with-snap.yml +++ b/tasks/install-with-snap.yml @@ -1,4 +1,10 @@ --- +- name: Ensure EPEL repository. + package: + name: epel-release + state: present + when: ansible_os_family == "RedHat" + - name: Ensure snapd is installed. package: name: snapd @@ -7,7 +13,7 @@ - name: Ensure snapd is enabled. systemd: - name: snapd.socket + name: snapd enabled: true - name: Enable classic snap support. @@ -22,6 +28,11 @@ failed_when: false when: snapd_install is changed +- name: Remove old certbot packages. + package: + name: "{{ certbot_package }}" + state: absent + - name: Install certbot via snap. snap: name: certbot diff --git a/tasks/renew-cron.yml b/tasks/renew-cron.yml index 394a30e..0bfd6a0 100644 --- a/tasks/renew-cron.yml +++ b/tasks/renew-cron.yml @@ -6,3 +6,4 @@ minute: "{{ certbot_auto_renew_minute }}" hour: "{{ certbot_auto_renew_hour }}" user: "{{ certbot_auto_renew_user }}" + when: certbot_install_method == 'package' or certbot_install_method == 'source'