|
|
@@ -0,0 +1,49 @@ |
|
|
|
--- |
|
|
|
|
|
|
|
- include: key.yml |
|
|
|
- include: csr.yml |
|
|
|
|
|
|
|
- name: certificate host_files directory |
|
|
|
local_action: file |
|
|
|
args: |
|
|
|
path: host_files/{{inventory_hostname}}/certificate |
|
|
|
state: directory |
|
|
|
|
|
|
|
- name: fetch certificate signing request |
|
|
|
fetch: |
|
|
|
src: "{{ certificate_signing_request_file }}" |
|
|
|
dest: host_files/{{inventory_hostname}}/certificate/{{certificate_name}}.csr.pem |
|
|
|
flat: yes |
|
|
|
fail_on_missing: yes |
|
|
|
|
|
|
|
- name: copy certificate signing request |
|
|
|
copy: |
|
|
|
src: host_files/{{inventory_hostname}}/certificate/{{certificate_name}}.csr.pem |
|
|
|
dest: "{{ certificate_authority_directory }}/csr/{{inventory_hostname}}-{{certificate_name}}.csr.pem" |
|
|
|
delegate_to: "{{ certificate_authority_host }}" |
|
|
|
|
|
|
|
- name: sign certificate with ca |
|
|
|
command: openssl ca -selfsign -batch -notext |
|
|
|
-config cnf/ca.cnf |
|
|
|
-in csr/{{inventory_hostname}}-{{certificate_name}}.csr.pem |
|
|
|
-out certs/{{inventory_hostname}}-{{certificate_name}}.cert.pem |
|
|
|
{{ certificate_authority_private_key_password is defined | ternary('-passin env:PRIVATE_KEY_PASSWORD','') }} |
|
|
|
args: |
|
|
|
chdir: "{{ certificate_authority_directory }}" |
|
|
|
creates: "{{ certificate_authority_directory }}/certs/{{inventory_hostname}}-{{certificate_name}}.cert.pem" |
|
|
|
environment: |
|
|
|
PRIVATE_KEY_PASSWORD: "{{ certificate_authority_private_key_password | default('') }}" |
|
|
|
delegate_to: "{{ certificate_authority_host }}" |
|
|
|
|
|
|
|
- name: fetch certificate |
|
|
|
fetch: |
|
|
|
src: "{{ certificate_authority_directory }}/certs/{{inventory_hostname}}-{{certificate_name}}.cert.pem" |
|
|
|
dest: host_files/{{inventory_hostname}}/certificate/{{certificate_name}}.cert.pem |
|
|
|
flat: yes |
|
|
|
fail_on_missing: yes |
|
|
|
delegate_to: "{{ certificate_authority_host }}" |
|
|
|
|
|
|
|
- name: copy certificate |
|
|
|
copy: |
|
|
|
src: host_files/{{inventory_hostname}}/certificate/{{certificate_name}}.cert.pem |
|
|
|
dest: "{{ certificate_file }}" |