blob: 43b774bc0022475f50c2edd77de8ce394faaa04e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
---
- name: Create certificates directory certs to current dir
file:
path: "{{ certificates_local_dir }}"
state: directory
# Some of task are delegated to Ansible container because unavailable
# version of python-pyOpenSSL
- name: Generate root CA private key
openssl_privatekey:
path: "{{ certificates_local_dir }}/rootCA.key"
size: 4096
- name: Generate an OpenSSL CSR.
openssl_csr:
path: "{{ certificates_local_dir }}/rootCA.csr"
privatekey_path: "{{ certificates_local_dir }}/rootCA.key"
organization_name: "{{ certificates.organization_name }}"
state_or_province_name: "{{ certificates.state_or_province_name }}"
country_name: "{{ certificates.country_name }}"
locality_name: "{{ certificates.locality_name }}"
basic_constraints:
- CA:TRUE
basic_constraints_critical: true
key_usage:
- digitalSignature
- cRLSign
- keyCertSign
key_usage_critical: true
- name: Generate root CA certificate
openssl_certificate:
provider: selfsigned
path: "{{ certificates_local_dir }}/rootCA.crt"
csr_path: "{{ certificates_local_dir }}/rootCA.csr"
privatekey_path: "{{ certificates_local_dir }}/rootCA.key"
notify: Restart Docker
- name: Generate private Nexus key
openssl_privatekey:
path: "{{ certificates_local_dir }}/nexus_server.key"
size: 4096
- name: Generate Nexus CSR (certificate signing request)
openssl_csr:
path: "{{ certificates_local_dir }}/nexus_server.csr"
privatekey_path: "{{ certificates_local_dir }}/nexus_server.key"
organization_name: "{{ certificates.organization_name }}"
state_or_province_name: "{{ certificates.state_or_province_name }}"
country_name: "{{ certificates.country_name }}"
locality_name: "{{ certificates.locality_name }}"
common_name: registry-1.docker.io
key_usage:
- keyAgreement
- nonRepudiation
- digitalSignature
- keyEncipherment
- dataEncipherment
extended_key_usage:
- serverAuth
subject_alt_name:
"{{ all_simulated_hosts | map('regex_replace', '(.*)', 'DNS:\\1') | list }}"
- name: Sign Nexus certificate
openssl_certificate:
provider: ownca
path: "{{ certificates_local_dir }}/nexus_server.crt"
csr_path: "{{ certificates_local_dir }}/nexus_server.csr"
ownca_path: "{{ certificates_local_dir }}/rootCA.crt"
ownca_privatekey_path: "{{ certificates_local_dir }}/rootCA.key"
|