Issue #12: Add basic standalone certbot cert generation.
parent
574c0843c8
commit
7651f0ac0b
@ -0,0 +1,23 @@ |
||||
--- |
||||
- name: Check if certificate already exists. |
||||
stat: |
||||
path: /etc/letsencrypt/live/{{ item.domains | first }}/cert.pem |
||||
register: letsencrypt_cert |
||||
|
||||
- name: Stop services to allow certbot to generate a cert. |
||||
service: |
||||
name: "{{ item }}" |
||||
state: stopped |
||||
when: not letsencrypt_cert.stat.exists |
||||
with_items: certbot_create_stop_services |
||||
|
||||
- name: Generate new certificate if one doesn't exist. |
||||
shell: "{{ certbot_create_command }}" |
||||
when: not letsencrypt_cert.stat.exists |
||||
|
||||
- name: Start services after cert has been generated. |
||||
service: |
||||
name: "{{ item }}" |
||||
state: started |
||||
when: not letsencrypt_cert.stat.exists |
||||
with_items: certbot_create_stop_services |
@ -0,0 +1,28 @@ |
||||
--- |
||||
- hosts: all |
||||
|
||||
vars: |
||||
certbot_admin_email: https@servercheck.in |
||||
certbot_create_if_missing: yes |
||||
certbot_create_stop_services: |
||||
- nginx |
||||
certbot_certs: |
||||
- domains: |
||||
- certbot-test.servercheck.in |
||||
|
||||
pre_tasks: |
||||
- name: Update apt cache. |
||||
apt: update_cache=yes cache_valid_time=600 |
||||
when: ansible_os_family == 'Debian' |
||||
changed_when: false |
||||
|
||||
- name: Install cron (RedHat). |
||||
yum: name=cronie state=present |
||||
when: ansible_os_family == 'RedHat' |
||||
|
||||
- name: Install cron (Debian). |
||||
apt: name=cron state=present |
||||
when: ansible_os_family == 'Debian' |
||||
|
||||
roles: |
||||
- role_under_test |
Loading…
Reference in new issue