From 54caff8fb617a40193b6fb4008c34f85e32e9222 Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Fri, 15 Jul 2022 12:14:12 +0200 Subject: [PATCH] Add conditional;Inject manifests --- .../roles/metacluster/tasks/main.yml | 2 +- ansible/roles/metacluster/tasks/components.yml | 14 +++++++++++++- .../metacluster/templates/ingressroutetcp.j2 | 7 +++++++ ansible/vars/metacluster.yml | 17 +++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 ansible/roles/metacluster/templates/ingressroutetcp.j2 diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/main.yml b/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/main.yml index 761d86e..f8beb1d 100644 --- a/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/main.yml +++ b/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/main.yml @@ -215,7 +215,7 @@ loop_control: label: "{{ item.organization + '/' + item.body.name }}" - # when: gitea_existing_config.json.data is undefined + when: (gitea_existing_config.json is undefined) or (gitea_existing_config.json.data | length == 0) module_defaults: ansible.builtin.uri: diff --git a/ansible/roles/metacluster/tasks/components.yml b/ansible/roles/metacluster/tasks/components.yml index be73b3c..8141160 100644 --- a/ansible/roles/metacluster/tasks/components.yml +++ b/ansible/roles/metacluster/tasks/components.yml @@ -53,7 +53,19 @@ docker://{{ item }} \ docker-archive:./{{ ( item | regex_findall('[^/:]+'))[-2] }}.tar:{{ item }} chdir: /opt/metacluster/container-images - loop: "{{ containerimages.results | map(attribute='stdout_lines') | flatten + dependencies.container_images }}" + loop: "{{ (containerimages.results | map(attribute='stdout_lines') | flatten) + dependencies.container_images }}" + +- name: Inject manifests + ansible.builtin.template: + src: "{{ item.type }}.j2" + dest: /var/lib/rancher/k3s/server/manifests/{{ item.name }}-manifest.yaml + owner: root + group: root + mode: 0600 + when: item is defined + loop: "{{ lookup('ansible.builtin.dict', components) | map(attribute='value.manifests') | list }}" + loop_control: + label: "{{ item.key }}" - name: Compress tarballs community.general.archive: diff --git a/ansible/roles/metacluster/templates/ingressroutetcp.j2 b/ansible/roles/metacluster/templates/ingressroutetcp.j2 new file mode 100644 index 0000000..53fad5e --- /dev/null +++ b/ansible/roles/metacluster/templates/ingressroutetcp.j2 @@ -0,0 +1,7 @@ +apiVersion: traefik.containo.us/v1alpha1 +kind: IngressRouteTCP +metadata: + name: {{ item.name }} + namespace: {{ item.namespace }} +spec: +{{ item.config }} diff --git a/ansible/vars/metacluster.yml b/ansible/vars/metacluster.yml index d180ffe..e52c795 100644 --- a/ansible/vars/metacluster.yml +++ b/ansible/vars/metacluster.yml @@ -7,6 +7,9 @@ platform: - name: traefik namespace: kube-system config: |2 + # ingressRoute: + # dashboard: + # enabled: true ports: ssh: port: 8022 @@ -23,6 +26,8 @@ platform: url: https://dl.gitea.io/charts/ - name: argo url: https://argoproj.github.io/argo-helm + - name: sealed-secrets + url: https://bitnami-labs.github.io/sealed-secrets components: @@ -78,6 +83,18 @@ components: paths: - path: / pathType: Prefix + manifests: + - type: ingressroutetcp + name: gitea-ssh + namespace: gitea + config: |2 + entryPoints: + - ssh + routes: + - match: HostSNI(`*`) + services: + - name: gitea-ssh + port: 22 argo-cd: helm: