# SPDX-License-Identifier: MIT-0 --- - name: Validate required deployment settings ansible.builtin.assert: that: - the_button_image is string and the_button_image | length > 0 - the_button_ingress_host is string and the_button_ingress_host | length > 0 - the_button_ingress_host | length <= 253 - the_button_ingress_host is match('^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)*[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$') - the_button_name is match('^[a-z]([a-z0-9-]*[a-z0-9])?$') - the_button_name | length <= 50 - the_button_namespace is match('^[a-z0-9]([a-z0-9-]*[a-z0-9])?$') - the_button_namespace | length <= 63 - the_button_tls_secret_name | length > 0 - the_button_duration_seconds | string is match('^[1-9][0-9]*$') - the_button_image_pull_policy in ['Always', 'IfNotPresent', 'Never'] - the_button_ingress_annotations is mapping - the_button_resources is mapping - the_button_storage_access_modes | length > 0 - the_button_wait_timeout | int > 0 fail_msg: >- Set the_button_image to a published application image and the_button_ingress_host to a DNS hostname (no scheme or path). Names must be valid Kubernetes names, and duration and wait timeout must be positive. - name: Create the application namespace kubernetes.core.k8s: kubeconfig: "{{ the_button_kubeconfig | default(omit, true) }}" context: "{{ the_button_kube_context | default(omit, true) }}" state: present apply: true definition: apiVersion: v1 kind: Namespace metadata: name: "{{ the_button_namespace }}" when: the_button_create_namespace | bool - name: Create persistent storage for game data and mailing list kubernetes.core.k8s: kubeconfig: "{{ the_button_kubeconfig | default(omit, true) }}" context: "{{ the_button_kube_context | default(omit, true) }}" state: present apply: true definition: "{{ lookup('ansible.builtin.template', 'pvc.yml.j2') | from_yaml }}" # Do not wait here: WaitForFirstConsumer volumes need the Deployment first. wait: false when: the_button_existing_claim | length == 0 - name: Deploy The Button service, application, and TLS ingress kubernetes.core.k8s: kubeconfig: "{{ the_button_kubeconfig | default(omit, true) }}" context: "{{ the_button_kube_context | default(omit, true) }}" state: present apply: true definition: "{{ lookup('ansible.builtin.template', item) | from_yaml }}" wait: "{{ the_button_wait | bool }}" wait_timeout: "{{ the_button_wait_timeout | int }}" loop: - service.yml.j2 - deployment.yml.j2 - ingress.yml.j2