-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-use recipes for certificate signing in vrouter and standalone
- Loading branch information
Showing
3 changed files
with
48 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
- name: Fetch CSR | ||
fetch: | ||
src: "{{ INDIGOVR_CERT_DIR }}/{{ INDIGOVR_CERT_NAME }}.csr" | ||
dest: "/tmp/._indigovr_tmp_{{ INDIGOVR_CERT_NAME }}.csr" | ||
flat: yes | ||
fail_on_missing: yes | ||
|
||
- name: Copy CSR to CA | ||
copy: | ||
src: "/tmp/._indigovr_tmp_{{ INDIGOVR_CERT_NAME }}.csr" | ||
dest: "{{ INDIGOVR_CA_DIR }}/certs/{{ INDIGOVR_CERT_NAME }}.csr" | ||
delegate_to: "{{ INDIGOVR_CENTRALPOINT_IP }}" | ||
become: true | ||
|
||
- name: Check certfile stat | ||
stat: | ||
path: "{{ INDIGOVR_CA_DIR }}/certs/{{ INDIGOVR_CERT_NAME }}.crt" | ||
register: certfile | ||
delegate_to: "{{ INDIGOVR_CENTRALPOINT_IP }}" | ||
become: true | ||
|
||
- name: Check csr stat | ||
stat: | ||
path: "{{ INDIGOVR_CA_DIR }}/certs/{{ INDIGOVR_CERT_NAME }}.csr" | ||
register: csrfile | ||
delegate_to: "{{ INDIGOVR_CENTRALPOINT_IP }}" | ||
become: true | ||
|
||
- block: | ||
- name: Revoke previous certificate | ||
command: openssl ca -config "{{ INDIGOVR_CA_DIR }}/openssl.cnf" -revoke "{{ INDIGOVR_CA_DIR }}/certs/{{ INDIGOVR_CERT_NAME }}.crt" | ||
- name: Delete previous certificate | ||
command: rm -fv "{{ INDIGOVR_CA_DIR }}/certs/{{ INDIGOVR_CERT_NAME }}.crt" | ||
when: certfile.stat.exists and certfile.stat.mtime < csrfile.stat.mtime | ||
delegate_to: "{{ INDIGOVR_CENTRALPOINT_IP }}" | ||
become: true | ||
|
||
- name: Sign certificate | ||
shell: openssl ca -config "{{ INDIGOVR_CA_DIR }}/openssl.cnf" -extensions usr_cert -notext -batch -in "{{ INDIGOVR_CA_DIR }}/certs/{{ INDIGOVR_CERT_NAME }}.csr" -out "{{ INDIGOVR_CA_DIR }}/certs/{{ INDIGOVR_CERT_NAME }}.crt" | ||
args: | ||
creates: "{{ INDIGOVR_CA_DIR }}/certs/{{ INDIGOVR_CERT_NAME }}.crt" | ||
delegate_to: "{{ INDIGOVR_CENTRALPOINT_IP }}" | ||
become: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters