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

Commit

Permalink
Separate out priv key and cert installs (#31)
Browse files Browse the repository at this point in the history
* Separate out priv key and cert installs

* Allow force replace to be configurable
  • Loading branch information
lakshmi-kannan authored and jdauphant committed Apr 10, 2017
1 parent 0010485 commit e82f5ab
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ssl_certs_cert_path: "{{ssl_certs_path}}/{{ssl_certs_common_name}}.pem"
ssl_certs_csr_path: "{{ssl_certs_path}}/{{ssl_certs_common_name}}.csr"
ssl_certs_dhparam_path: "{{ssl_certs_path}}/dhparam.pem"
ssl_certs_mode: "0700"
ssl_certs_force_replace: yes

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"
Expand Down
31 changes: 21 additions & 10 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,30 @@
and ( ssl_certs_local_privkey_data == '' and ssl_certs_local_cert_data == '' )
tags: [ssl-certs,configuration]

- name: Copy SSL certificates
- name: Copy SSL private key file (if exists)
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
src: "{{ ssl_certs_local_privkey_path }}"
dest: "{{ ssl_certs_privkey_path }}"
owner: "{{ ssl_certs_path_owner }}"
group: "{{ ssl_certs_path_group }}"
mode: "{{ ssl_certs_mode }}"
force: "{{ ssl_certs_force_replace }}"
when: >
( stat_privkey.stat.exists and stat_cert.stat.exists )
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 }}" }
( stat_privkey.stat.exists )
and ( ssl_certs_local_privkey_data == '' )
tags: [ssl-certs,configuration]

- name: Copy SSL certificate file (if exists)
copy:
src: "{{ ssl_certs_local_cert_path }}"
dest: "{{ ssl_certs_cert_path }}"
owner: "{{ ssl_certs_path_owner }}"
group: "{{ ssl_certs_path_group }}"
mode: "{{ ssl_certs_mode }}"
force: "{{ ssl_certs_force_replace }}"
when: >
( stat_cert.stat.exists )
and ( ssl_certs_local_cert_data == '' )
tags: [ssl-certs,configuration]

- name: Copy SSL certificate data
Expand All @@ -60,8 +71,8 @@
owner: "{{ ssl_certs_path_owner }}"
group: "{{ ssl_certs_path_group }}"
mode: "{{ ssl_certs_mode }}"
when: ssl_certs_local_privkey_data != ''
and ssl_certs_local_cert_data != ''
force: "{{ ssl_certs_force_replace }}"
when: item.content != ''
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 e82f5ab

Please sign in to comment.