Skip to content

Commit 7fe771e

Browse files
authored
Add FreeIPA role for issuing TLS certificates to enrolled hosts (#307)
Signed-off-by: rsuplina <[email protected]>
1 parent dee6a59 commit 7fe771e

File tree

11 files changed

+841
-0
lines changed

11 files changed

+841
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# freeipa_server_enrolled_tls
2+
3+
Issue a TLS certificate and private key for an enrolled host
4+
5+
This role issues a **TLS certificate and private key** for a host that is enrolled in FreeIPA. This is useful for hosts that are already members of the FreeIPA domain and need TLS certificates for their services. The process includes generating a private key and Certificate Signing Request (CSR), and then requesting a certificate from FreeIPA's Certificate Authority (CA) using the host's enrolled identity.
6+
7+
The role will:
8+
9+
* Authenticate to the FreeIPA server using the provided administrative credentials.
10+
* Generate a private key and CSR directly on the target host.
11+
* Request a TLS certificate from FreeIPA's CA for the enrolled host.
12+
* The certificate and key will be saved directly to their final locations.
13+
14+
15+
## Requirements
16+
17+
* The target host must be already enrolled in the FreeIPA domain.
18+
* The `ipaadmin_principal` must have permissions to issue certificates in FreeIPA.
19+
* Write access to the specified certificate and key paths on the FreeIPA server.
20+
21+
## Dependencies
22+
23+
None.
24+
25+
## Parameters
26+
27+
| Variable | Type | Required | Default | Description |
28+
| --- | --- | --- | --- | --- |
29+
| `ipaadmin_password` | `str` | `True` | | **FreeIPA** admin password for authentication. |
30+
| `ipaadmin_principal` | `str` | `False` | `admin` | **FreeIPA** admin principal for authentication. |
31+
| `enrolled_hostname` | `str` | `True` | | The hostname for which the certificate will be issued. Must be an enrolled FreeIPA client. |
32+
| `enrolled_principal_type` | `str` | `False` | `host` | The type of principal for certificate request (e.g., host, service). |
33+
| `enrolled_cert_key_path` | `path` | `False` | `/etc/pki/tls/private/host.key` | The path on the target host to save the generated private key file. |
34+
| `enrolled_cert_csr_path` | `path` | `False` | `/etc/pki/tls/private/host.csr` | The path on the target host to save the generated CSR file. |
35+
| `enrolled_cert_path` | `path` | `False` | `/etc/pki/tls/certs/host.crt` | The path on the target host to save the issued TLS certificate. |
36+
37+
## Example Playbook
38+
39+
```yaml
40+
- hosts: enrolled_hosts
41+
tasks:
42+
- name: Issue a TLS certificate and private key for enrolled host
43+
ansible.builtin.import_role:
44+
name: cloudera.exe.freeipa_server_enrolled_tls
45+
vars:
46+
enrolled_hostname: "hostname.example.internal"
47+
ipaadmin_password: "password"
48+
enrolled_cert_key_path: "/etc/pki/tls/private/gateway.key"
49+
enrolled_cert_path: "/etc/pki/tls/certs/gateway.crt"
50+
```
51+
52+
## License
53+
54+
```
55+
Copyright 2025 Cloudera, Inc.
56+
57+
Licensed under the Apache License, Version 2.0 (the "License");
58+
you may not use this file except in compliance with the License.
59+
You may obtain a copy of the License at
60+
61+
https://www.apache.org/licenses/LICENSE-2.0
62+
63+
Unless required by applicable law or agreed to in writing, software
64+
distributed under the License is distributed on an "AS IS" BASIS,
65+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
66+
See the License for the specific language governing permissions and
67+
limitations under the License.
68+
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
# Copyright 2025 Cloudera, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
ipaadmin_principal: admin
17+
ipaadmin_password: "{{ undef(hint='Please define the FreeIPA adminstrator principal password') }}"
18+
19+
enrolled_principal_type: host
20+
enrolled_cert_key_path: "/etc/pki/tls/private/host.key"
21+
enrolled_cert_csr_path: "/etc/pki/tls/private/host.csr"
22+
enrolled_cert_path: "/etc/pki/tls/certs/host.crt"
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
# Copyright 2025 Cloudera, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
argument_specs:
17+
main:
18+
short_description: Issue a TLS certificate and private key for an enrolled host
19+
description:
20+
- Issue a TLS certificate and private key for a host that is already enrolled in FreeIPA.
21+
- The certificate is requested from FreeIPA CA using the enrolled host's identity.
22+
author: Cloudera Labs
23+
version_added: 3.1.0
24+
options:
25+
ipaadmin_password:
26+
description: FreeIPA admin password used for authentication.
27+
type: str
28+
required: true
29+
ipaadmin_principal:
30+
description: FreeIPA admin principal used for authentication.
31+
type: str
32+
default: admin
33+
enrolled_hostname:
34+
description:
35+
- The hostname for which the certificate will be issued.
36+
type: str
37+
required: true
38+
enrolled_cert_key_path:
39+
description: The path to the private key file for the TLS certificate.
40+
type: str
41+
default: /etc/pki/tls/private/host.key
42+
enrolled_cert_csr_path:
43+
description: The path to the CSR file for the TLS certificate.
44+
type: str
45+
default: /etc/pki/tls/private/host.csr
46+
enrolled_cert_path:
47+
description: The path of issued TLS certificate.
48+
type: str
49+
default: /etc/pki/tls/certs/host.crt
50+
enrolled_principal_type:
51+
description:
52+
- The type of principal for certificate request (e.g., host, service).
53+
type: str
54+
default: host
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
# Copyright 2025 Cloudera, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
- name: Converge
17+
hosts: all
18+
gather_facts: true
19+
tasks:
20+
- name: Provision enrolled TLS
21+
ansible.builtin.import_role:
22+
name: cloudera.exe.freeipa_server_enrolled_tls

0 commit comments

Comments
 (0)