blob: 8d609174c8964c7eaeeb378fb38bd8fd9788d8cf [file] [log] [blame]
Mohammed Naserb7b97d62022-03-12 16:30:00 -05001# Copyright (c) 2022 VEXXHOST, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15- name: Deploy Helm chart
16 kubernetes.core.helm:
17 name: cert-manager
18 chart_ref: jetstack/cert-manager
19 chart_version: v1.7.1
20 release_namespace: cert-manager
21 create_namespace: true
22 kubeconfig: /etc/kubernetes/admin.conf
23 values:
24 installCRDs: true
25 volumes:
26 - name: etc-ssl-certs
27 hostPath:
28 path: /etc/ssl/certs
29 volumeMounts:
30 - name: etc-ssl-certs
31 mountPath: /etc/ssl/certs
32 readOnly: true
33
34- name: Create issuer
35 kubernetes.core.k8s:
36 state: present
37 definition:
38 apiVersion: cert-manager.io/v1
39 kind: Issuer
40 metadata:
41 name: openstack
42 namespace: openstack
43 spec: "{{ cert_manager_issuer }}"
okozachenko05a72ed2022-04-12 23:01:43 +100044
okozachenko674f9b72022-04-19 01:28:33 +100045- name: Bootstrap self-signed PKI
46 block:
47 - name: Create self-signed issuer
48 kubernetes.core.k8s:
49 state: present
50 definition:
51 apiVersion: cert-manager.io/v1
okozachenko05a72ed2022-04-12 23:01:43 +100052 kind: ClusterIssuer
okozachenko674f9b72022-04-19 01:28:33 +100053 metadata:
54 name: selfsigned-issuer
55 spec:
56 selfSigned: {}
57
58 - name: Bootstrap a custom root certificate for a private PKI
59 kubernetes.core.k8s:
60 state: present
61 definition:
62 apiVersion: cert-manager.io/v1
63 kind: Certificate
64 metadata:
65 name: selfsigned-ca
66 namespace: openstack
67 spec:
68 isCA: true
69 commonName: selfsigned-ca
70 secretName: root-secret
71 duration: 86400h # 3600d
72 renewBefore: 360h # 15d
73 privateKey:
74 algorithm: ECDSA
75 size: 256
76 issuerRef:
77 name: selfsigned-issuer
78 kind: ClusterIssuer
79 group: cert-manager.io
80
81 - name: Wait till the root secret is created
82 kubernetes.core.k8s_info:
83 api_version: v1
84 kind: Secret
85 wait: true
86 name: root-secret
87 namespace: openstack
88 wait_sleep: 10
89 wait_timeout: 300
90 register: _openstack_helm_root_secret
91
92 - name: Copy CA certificate on host
93 ansible.builtin.copy:
94 content: "{{ _openstack_helm_root_secret.resources[0].data['tls.crt'] | b64decode }}"
95 dest: "/usr/local/share/ca-certificates/self-signed-osh-ca.crt"
96 mode: "0644"
97
98 - name: Update ca certificates on host
99 ansible.builtin.command:
100 cmd: update-ca-certificates
101 changed_when: false
102 when:
103 - cert_manager_issuer.ca.secretName is defined
104 - cert_manager_issuer.ca.secretName == "root-secret"