add test to create certificate
This commit is contained in:
parent
4fbcdc581a
commit
6e7a0dc228
3 changed files with 30 additions and 19 deletions
|
@ -27,19 +27,6 @@
|
||||||
- ssl
|
- ssl
|
||||||
- mpm_prefork
|
- mpm_prefork
|
||||||
|
|
||||||
- name: Stop Apache
|
|
||||||
service:
|
|
||||||
name: apache2
|
|
||||||
state: stopped
|
|
||||||
|
|
||||||
- name: Ensure SSL certificate exists
|
|
||||||
shell: "certbot certonly --agree-tos --email certs@susurrando.com -n --standalone -d {{ item.vhostname }}"
|
|
||||||
args:
|
|
||||||
creates: "/etc/letsencrypt/archive/{{ item.vhostname }}"
|
|
||||||
when:
|
|
||||||
- "'ssl' in item"
|
|
||||||
- item['ssl']
|
|
||||||
with_items: "{{ vhosts }}"
|
|
||||||
|
|
||||||
- name: Ensure default vhost root exists
|
- name: Ensure default vhost root exists
|
||||||
file:
|
file:
|
||||||
|
@ -67,11 +54,6 @@
|
||||||
notify:
|
notify:
|
||||||
- Restart Apache
|
- Restart Apache
|
||||||
|
|
||||||
- name: Start Apache
|
|
||||||
service:
|
|
||||||
name: apache2
|
|
||||||
state: started
|
|
||||||
|
|
||||||
- name: Ensure Apache modules are enabled
|
- name: Ensure Apache modules are enabled
|
||||||
community.general.apache2_module:
|
community.general.apache2_module:
|
||||||
state: present
|
state: present
|
||||||
|
|
19
tasks/configure_certificate.yml
Normal file
19
tasks/configure_certificate.yml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
---
|
||||||
|
- name: Stop Apache
|
||||||
|
service:
|
||||||
|
name: apache2
|
||||||
|
state: stopped
|
||||||
|
|
||||||
|
- name: Ensure SSL certificate exists
|
||||||
|
shell: "certbot certonly --agree-tos --email certs@susurrando.com -n --standalone -d {{ item.vhostname }}"
|
||||||
|
args:
|
||||||
|
creates: "/etc/letsencrypt/archive/{{ item.vhostname }}"
|
||||||
|
when:
|
||||||
|
- "'ssl' in item"
|
||||||
|
- item['ssl']
|
||||||
|
with_items: "{{ vhosts }}"
|
||||||
|
|
||||||
|
- name: Start Apache
|
||||||
|
service:
|
||||||
|
name: apache2
|
||||||
|
state: started
|
|
@ -1,5 +1,15 @@
|
||||||
---
|
---
|
||||||
- name: Ensure installation
|
- name: Ensure installation
|
||||||
include_tasks: install.yml
|
include_tasks: install.yml
|
||||||
|
|
||||||
- name: Ensure configuration
|
- name: Ensure configuration
|
||||||
include_tasks: configure.yml
|
include_tasks: configure.yml
|
||||||
|
|
||||||
|
- name: Get certificate file
|
||||||
|
stat:
|
||||||
|
path: "/etc/letsencrypt/archive/{{ item.vhostname }}"
|
||||||
|
register: certificate_folder
|
||||||
|
|
||||||
|
- name: Ensure certificate is created
|
||||||
|
include_tasks: configure_certificate.yml
|
||||||
|
when: not certificate_folder.stat.exists
|
||||||
|
|
Loading…
Reference in a new issue