diff --git a/defaults/main.yml b/defaults/main.yml index 793362c..53be380 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,10 +1,11 @@ --- # Where to get Certbot. +certbot_from_git: no certbot_repo: https://github.com/certbot/certbot.git certbot_version: master certbot_keep_updated: yes -# Where to put Certbot. +# Where to put Certbot when cloning from Git. certbot_dir: /opt/certbot # How to keep Certbot certs up to date. diff --git a/tasks/install-from-git.yml b/tasks/install-from-git.yml index 24a3544..8ff2040 100644 --- a/tasks/install-from-git.yml +++ b/tasks/install-from-git.yml @@ -7,7 +7,11 @@ update: "{{ certbot_keep_updated }}" force: yes +- name: Set Certbot script variable + set_fact: + certbot_script: "{{ certbot_dir }}/certbot-auto" + - name: Ensure certbot-auto is executable. file: - path: "{{ certbot_dir }}/certbot-auto" + path: "{{ certbot_script }}" mode: 0755 diff --git a/tasks/install-from-package.yml b/tasks/install-from-package.yml new file mode 100644 index 0000000..20f4a2f --- /dev/null +++ b/tasks/install-from-package.yml @@ -0,0 +1,7 @@ +--- +- name: Install Certbot + package: name=certbot state=present + +- name: Set Certbot script variable + set_fact: + certbot_script: certbot diff --git a/tasks/main.yml b/tasks/main.yml index 27aab86..0f1ac91 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,5 +1,9 @@ --- +- include: install-from-package.yml + when: not certbot_from_git + - include: install-from-git.yml + when: certbot_from_git - include: renew-cron.yml when: certbot_auto_renew diff --git a/tasks/renew-cron.yml b/tasks/renew-cron.yml index 62ba3bd..7678a7c 100644 --- a/tasks/renew-cron.yml +++ b/tasks/renew-cron.yml @@ -1,8 +1,8 @@ --- -- name: Add cron job for 'certbot-auto renew' (if configured). +- name: Add cron job for certbot renewal (if configured). cron: name: Certbot automatic renewal. - job: "{{ certbot_dir }}/certbot-auto renew --quiet --no-self-upgrade" + job: "{{ certbot_script }} renew --quiet --no-self-upgrade" minute: "{{ certbot_auto_renew_minute }}" hour: "{{ certbot_auto_renew_hour }}" user: "{{ certbot_auto_renew_user }}"