blob: 72e9ac4bb39f5e8f22a7263887ed8ca9e3176c90 [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
Mohammed Naser6a8b6ca2024-05-30 17:25:30 -040016 run_once: true
Mohammed Naser38179092023-01-28 19:37:25 +000017 kubernetes.core.k8s:
18 state: present
19 definition:
20 apiVersion: cert-manager.io/v1
21 kind: ClusterIssuer
22 metadata:
23 name: self-signed
24 spec:
25 selfSigned: {}
26
27- name: Import tasks for ClusterIssuer type
28 ansible.builtin.include_tasks: "type/{{ cluster_issuer_type }}/main.yml"
29
30- name: Bootstrap PKI
31 when: cluster_issuer_type in ("self-signed", "ca")
32 block:
33 - name: Wait till the secret is created
Mohammed Naser6a8b6ca2024-05-30 17:25:30 -040034 run_once: true
Mohammed Naser38179092023-01-28 19:37:25 +000035 kubernetes.core.k8s_info:
36 api_version: v1
37 kind: Secret
38 name: "{{ (cluster_issuer_type == 'self-signed') | ternary(cluster_issuer_self_signed_secret_name, cluster_issuer_ca_secret_name) }}"
39 namespace: cert-manager
40 wait: true
41 wait_sleep: 1
42 wait_timeout: 600
43 register: _cluster_issuer_ca_secret
44
45 - name: Copy CA certificate on host
46 ansible.builtin.copy:
47 content: "{{ _cluster_issuer_ca_secret.resources[0].data['tls.crt'] | b64decode }}"
Tadas Sutkaitis8d037242024-02-08 02:48:21 +020048 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 +020049 mode: "0644"
Mohammed Naser38179092023-01-28 19:37:25 +000050 notify:
51 - Update CA certificates on host
Mohammed Nasercf8424d2023-01-29 01:10:57 +000052
53- name: Flush all handlers
54 ansible.builtin.meta: flush_handlers