blob: 851677166d31e3764402d37cc8efe83d9b255bc7 [file] [log] [blame]
Tadas Sutkaitis8d037242024-02-08 02:48:21 +02001# Copyright (c) 2024 VEXXHOST, Inc.
Mohammed Naser38179092023-01-28 19:37:25 +00002#
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: Create self-signed cluster issuer
16 kubernetes.core.k8s:
17 state: present
18 definition:
19 apiVersion: cert-manager.io/v1
20 kind: ClusterIssuer
21 metadata:
22 name: self-signed
23 spec:
24 selfSigned: {}
25
26- name: Import tasks for ClusterIssuer type
27 ansible.builtin.include_tasks: "type/{{ cluster_issuer_type }}/main.yml"
28
29- name: Bootstrap PKI
30 when: cluster_issuer_type in ("self-signed", "ca")
31 block:
32 - name: Wait till the secret is created
33 kubernetes.core.k8s_info:
34 api_version: v1
35 kind: Secret
36 name: "{{ (cluster_issuer_type == 'self-signed') | ternary(cluster_issuer_self_signed_secret_name, cluster_issuer_ca_secret_name) }}"
37 namespace: cert-manager
38 wait: true
39 wait_sleep: 1
40 wait_timeout: 600
41 register: _cluster_issuer_ca_secret
42
43 - name: Copy CA certificate on host
44 ansible.builtin.copy:
45 content: "{{ _cluster_issuer_ca_secret.resources[0].data['tls.crt'] | b64decode }}"
Tadas Sutkaitis8d037242024-02-08 02:48:21 +020046 dest: "{{ '/usr/local/share/ca-certificates' if ansible_facts['os_family'] in ['Debian'] else '/etc/pki/ca-trust/source/anchors' }}/atmosphere.crt"
Tadas Sutkaitis4ace4182023-02-27 04:31:52 +020047 mode: "0644"
Mohammed Naser38179092023-01-28 19:37:25 +000048 notify:
49 - Update CA certificates on host
Mohammed Nasercf8424d2023-01-29 01:10:57 +000050
51- name: Flush all handlers
52 ansible.builtin.meta: flush_handlers