Skip to content

Commit c2169e8

Browse files
tristanGitHub Enterprise
authored andcommitted
Merge pull request #178 from tristan/customer-changes
Misc security fixes
2 parents 559749a + 84726ea commit c2169e8

File tree

9 files changed

+478
-16
lines changed

9 files changed

+478
-16
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# How to: Clear CA Server state
2+
3+
The CA Server (using `openssl ca`) can be used to sign the host certificates used to deploy the cluster.
4+
5+
There may be cases where you wish to replace the host keys and certificates.
6+
7+
# Replace the CA
8+
9+
On each host in the cluster, move or delete the following directory:
10+
11+
```
12+
/opt/cloudera/security/pki
13+
```
14+
15+
On the `ca_server` host, move or delete the following directory:
16+
17+
```
18+
/ca
19+
```
20+
21+
Re-run the playbook.
22+
23+
At a minimum, re-run the following in the order they appear:
24+
25+
- `create_infrastructure.yml`
26+
- `prepare_tls.yml`
27+
28+
# Keep the CA but replace host certificates
29+
30+
On each host in the cluster where you wish to replace the host keys and certificates, move or delete the following directory:
31+
32+
```
33+
/opt/cloudera/security/pki
34+
```
35+
36+
On the `ca_server` host, execute the following for each host you wish to replace:
37+
38+
```
39+
openssl ca -config /ca/intermediate/openssl.cnf -revoke /ca/intermediate/cert/<host-certificate>.pem -passin pass:<ca-password>
40+
```
41+
42+
__Note:__ The default CA password is `password` and can be configured by setting:
43+
44+
- `ca_server_root_key_password`
45+
- `ca_server_intermediate_key_password`
46+
47+
Now move or delete the corresponding host certificates from:
48+
49+
```
50+
/ca/intermediate/cert
51+
```
52+
53+
Re-run the playbook.
54+
55+
At a minimum, re-run `prepare_tls.yml`.
56+
57+
__Note:__ You can skip the revoke step by setting `unique_subject` in `/ca/intermediate/index.txt.attr` to `no`.
58+
59+
__Note:__ The CA Server is meant for testing only. Please use an enterprise CA Server in production.

