Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle multiple architectures when distributing airgap binary #367

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
ansible.builtin.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:
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
Loading