2018-09-11 17:37:10 +02:00
|
|
|
---
|
|
|
|
- block:
|
|
|
|
- name: Create the acme hooks directory if it does not yet exist
|
|
|
|
file: dest={{ letsencrypt_acme_services_scripts_dir }} state=directory owner=root group=root
|
|
|
|
|
|
|
|
- name: Install a script that fix the letsencrypt certificate for mongodb and then reload the service
|
|
|
|
template: src=mongodb-letsencrypt-acmetool.sh dest={{ letsencrypt_acme_services_scripts_dir }}/mongodb owner=root group=root mode=4555
|
|
|
|
|
2018-09-19 17:41:37 +02:00
|
|
|
- name: Create the mongodb certificate directory
|
|
|
|
file: dest={{ mongodb_ssl_cert_dir }} state=directory owner=root group=mongodb mode=0750
|
|
|
|
|
2018-09-25 20:05:53 +02:00
|
|
|
- name: Get the Letsencrypt CA file if there is no local copy yet
|
2018-09-19 17:41:37 +02:00
|
|
|
get_url: url={{ mongodb_ssl_letsencrypt_ca_url }} dest={{ mongodb_ssl_cert_dir }}/{{ mongodb_ssl_letsencrypt_ca_filename }}
|
2018-09-26 16:41:33 +02:00
|
|
|
register: build_mongo_ca_file
|
|
|
|
|
|
|
|
- name: Add the Root CA certificate to the mongodb CA file
|
|
|
|
command: cat {{ mongodb_ssl_root_CA_file }} >> {{ mongodb_ssl_cert_dir }}/{{ mongodb_ssl_letsencrypt_ca_filename }}
|
|
|
|
when: build_mongo_ca_file is changed
|
2018-09-19 17:41:37 +02:00
|
|
|
|
2018-09-12 19:04:46 +02:00
|
|
|
- name: Verify if the mongodb pem file exists
|
|
|
|
stat: path={{ mongodb_ssl_certkey_file }}
|
|
|
|
register: mongodb_pem
|
|
|
|
|
2018-09-12 19:00:01 +02:00
|
|
|
- name: Copy the certificate and its key where the mongo server expects it
|
|
|
|
command: "{{ letsencrypt_acme_services_scripts_dir }}/mongodb"
|
2018-09-13 11:41:24 +02:00
|
|
|
when: not mongodb_pem.stat.exists
|
2018-09-12 19:00:01 +02:00
|
|
|
|
2018-09-11 17:37:10 +02:00
|
|
|
when:
|
|
|
|
- mongodb_ssl_letsencrypt_managed
|
|
|
|
- letsencrypt_acme_install
|
|
|
|
tags: [ 'mongodb', 'letsencrypt', 'mongodb_letsencrypt' ]
|