Skip to content

Commit

Permalink
Handle multiple architectures when distributing airgap binary
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Nola <[email protected]>
  • Loading branch information
dereknola committed Oct 7, 2024
1 parent 040d378 commit 7233161
Showing 1 changed file with 14 additions and 42 deletions.
56 changes: 14 additions & 42 deletions roles/airgap/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}"

Check failure on line 31 in roles/airgap/tasks/main.yml

View workflow job for this annotation

GitHub Actions / Lint

31:1 [trailing-spaces] trailing spaces
- 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:
Expand Down Expand Up @@ -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 }}
Expand All @@ -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:
Expand Down

0 comments on commit 7233161

Please sign in to comment.