From 2cd2c4c6d0fee596d11e3063cb5b6e3a84757369 Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Sun, 28 Aug 2022 20:10:08 +0200 Subject: [PATCH] Fix typo;Fix readycheck;Add argocd applicationset --- .../roles/metacluster/tasks/git.yml | 2 +- .../roles/metacluster/tasks/gitops.yml | 17 +++++++++-- .../roles/metacluster/tasks/k3s.yml | 4 ++- .../templates/applicationset.j2 | 28 +++++++++++++++++++ ansible/vars/metacluster.yml | 2 +- 5 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 ansible/roles/firstboot/files/ansible_payload/templates/applicationset.j2 diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/git.yml b/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/git.yml index 615a062..f4f2a6a 100644 --- a/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/git.yml +++ b/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/git.yml @@ -37,7 +37,7 @@ - name: Ensure gitea API availability ansible.builtin.uri: - url: https://git.{{ vapp['metacluster.fqdn'] }}/api/healtz + url: https://git.{{ vapp['metacluster.fqdn'] }}/api/healthz method: GET register: api_readycheck until: api_readycheck.json.status | default(false) | bool diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/gitops.yml b/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/gitops.yml index 421e046..5b99ca6 100644 --- a/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/gitops.yml +++ b/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/gitops.yml @@ -29,9 +29,6 @@ password: "{{ vapp['guestinfo.rootpw'] }}" register: argocd_api_token - # - name: Create umbrella application - # ansible.builtin.template: - # - name: Configure metacluster-gitops repository ansible.builtin.template: src: gitrepo.j2 @@ -48,6 +45,20 @@ notify: - Apply manifests + - name: Create applicationset + ansible.builtin.template: + src: applicationset.j2 + dest: /var/lib/rancher/k3s/server/manifests/{{ _template.name }}-manifest.yaml + owner: root + group: root + mode: 0600 + vars: + _template: + name: argocd-applicationset-metacluster + namespace: argo-cd + notify: + - Apply manifests + - name: Trigger handlers ansible.builtin.meta: flush_handlers diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/k3s.yml b/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/k3s.yml index 2ffcff2..f4b0558 100644 --- a/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/k3s.yml +++ b/ansible/roles/firstboot/files/ansible_payload/roles/metacluster/tasks/k3s.yml @@ -15,8 +15,10 @@ ansible.builtin.uri: url: https://{{ vapp['guestinfo.ipaddress'] }}:6443/livez?verbose method: GET + validate_certs: no + status_code: [200, 401] register: api_readycheck - until: api_readycheck.json.apiVersion | default(false) | bool + until: api_readycheck.json.apiVersion is defined retries: 3 delay: 30 diff --git a/ansible/roles/firstboot/files/ansible_payload/templates/applicationset.j2 b/ansible/roles/firstboot/files/ansible_payload/templates/applicationset.j2 new file mode 100644 index 0000000..f4852d6 --- /dev/null +++ b/ansible/roles/firstboot/files/ansible_payload/templates/applicationset.j2 @@ -0,0 +1,28 @@ +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +metadata: + name: {{ _template.name }} + namespace: {{ _template.namespace }} +spec: + generators: + - git: + repoURL: https://git.{{ vapp['metacluster.fqdn'] }}/mc/ArgoCD.Config.git + revision: HEAD + directories: + - path: metacluster-applicationset/* + template: + metadata: + name: {% raw %}'{{ path.basename }}'{% endraw %} + spec: + project: default + syncPolicy: + automated: + prune: true + selfHeal: true + source: + repoURL: https://git.{{ vapp['metacluster.fqdn'] }}/mc/ArgoCD.Config.git + targetRevision: HEAD + path: {% raw %}'{{ path }}'{% endraw %} + destination: + server: https://{{ vapp['guestinfo.ipaddress'] }}:6443 + namespace: default diff --git a/ansible/vars/metacluster.yml b/ansible/vars/metacluster.yml index 74925f3..c8c26ae 100644 --- a/ansible/vars/metacluster.yml +++ b/ansible/vars/metacluster.yml @@ -112,7 +112,7 @@ components: gitea: helm: - version: v5.0.9 # (= Gitea v1.16.8) + version: v6.0.0 # (= Gitea v1.17.1) chart: gitea-charts/gitea parse_logic: helm template . | yq --no-doc eval '.. | .image? | select(.)' | sort -u | sed '/:/!s/$/:latest/' chart_values: !unsafe |