Skip to content

Commit

Permalink
added possibility to install certbot from package management
Browse files Browse the repository at this point in the history
- introduces a variable certbot_from_git
- adds install from package tasks
- makes a variable called certbot_script available (to handle certbot vs certbot-auto naming)
- fixes geerlingguy#18
  • Loading branch information
exploide committed Feb 24, 2017
1 parent 35ceee9 commit f3a260e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
3 changes: 2 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
6 changes: 5 additions & 1 deletion tasks/install-from-git.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions tasks/install-from-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Install Certbot
package: name=certbot state=present

- name: Set Certbot script variable
set_fact:
certbot_script: certbot
4 changes: 4 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions tasks/renew-cron.yml
Original file line number Diff line number Diff line change
@@ -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 }}"

0 comments on commit f3a260e

Please sign in to comment.