Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

Commit

Permalink
Give the ability to unset certificate and private keys data (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
BboyKeen authored and jdauphant committed Feb 3, 2017
1 parent abef8e0 commit 3266d09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ ssl_certs_mode: "0700"

ssl_certs_local_privkey_path: "{{inventory_dir|default(playbook_dir)}}/files/ssl/{{ssl_certs_common_name}}.key"
ssl_certs_local_cert_path: "{{inventory_dir|default(playbook_dir)}}/files/ssl/{{ssl_certs_common_name}}.pem"
ssl_certs_local_privkey_data: ""
ssl_certs_local_cert_data: ""

ssl_certs_generate_self_signed: true
ssl_certs_key_size: "2048"
Expand Down
7 changes: 4 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
- include: generate.yml
when: >
( not stat_privkey.stat.exists and not stat_cert.stat.exists )
and ( ssl_certs_local_privkey_data is undefined and ssl_certs_local_cert_data is undefined )
and ( ssl_certs_local_privkey_data == '' and ssl_certs_local_cert_data == '' )
tags: [ssl-certs,configuration]

- name: Copy SSL certificates
Expand All @@ -47,7 +47,7 @@
mode: "{{ ssl_certs_mode }}"
when: >
( stat_privkey.stat.exists and stat_cert.stat.exists )
and ( ssl_certs_local_privkey_data is undefined and ssl_certs_local_cert_data is undefined )
and ( ssl_certs_local_privkey_data == '' and ssl_certs_local_cert_data == '' )
with_items:
- { src: "{{ ssl_certs_local_cert_path }}", dest: "{{ ssl_certs_cert_path }}" }
- { src: "{{ ssl_certs_local_privkey_path }}", dest: "{{ ssl_certs_privkey_path }}" }
Expand All @@ -60,7 +60,8 @@
owner: "{{ ssl_certs_path_owner }}"
group: "{{ ssl_certs_path_group }}"
mode: "{{ ssl_certs_mode }}"
when: ssl_certs_local_privkey_data is defined and ssl_certs_local_cert_data is defined
when: ssl_certs_local_privkey_data != ''
and ssl_certs_local_cert_data != ''
with_items:
- { content: "{{ ssl_certs_local_cert_data|default }}", dest: "{{ ssl_certs_cert_path }}" }
- { content: "{{ ssl_certs_local_privkey_data|default }}", dest: "{{ ssl_certs_privkey_path }}" }
Expand Down

0 comments on commit 3266d09

Please sign in to comment.