Tadas Sutkaitis | 8d03724 | 2024-02-08 02:48:21 +0200 | [diff] [blame] | 1 | # Copyright (c) 2024 VEXXHOST, Inc. |
Mohammed Naser | 3817909 | 2023-01-28 19:37:25 +0000 | [diff] [blame] | 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: Create self-signed cluster issuer |
Mohammed Naser | 6a8b6ca | 2024-05-30 17:25:30 -0400 | [diff] [blame] | 16 | run_once: true |
Mohammed Naser | 3817909 | 2023-01-28 19:37:25 +0000 | [diff] [blame] | 17 | 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 Naser | 6a8b6ca | 2024-05-30 17:25:30 -0400 | [diff] [blame] | 34 | run_once: true |
Mohammed Naser | 3817909 | 2023-01-28 19:37:25 +0000 | [diff] [blame] | 35 | 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 Sutkaitis | 8d03724 | 2024-02-08 02:48:21 +0200 | [diff] [blame] | 48 | dest: "{{ '/usr/local/share/ca-certificates' if ansible_facts['os_family'] in ['Debian'] else '/etc/pki/ca-trust/source/anchors' }}/atmosphere.crt" |
Tadas Sutkaitis | 4ace418 | 2023-02-27 04:31:52 +0200 | [diff] [blame] | 49 | mode: "0644" |
Mohammed Naser | 3817909 | 2023-01-28 19:37:25 +0000 | [diff] [blame] | 50 | notify: |
| 51 | - Update CA certificates on host |
Mohammed Naser | cf8424d | 2023-01-29 01:10:57 +0000 | [diff] [blame] | 52 | |
| 53 | - name: Flush all handlers |
| 54 | ansible.builtin.meta: flush_handlers |