Skip to content

Commit

Permalink
Merge pull request #10 from coopdevs/feature/separate-cert-creation-t…
Browse files Browse the repository at this point in the history
…o-task

Move certificate creation to its own task
  • Loading branch information
danypr92 authored Jan 23, 2019
2 parents 9e85774 + 2058be6 commit 6c4797f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 9 additions & 0 deletions tasks/certificate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Check if certificate already exists
stat:
path: "/etc/letsencrypt/live/{{ certbot_nginx_cert_name | default(domain_name, true) }}/cert.pem"
register: letsencrypt_cert

- name: Generate new certificate if one doesn't exist
shell: "certbot certonly --nginx --email '{{ letsencrypt_email }}' --agree-tos -d '{{ domain_name }}' {% if certbot_nginx_cert_name is defined %} --cert-name '{{ certbot_nginx_cert_name }}' {% endif %} {% if letsencrypt_staging %} --staging {% endif %}"
when: not letsencrypt_cert.stat.exists
10 changes: 2 additions & 8 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,5 @@
name: "python-certbot-nginx=0.28.0-1+ubuntu{{ ansible_distribution_version }}.1+certbot+3"
state: present

- name: Check if certificate already exists
stat:
path: "/etc/letsencrypt/live/{{ certbot_nginx_cert_name | default(domain_name, true) }}/cert.pem"
register: letsencrypt_cert

- name: Generate new certificate if one doesn't exist
shell: "certbot certonly --nginx --email '{{ letsencrypt_email }}' --agree-tos -d '{{ domain_name }}' {% if certbot_nginx_cert_name %} --cert-name '{{ certbot_nginx_cert_name }}' {% endif %} {% if letsencrypt_staging %} --staging {% endif %}"
when: not letsencrypt_cert.stat.exists
- import_tasks: certificate.yml
when: domain_name is defined

0 comments on commit 6c4797f

Please sign in to comment.