blob: c9c09010b15332111f02aafad7b014d67c768925 [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
Mohammed Naserc8e1a452022-08-11 16:16:13 -040015- name: Create Issuer
Mohammed Naserb7b97d62022-03-12 16:30:00 -050016 kubernetes.core.k8s:
17 state: present
18 definition:
19 apiVersion: cert-manager.io/v1
20 kind: Issuer
21 metadata:
22 name: openstack
23 namespace: openstack
24 spec: "{{ cert_manager_issuer }}"
Mohammed Naserc8e1a452022-08-11 16:16:13 -040025 # NOTE(mnaser): Since we haven't moved to the operator pattern yet, we need to
26 # keep retrying a few times as the CRDs might not be installed
27 # yet.
28 retries: 60
29 delay: 5
30 register: _result
31 until: _result is not failed
okozachenko05a72ed2022-04-12 23:01:43 +100032
okozachenko674f9b72022-04-19 01:28:33 +100033- name: Bootstrap self-signed PKI
34 block:
35 - name: Create self-signed issuer
36 kubernetes.core.k8s:
37 state: present
38 definition:
39 apiVersion: cert-manager.io/v1
okozachenko05a72ed2022-04-12 23:01:43 +100040 kind: ClusterIssuer
okozachenko674f9b72022-04-19 01:28:33 +100041 metadata:
42 name: selfsigned-issuer
43 spec:
44 selfSigned: {}
45
46 - name: Bootstrap a custom root certificate for a private PKI
47 kubernetes.core.k8s:
48 state: present
49 definition:
50 apiVersion: cert-manager.io/v1
51 kind: Certificate
52 metadata:
53 name: selfsigned-ca
54 namespace: openstack
55 spec:
56 isCA: true
57 commonName: selfsigned-ca
58 secretName: root-secret
59 duration: 86400h # 3600d
60 renewBefore: 360h # 15d
61 privateKey:
62 algorithm: ECDSA
63 size: 256
64 issuerRef:
65 name: selfsigned-issuer
66 kind: ClusterIssuer
67 group: cert-manager.io
68
69 - name: Wait till the root secret is created
70 kubernetes.core.k8s_info:
71 api_version: v1
72 kind: Secret
73 wait: true
74 name: root-secret
75 namespace: openstack
76 wait_sleep: 10
77 wait_timeout: 300
78 register: _openstack_helm_root_secret
79
80 - name: Copy CA certificate on host
81 ansible.builtin.copy:
82 content: "{{ _openstack_helm_root_secret.resources[0].data['tls.crt'] | b64decode }}"
83 dest: "/usr/local/share/ca-certificates/self-signed-osh-ca.crt"
84 mode: "0644"
85
86 - name: Update ca certificates on host
87 ansible.builtin.command:
88 cmd: update-ca-certificates
89 changed_when: false
90 when:
91 - cert_manager_issuer.ca.secretName is defined
92 - cert_manager_issuer.ca.secretName == "root-secret"