From 4ba1df5237e56f2d85f5e22043a5c49cf0915ccb Mon Sep 17 00:00:00 2001 From: pli Date: Mon, 20 Feb 2023 01:11:37 +0100 Subject: [PATCH] Fix kubernetes-app/argocd: download related things with the download role (#9786) * Fix yq install in argocd role: use download_file instead of get_url * Fix use download_file instead of get_url to download argocd-install manifest in argocd role * Fix order and add arm64 checksum * Fix: Failed to template loop_control.label: 'None' --- roles/download/defaults/main.yml | 25 +++++++++++ roles/kubernetes-apps/argocd/tasks/main.yml | 48 ++++++++++++++++----- 2 files changed, 63 insertions(+), 10 deletions(-) diff --git a/roles/download/defaults/main.yml b/roles/download/defaults/main.yml index 5b34a0305..29cfd3182 100644 --- a/roles/download/defaults/main.yml +++ b/roles/download/defaults/main.yml @@ -150,6 +150,8 @@ crio_supported_versions: v1.24: v1.24.3 crio_version: "{{ crio_supported_versions[kube_major_version] }}" +yq_version: "v4.30.6" + # Download URLs kubelet_download_url: "https://storage.googleapis.com/kubernetes-release/release/{{ kube_version }}/bin/linux/{{ image_arch }}/kubelet" kubectl_download_url: "https://storage.googleapis.com/kubernetes-release/release/{{ kube_version }}/bin/linux/{{ image_arch }}/kubectl" @@ -174,6 +176,7 @@ krew_download_url: "https://github.com/kubernetes-sigs/krew/releases/download/{{ containerd_download_url: "https://github.com/containerd/containerd/releases/download/v{{ containerd_version }}/containerd-{{ containerd_version }}-linux-{{ image_arch }}.tar.gz" cri_dockerd_download_url: "https://github.com/Mirantis/cri-dockerd/releases/download/v{{ cri_dockerd_version }}/cri-dockerd-{{ cri_dockerd_version }}.{{ image_arch }}.tgz" skopeo_download_url: "https://github.com/lework/skopeo-binary/releases/download/{{ skopeo_version }}/skopeo-linux-{{ image_arch }}" +yq_download_url: "https://github.com/mikefarah/yq/releases/download/{{ yq_version }}/yq_linux_{{ image_arch }}" crictl_checksums: arm: @@ -837,11 +840,20 @@ skopeo_binary_checksums: ppc64l3: v1.10.0: 0 +yq_checksums: + arm64: + v4.30.6: 40ee3000d5b65703caffb0263a7d5e75164f10afd2c9a3c879b6016f0300ac25 + v4.27.5: ea360a0ecdff30c8625ccd0b97f8714b8308a429fd839cf8ccc481f311e217c6 + amd64: + v4.30.6: 2aabdd748d301fc2286ea9f73eb20477b4ce173fbf072e0102fff1fcbed05985 + v4.27.5: 9a54846e81720ae22814941905cd3b056ebdffb76bf09acffa30f5e90b22d615 + etcd_binary_checksum: "{{ etcd_binary_checksums[image_arch][etcd_version] }}" cni_binary_checksum: "{{ cni_binary_checksums[image_arch][cni_version] }}" kubelet_binary_checksum: "{{ kubelet_checksums[image_arch][kube_version] }}" kubectl_binary_checksum: "{{ kubectl_checksums[image_arch][kube_version] }}" kubeadm_binary_checksum: "{{ kubeadm_checksums[image_arch][kubeadm_version] }}" +yq_binary_checksum: "{{ yq_checksums[image_arch][yq_version] }}" calicoctl_binary_checksum: "{{ calicoctl_binary_checksums[image_arch][calico_ctl_version] }}" calico_crds_archive_checksum: "{{ calico_crds_archive_checksums[calico_version] }}" ciliumcli_binary_checksum: "{{ ciliumcli_binary_checksums[image_arch][cilium_cli_version] }}" @@ -1806,6 +1818,19 @@ downloads: groups: - kube_control_plane + yq: + enabled: "{{ argocd_enabled }}" + file: true + version: "{{ yq_version }}" + dest: "{{ local_release_dir }}/yq" + sha256: "{{ yq_binary_checksum|default(None) }}" + url: "{{ yq_download_url }}" + unarchive: false + owner: "root" + mode: "0755" + groups: + - kube_control_plane + download_defaults: container: false file: false diff --git a/roles/kubernetes-apps/argocd/tasks/main.yml b/roles/kubernetes-apps/argocd/tasks/main.yml index a6a4450ad..709067b7f 100644 --- a/roles/kubernetes-apps/argocd/tasks/main.yml +++ b/roles/kubernetes-apps/argocd/tasks/main.yml @@ -1,10 +1,18 @@ --- -- name: Kubernetes Apps | Install yq - become: yes - get_url: - url: "https://github.com/mikefarah/yq/releases/download/v4.30.6/yq_linux_{{ host_architecture }}" +- name: Kubernetes Apps | Download yq + include_tasks: "../../../download/tasks/download_file.yml" + vars: + download: "{{ download_defaults | combine(downloads.yq) }}" + +- name: Kubernetes Apps | Copy yq binary from download dir + synchronize: + src: "{{ local_release_dir }}/yq" dest: "{{ bin_dir }}/yq" - mode: '0755' + compress: no + perms: yes + owner: no + group: no + delegate_to: "{{ inventory_hostname }}" - name: Kubernetes Apps | Set ArgoCD template list set_fact: @@ -19,17 +27,37 @@ - "inventory_hostname == groups['kube_control_plane'][0]" - name: Kubernetes Apps | Download ArgoCD remote manifests - become: yes - get_url: - url: "{{ item.url }}" - dest: "{{ kube_config_dir }}/{{ item.file }}" - mode: 0644 + include_tasks: "../../../download/tasks/download_file.yml" + vars: + download_argocd: + enabled: "{{ argocd_enabled }}" + file: true + dest: "{{ local_release_dir }}/{{ item.file }}" + url: "{{ item.url }}" + unarchive: false + owner: "root" + mode: 0644 + sha256: "" + download: "{{ download_defaults | combine(download_argocd) }}" with_items: "{{ argocd_templates | selectattr('url', 'defined') | list }}" loop_control: label: "{{ item.file }}" when: - "inventory_hostname == groups['kube_control_plane'][0]" +- name: Kubernetes Apps | Copy ArgoCD remote manifests from download dir + synchronize: + src: "{{ local_release_dir }}/{{ item.file }}" + dest: "{{ kube_config_dir }}/{{ item.file }}" + compress: no + perms: yes + owner: no + group: no + delegate_to: "{{ inventory_hostname }}" + with_items: "{{ argocd_templates | selectattr('url', 'defined') | list }}" + when: + - "inventory_hostname == groups['kube_control_plane'][0]" + - name: Kubernetes Apps | Set ArgoCD namespace for remote manifests become: yes command: |