send the cert in the right file and clean localhost

master
histausse 3 years ago
parent 7081c0411c
commit 3c643fe012
Signed by: histausse
GPG Key ID: 67486F107F62E9E9

@ -4,5 +4,5 @@
roles:
- generate-cert
vars:
directory: /tmp/test-pki
cname: test-client
directory: /etc/nginx/certs/
cname: example.com

@ -79,6 +79,15 @@
mode: "{{ key_mode | default('u=rw,g=,o=') }}"
when: not key_file.stat.exists
- name: Send certificate to the server
copy:
src: "/tmp/ansible_hacky_pki_{{ cname }}.crt"
dest: "{{ directory }}/{{ cname }}.crt"
owner: "{{ owner | default('root') }}"
group: "{{ group | default('root') }}"
mode: "{{ key_mode | default('u=rw,g=r,o=r') }}"
when: not key_file.stat.exists
# Clean up
- name: Remove the local cert key
become: false
@ -95,3 +104,27 @@
state: absent
delegate_to: localhost
when: not key_file.stat.exists
- name: Remove the local certificate
become: false
file:
path: "/tmp/ansible_hacky_pki_{{ cname }}.crt"
state: absent
delegate_to: localhost
when: not key_file.stat.exists
- name: Remove the CA certificate
become: false
file:
path: /tmp/ansible_hacky_pki_ca.crt
state: absent
delegate_to: localhost
when: not key_file.stat.exists
- name: Remove the CA key
become: false
file:
path: /tmp/ansible_hacky_pki_ca.key
state: absent
delegate_to: localhost
when: not key_file.stat.exists

Loading…
Cancel
Save