docs/how-to/externally-signed.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# How to: Setup externally signed TLS certificates
2+
3+
The playbook is able to provision an internal CA and automatically sign the host certificates.
4+
5+
However, it is more likely that an external CA will be used in production environments.
6+
7+
This guide will run through specifics for deploying clusters using an external CA to sign the host certificates.
8+
9+
At a high-level, the playbook generates and distributes the TLS keys and certificates in three steps:
10+
11+
- Phase 1 (generation)
12+
* Create the host keys
13+
* Generate the keystores
14+
* Generate the CSRs
15+
* Copy the CSRs to the Ansible controller
16+
- Phase 2 (signing)
17+
* Sign the certificates
18+
- Phase 3 (installation)
19+
* Copy the signed certificates to the hosts
20+
* Copy the CA certificates to the hosts
21+
22+
When `ca_server` is used, this all occurs automatically.
23+
24+
However, when an external CA is used, a few manual steps are required to complete the deployment:
25+
26+
Starting with the definition, assuming nothing has been deployed:
27+
28+
## Ensure that `ca_server` is **not** present in the inventory
29+
30+
The `ca_server` is the playbook's internal CA.
31+
32+
As we wish to use an external CA, it should be omitted from the inventory file.
33+
34+
## Set `tls_ca_certs` to point to the external CA certificates
35+
36+
Here, we need to set `tls_ca_certs` in `extra_vars.yml` to point to the external CA certificates (on the Ansible controller):
37+
38+
```
39+
tls_ca_certs:
40+
- alias: ipaca
41+
path: /root/ca.crt
42+
```
43+
44+
In this example, our CA certificate exists on the Ansible controller at `/root/ca.crt`.
45+
46+
**Note:** If you have an intermediate CA and a root CA, please include both certificates here.
47+
48+
## Run the playbook deployment as usual
49+
50+
If everything is configured correctly, it should run as usual until we reach `prepare_tls.yml`.
51+
52+
Here, in `prepare_tls.yml`, it will fail with a message:
53+
54+
> Signed cert for <hostname> could not be found. If manual signing is required, do this now and re-run the playbook with 'tls_signed_certs_dir' variable set.
55+
56+
E.g.
57+
58+
```
59+
TASK [security/tls_install_certs : fail] **************************************************************************************************************
60+
fatal: [host-1.example.com] FAILED! => {"changed": false, "msg": "\"Signed cert for host-1.example.com could not be found. If manual signing is required, do this now and re-run the playbook with 'tls_signed_certs_dir' variable set.\n"}
61+
fatal: [host-2.example.com] FAILED! => {"changed": false, "msg": "\"Signed cert for host-1.example.com could not be found. If manual signing is required, do this now and re-run the playbook with 'tls_signed_certs_dir' variable set.\n"}
62+
fatal: [host-3.example.com] FAILED! => {"changed": false, "msg": "\"Signed cert for host-1.example.com could not be found. If manual signing is required, do this now and re-run the playbook with 'tls_signed_certs_dir' variable set.\n"}
63+
fatal: [host-4.example.com] FAILED! => {"changed": false, "msg": "\"Signed cert for host-1.example.com could not be found. If manual signing is required, do this now and re-run the playbook with 'tls_signed_certs_dir' variable set.\n"}
64+
```
65+
66+
This is expected.
67+
68+
At this point, the playbook will have generated the TLS keys and CSRs and copied the CSRs to the Ansible controller (stage 1).
69+
70+
It is up to us now to sign the CSRs and copy the signed certificates back to the Ansible controller:
71+
72+
## Sign the CSRs generated by the playbook
73+
74+
You will find copies of the TLS CSRs in `{{ local_temp_dir }}/csrs` on the Ansible controller (default `/tmp/csrs`).
75+
76+
```
77+
# ls /tmp/csrs
78+
host-1.example.com.csr host-3.example.com.csr
79+
host-2.example.com.csr host-4.example.com.csr
80+
```
81+
82+
Sign the CSRs and copy the signed certificates to the Ansible controller using the same filename, replacing `.csr` with `.pem`.
83+
84+
Place these signed certificates in `{{ local_temp_dir }}/certs` on the Ansible controller (default `/tmp/certs`).
85+
86+
```
87+
# ls /tmp/certs
88+
host-1.example.com.pem host-3.example.com.pem
89+
host-2.example.com.pem host-4.example.com.pem
90+
```
91+
92+
## Rerun the playbook
93+
94+
The playbook can be restarted now that the signed certificates exist on the Ansible controller (stage 2).
95+
96+
**Note:** To save time, you can start the playbook from `prepare_tls.yml` – skipping completed steps.
97+
98+
The playbook will distribute the new signed certificates and continue as usual.
99+
100+
No other steps are required.

prepare_tls.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
flat: yes
4747
loop:
4848
- src: "{{ ca_server_root_cert_path }}"
49-
dest: "{{ local_temp_dir }}/certs/rootca.pem"
49+
dest: "{{ local_temp_dir }}/certs/cluster_rootca.pem"
5050
- src: "{{ ca_server_intermediate_cert_path }}"
51-
dest: "{{ local_temp_dir }}/certs/intca.pem"
51+
dest: "{{ local_temp_dir }}/certs/cluster_intca.pem"
5252
loop_control:
5353
loop_var: cert
5454
vars_files:

roles/cloudera_manager/admin_password/check/tasks/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
run_once: True
2727
when: cloudera_manager_admin_password is defined
2828

29+
- set_fact:
30+
cloudera_manager_api_password: "admin"
31+
run_once: True
32+
2933
- name: Set the playbook to use the non-default Cloudera Manager admin password
3034
set_fact:
3135
cloudera_manager_api_password: "{{ cloudera_manager_admin_password }}"

0 commit comments

Comments
 (0)