generate private key on localhost
This commit is contained in:
parent
957f3e29ff
commit
d01e17c4dd
2 changed files with 26 additions and 5 deletions
|
@ -4,4 +4,5 @@
|
||||||
roles:
|
roles:
|
||||||
- generate-cert
|
- generate-cert
|
||||||
vars:
|
vars:
|
||||||
path: /tmp/test-client
|
directory: /tmp/test-pki
|
||||||
|
cname: test-client
|
||||||
|
|
|
@ -3,10 +3,30 @@
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "Test"
|
msg: "Test"
|
||||||
|
|
||||||
|
- name: Ensure the directory containing the cert exist
|
||||||
|
file:
|
||||||
|
path: "{{ directory }}"
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: Test if the key already exist
|
||||||
|
stat:
|
||||||
|
path: "{{ directory }}/{{ cname }}.key"
|
||||||
|
register: key_file
|
||||||
|
|
||||||
- name: Generate private key
|
- name: Generate private key
|
||||||
|
become: false
|
||||||
openssl_privatekey:
|
openssl_privatekey:
|
||||||
path: "{{ path }}.key"
|
path: "/tmp/ansible_hacky_pki_{{ cname }}.key"
|
||||||
owner: "{{ owner | default(omit) }}"
|
mode: u=rw,g=,o=
|
||||||
group: "{{ group | default(omit) }}"
|
|
||||||
mode: "{{ key_mode | default(omit) }}"
|
|
||||||
size: "{{ key_size | default(omit) }}"
|
size: "{{ key_size | default(omit) }}"
|
||||||
|
delegate_to: localhost
|
||||||
|
when: not key_file.stat.exists
|
||||||
|
|
||||||
|
- name: Send private key to the server
|
||||||
|
copy:
|
||||||
|
src: "/tmp/ansible_hacky_pki_{{ cname }}.key"
|
||||||
|
dest: "{{ directory }}/{{ cname }}.key"
|
||||||
|
owner: "{{ owner | default('root') }}"
|
||||||
|
group: "{{ group | default('root') }}"
|
||||||
|
mode: "{{ key_mode | default('u=rw,g=,o=') }}"
|
||||||
|
when: not key_file.stat.exists
|
||||||
|
|
Loading…
Reference in a new issue