2016-04-20 15:21:19 +02:00
---
- name : Ensure that the PKI directory exists
file : path={{ pki_dir }} state=directory owner=root group=root mode=0755
2017-01-20 18:31:31 +01:00
tags : [ 'pki' , 'ssl' , 'ca' , 'letsencrypt' ]
2016-04-20 15:21:19 +02:00
- name : Ensure that the PKI subdirectories exist
file : path={{ pki_dir }}/{{ item }} state=directory owner=root group=root mode=0755
with_items : '{{ pki_subdirs }}'
2017-01-20 18:31:31 +01:00
tags : [ 'pki' , 'ssl' , 'ca' , 'letsencrypt' ]
2016-04-20 15:21:19 +02:00
2016-04-22 18:01:58 +02:00
- name : When we are going to install letsencrypt certificates, create a preliminary path and a self signed cert. Check if a certificate already exists. If so, skip all the related tasks
2016-09-30 18:36:09 +02:00
stat : path={{ letsencrypt_acme_user_home | default(omit) }}/live/{{ ansible_fqdn }}
2016-04-22 18:01:58 +02:00
register : true_cert
2016-09-13 13:48:00 +02:00
when : ( letsencrypt_acme_install is defined and letsencrypt_acme_install )
2016-04-22 18:01:58 +02:00
tags : [ 'pki' , 'ssl' , 'letsencrypt' ]
2016-04-20 15:21:19 +02:00
- name : When we are going to install letsencrypt certificates, create a preliminary path and a self signed cert. Now the physical paths
file : path={{ item }} mode=0755 state=directory
with_items :
2016-09-30 18:36:09 +02:00
- '{{ letsencrypt_acme_user_home | default(omit) }}/live'
- '{{ letsencrypt_acme_user_home | default(omit) }}/certs/fakeselfsignedcert'
- '{{ letsencrypt_acme_user_home | default(omit) }}/keys/fakeselfsignedcert'
2016-05-06 16:27:32 +02:00
when :
- ( true_cert.stat.islnk is not defined ) and ( letsencrypt_acme_install is defined and letsencrypt_acme_install )
2016-09-30 18:36:09 +02:00
- letsencrypt_acme_user_home | default(omit) is defined
2016-04-20 15:21:19 +02:00
tags : [ 'pki' , 'ssl' , 'letsencrypt' ]
2016-05-06 13:22:34 +02:00
2016-04-20 15:21:19 +02:00
- name : When we are going to install letsencrypt certificates, create a preliminary path and a self signed cert. Now the certificate and private key
2016-09-30 18:36:09 +02:00
command : openssl req -x509 -newkey rsa:2048 -keyout {{ letsencrypt_acme_user_home | default(omit) }}/keys/fakeselfsignedcert/privkey -out {{ letsencrypt_acme_user_home | default(omit) }}/certs/fakeselfsignedcert/cert -days 10 -nodes -subj '/CN=self signed certificate'
2016-04-20 15:21:19 +02:00
args :
2016-09-30 18:36:09 +02:00
creates : '{{ letsencrypt_acme_user_home | default(omit) }}/certs/fakeselfsignedcert/cert'
2016-04-22 18:01:58 +02:00
when : ( true_cert.stat.islnk is not defined ) and ( letsencrypt_acme_install is defined and letsencrypt_acme_install )
2016-04-20 15:21:19 +02:00
tags : [ 'pki' , 'ssl' , 'letsencrypt' ]
- name : When we are going to install letsencrypt certificates, create a preliminary path and a self signed cert. Now the symbolic links for the private key
2016-09-30 18:36:09 +02:00
file : src=../../keys/fakeselfsignedcert/privkey dest={{ letsencrypt_acme_user_home | default(omit) }}/certs/fakeselfsignedcert/privkey state=link
2016-04-22 18:01:58 +02:00
when : ( true_cert.stat.islnk is not defined ) and ( letsencrypt_acme_install is defined and letsencrypt_acme_install )
2016-04-20 15:21:19 +02:00
tags : [ 'pki' , 'ssl' , 'letsencrypt' ]
- name : When we are going to install letsencrypt certificates, create a preliminary path and a self signed cert. Now the symbolic links for the chain file
2016-09-30 18:36:09 +02:00
file : src=cert dest={{ letsencrypt_acme_user_home | default(omit) }}/certs/fakeselfsignedcert/chain state=link
2016-04-22 18:01:58 +02:00
when : ( true_cert.stat.islnk is not defined ) and ( letsencrypt_acme_install is defined and letsencrypt_acme_install )
2016-04-20 15:21:19 +02:00
tags : [ 'pki' , 'ssl' , 'letsencrypt' ]
2016-05-06 13:22:34 +02:00
- name : When we are going to install letsencrypt certificates, create a preliminary path and a self signed cert. Now the symbolic links for the fullchain file
2016-09-30 18:36:09 +02:00
file : src=cert dest={{ letsencrypt_acme_user_home | default(omit) }}/certs/fakeselfsignedcert/fullchain state=link
2016-05-06 13:22:34 +02:00
when : ( true_cert.stat.islnk is not defined ) and ( letsencrypt_acme_install is defined and letsencrypt_acme_install )
tags : [ 'pki' , 'ssl' , 'letsencrypt' ]
2016-04-20 15:21:19 +02:00
- name : When we are going to install letsencrypt certificates, create a preliminary path and a self signed cert. Now the symbolic links for the certificate if there is not one
2016-09-30 18:36:09 +02:00
file : src=../certs/fakeselfsignedcert dest={{ letsencrypt_acme_user_home | default(omit) }}/live/{{ ansible_fqdn }} state=link
2016-04-22 18:01:58 +02:00
when : ( true_cert.stat.islnk is not defined ) and ( letsencrypt_acme_install is defined and letsencrypt_acme_install )
2016-04-20 15:21:19 +02:00
tags : [ 'pki' , 'ssl' , 'letsencrypt' ]
- name : When we are going to install letsencrypt certificates, create a preliminary path and a self signed cert. Now handle the haproxy special case
2016-09-30 18:36:09 +02:00
shell : mkdir {{ pki_dir }}/haproxy ; cat {{ letsencrypt_acme_user_home | default(omit) }}/live/{{ ansible_fqdn }}/privkey {{ letsencrypt_acme_user_home | default(omit) }}/live/{{ ansible_fqdn }}/cert > {{ pki_dir }}/haproxy/haproxy.pem
2016-04-20 15:21:19 +02:00
args :
creates : '{{ pki_dir }}/haproxy/haproxy.pem'
when :
- letsencrypt_acme_install is defined and letsencrypt_acme_install
- haproxy_enabled is defined and haproxy_enabled
tags : [ 'pki' , 'ssl' , 'letsencrypt' ]