From 336150b00c4ae3d903a22fb221d27718dd13ffd6 Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Fri, 13 Jan 2023 09:03:35 +0100 Subject: [PATCH] Fix typo;Fix module;Register workloadcluster in argocd #2;Reduce tty refresh frequency;Upgrade component --- .../workloadcluster/tasks/clusterapi.yml | 2 +- .../roles/workloadcluster/tasks/gitops.yml | 29 ++++++++++++------- .../ansible_payload/templates/cluster.j2 | 18 ++++++++++++ .../files/ansible_payload/templates/tty.j2 | 4 +-- ansible/vars/metacluster.yml | 4 +-- 5 files changed, 42 insertions(+), 15 deletions(-) create mode 100644 ansible/roles/firstboot/files/ansible_payload/templates/cluster.j2 diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/clusterapi.yml b/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/clusterapi.yml index 032bc34..f8ccbf3 100644 --- a/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/clusterapi.yml +++ b/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/clusterapi.yml @@ -111,7 +111,7 @@ register: capi_kubeconfig - name: Retrieve kubeconfig - ansible.builtin.command: + ansible.builtin.shell: cmd: >- clusterctl get kubeconfig \ {{ vapp['workloadcluster.name'] | lower }} \ diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/gitops.yml b/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/gitops.yml index 770fb0b..2b8bb98 100644 --- a/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/gitops.yml +++ b/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/gitops.yml @@ -4,7 +4,13 @@ kubernetes.core.k8s: template: serviceaccount.j2 state: present - kubeconfig: "{{ capi_kubeconfig.path }}" + vars: + _template: + account: + name: argocd-sa + namespace: default + clusterrolebinding: + name: argocd-crb - name: Retrieve service account bearer token kubernetes.core.k8s_info: @@ -20,16 +26,19 @@ namespace: "{{ _template.account.namespace }}" register: workloadcluster_bearertoken - - debug: - msg: "{{ workloadcluster_bearertoken.resources | json_query('[].data.token') }}" + - name: Register workload cluster in argo-cd + kubernetes.core.k8s: + template: cluster.j2 + state: present + kubeconfig: "{{ kubeconfig.path }}" + vars: + _template: + cluster: + name: "{{ vapp['workloadcluster.name'] | lower }}" + secret: argocd-cluster-{{ vapp['workloadcluster.name'] | lower }} + url: https://{{ vapp['workloadcluster.vip'] }}:6443 + token: "{{ workloadcluster_bearertoken.resources | json_query('[].data.token') }}" - vars: - _template: - account: - name: argocd-sa - namespace: default - clusterrolebinding: - name: argocd-crb module_defaults: group/k8s: kubeconfig: "{{ capi_kubeconfig.path }}" diff --git a/ansible/roles/firstboot/files/ansible_payload/templates/cluster.j2 b/ansible/roles/firstboot/files/ansible_payload/templates/cluster.j2 new file mode 100644 index 0000000..bbaec5c --- /dev/null +++ b/ansible/roles/firstboot/files/ansible_payload/templates/cluster.j2 @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ _template.cluster.secret }} + namespace: argo-cd + labels: + argocd.argoproj.io/secret-type: cluster +type: Opaque +stringData: + name: {{ _template.cluster.name }} + server: {{ _template.cluster.url }} + config: | + { + "bearerToken": "{{ _template.cluster.token }}", + "tlsClientConfig": { + "insecure": true + } + } diff --git a/ansible/roles/firstboot/files/ansible_payload/templates/tty.j2 b/ansible/roles/firstboot/files/ansible_payload/templates/tty.j2 index b67e01e..913403b 100644 --- a/ansible/roles/firstboot/files/ansible_payload/templates/tty.j2 +++ b/ansible/roles/firstboot/files/ansible_payload/templates/tty.j2 @@ -17,10 +17,10 @@ COMPONENTS=('ca' 'storage' 'registry' 'git' 'gitops') FQDN='{{ vapp['metacluster.fqdn'] }}' IPADDRESS='{{ vapp['guestinfo.ipaddress'] }}' -I=10 +I=60 while /bin/true; do - if [[ $I -lt 9 ]]; then + if [[ $I -gt 59 ]]; then clear > /dev/tty1 I=0 else diff --git a/ansible/vars/metacluster.yml b/ansible/vars/metacluster.yml index 3150f97..aac2881 100644 --- a/ansible/vars/metacluster.yml +++ b/ansible/vars/metacluster.yml @@ -79,7 +79,7 @@ components: management: version: # Must match the version referenced at `dependencies.static_binaries[.filename==clusterctl].url` - base: v1.3.1 + base: v1.3.2 # Must match the version referenced at `components.cert-manager.helm.version` cert_manager: v1.10.1 infrastructure_vsphere: v1.5.1 @@ -215,7 +215,7 @@ dependencies: static_binaries: - filename: clusterctl - url: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.3.1/clusterctl-linux-amd64 + url: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.3.2/clusterctl-linux-amd64 - filename: govc url: https://github.com/vmware/govmomi/releases/download/v0.29.0/govc_Linux_x86_64.tar.gz archive: compressed