From 7233161d560a247ba796ecb5609d331e22aa05ce Mon Sep 17 00:00:00 2001 From: Derek Nola Date: Mon, 7 Oct 2024 11:40:58 -0700 Subject: [PATCH] Handle multiple architectures when distributing airgap binary Signed-off-by: Derek Nola --- roles/airgap/tasks/main.yml | 56 ++++++++++--------------------------- 1 file changed, 14 insertions(+), 42 deletions(-) diff --git a/roles/airgap/tasks/main.yml b/roles/airgap/tasks/main.yml index 752bd486f..6a8b21222 100644 --- a/roles/airgap/tasks/main.yml +++ b/roles/airgap/tasks/main.yml @@ -25,13 +25,21 @@ group: root mode: "0755" - - name: Distribute K3s binary + - name: Determine architecture and set k3s_arch + set_fact: + k3s_arch: "{{ 'arm64' if ansible_architecture == 'aarch64' else 'arm' if ansible_architecture == 'armv7l' else 'amd64' }}" + + - name: Distribute K3s binary {{ k3s_arch }} ansible.builtin.copy: - src: "{{ airgap_dir }}/k3s" + src: "{{ item }}" dest: /usr/local/bin/k3s owner: root group: root mode: "0755" + with_first_found: + - files: + - "{{ airgap_dir }}/k3s-{{ k3s_arch }}" + - "{{ airgap_dir }}/k3s" - name: Distribute K3s SELinux RPM ansible.builtin.copy: @@ -60,42 +68,7 @@ mode: "0755" state: directory - - name: Determine Architecture - ansible.builtin.set_fact: - k3s_arch: "{{ ansible_architecture }}" - - - name: Distribute K3s amd64 images - when: ansible_architecture == 'x86_64' - ansible.builtin.copy: - src: "{{ item }}" - dest: /var/lib/rancher/k3s/agent/images/{{ item | basename }} - owner: root - group: root - mode: "0755" - with_first_found: - - files: - - "{{ airgap_dir }}/k3s-airgap-images-amd64.tar.zst" - - "{{ airgap_dir }}/k3s-airgap-images-amd64.tar.gz" - - "{{ airgap_dir }}/k3s-airgap-images-amd64.tar" - skip: true - - - name: Distribute K3s arm64 images - when: ansible_architecture == 'aarch64' - ansible.builtin.copy: - src: "{{ item }}" - dest: /var/lib/rancher/k3s/agent/images/{{ item | basename }} - owner: root - group: root - mode: "0755" - with_first_found: - - files: - - "{{ airgap_dir }}/k3s-airgap-images-arm64.tar.zst" - - "{{ airgap_dir }}/k3s-airgap-images-arm64.tar.gz" - - "{{ airgap_dir }}/k3s-airgap-images-arm64.tar" - skip: true - - - name: Distribute K3s arm images - when: ansible_architecture == 'armv7l' + - name: Distribute K3s images {{ k3s_arch }} ansible.builtin.copy: src: "{{ item }}" dest: /var/lib/rancher/k3s/agent/images/{{ item | basename }} @@ -104,10 +77,9 @@ mode: "0755" with_first_found: - files: - - "{{ airgap_dir }}/k3s-airgap-images-arm.tar.zst" - - "{{ airgap_dir }}/k3s-airgap-images-arm.tar.gz" - - "{{ airgap_dir }}/k3s-airgap-images-arm.tar" - skip: true + - "{{ airgap_dir }}/k3s-airgap-images-{{ k3s_arch }}.tar.zst" + - "{{ airgap_dir }}/k3s-airgap-images-{{ k3s_arch }}.tar.gz" + - "{{ airgap_dir }}/k3s-airgap-images-{{ k3s_arch }}.tar" - name: Run K3s Install [server] ansible.builtin.command: