Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to install certbot from repository #32

Merged
merged 1 commit into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ nginx_revproxy_sites: # List of sites to
ssl_certificate_key: /etc/ssl/private/ssl-cert-snakeoil.key # ssl certificate key, used if letsencrypt is false
letsencrypt: false # Set to True if you want use letsencrypt
letsencrypt_email: "" # Set email for letencrypt cert

nginx_revproxy_certbot_auto: true # Install certbot-auto

nginx_revproxy_certbot_packages: # Install these packages from repo, when not using certbot-auto
- certbot
- python3-certbot-nginx
```
Dependencies
Expand Down
6 changes: 6 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ nginx_revproxy_sites: # List of sites to
hsts_max_age: 63072000 # Set HSTS header with max-age defined
letsencrypt: false # Set to True if you want use letsencrypt
letsencrypt_email: "" # Set email for letencrypt cert

nginx_revproxy_certbot_auto: true

nginx_revproxy_certbot_packages:
- certbot
- python3-certbot-nginx
17 changes: 14 additions & 3 deletions tasks/letsencrypt.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
---

- name: Install certbot
- name: Install certbot-auto
get_url:
url: https://dl.eff.org/certbot-auto
dest: /usr/bin/certbot-auto
mode: "a+x"
when: nginx_revproxy_certbot_auto
tags:
- lesencrypt
- nginxrevproxy

- name: Install certbot from repository
apt:
name: "{{ nginx_revproxy_certbot_packages }}"
state: present
when: not nginx_revproxy_certbot_auto
tags:
- lesencrypt
- nginxrevproxy
Expand Down Expand Up @@ -60,7 +70,7 @@

- name: Generate certs (first time)
command: |
certbot-auto certonly
certbot{{ '-auto' if nginx_revproxy_certbot_auto else '' }} certonly
--webroot -w /var/www/{{ item.key }}
-d {{ item.value.domains | join(' -d ') }}
--email {{ item.value.letsencrypt_email }}
Expand Down Expand Up @@ -89,7 +99,8 @@
- name: Insert cert-bot renew in crontab
cron:
name: "cert-bot renew"
job: 'certbot-auto renew --post-hook "systemctl reload nginx" >> /var/log/letsencrypt/letsencrypt-update.log 2>&1'
job: "certbot{{ '-auto' if nginx_revproxy_certbot_auto else '' }} \
renew --post-hook \"systemctl reload nginx\" >> /var/log/letsencrypt/letsencrypt-update.log 2>&1"
hour: "3"
minute: "30"
weekday: "1"
Expand Down