2019-04-26 21:10:27 +02:00
|
|
|
---
|
2023-11-14 23:36:15 +01:00
|
|
|
- name: Check for Airgap
|
|
|
|
when: airgap_dir is defined
|
|
|
|
block:
|
2023-11-30 21:32:19 +01:00
|
|
|
|
|
|
|
- name: Verify Ansible meets airgap version requirements.
|
|
|
|
ansible.builtin.assert:
|
|
|
|
that: "ansible_version.full is version_compare('2.12', '>=')"
|
|
|
|
msg: "The Airgap role requires at least ansible-core 2.12"
|
|
|
|
|
|
|
|
- name: Download k3s install script
|
2024-04-01 20:31:44 +02:00
|
|
|
become: false
|
2023-11-14 23:36:15 +01:00
|
|
|
delegate_to: localhost
|
|
|
|
ansible.builtin.get_url:
|
|
|
|
url: https://get.k3s.io/
|
|
|
|
timeout: 120
|
|
|
|
dest: "{{ airgap_dir }}/k3s-install.sh"
|
|
|
|
mode: 0755
|
|
|
|
|
2023-11-30 21:32:19 +01:00
|
|
|
- name: Distribute K3s install script
|
2023-11-14 23:36:15 +01:00
|
|
|
ansible.builtin.copy:
|
|
|
|
src: "{{ airgap_dir }}/k3s-install.sh"
|
|
|
|
dest: /usr/local/bin/k3s-install.sh
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0755
|
|
|
|
|
2023-11-30 21:32:19 +01:00
|
|
|
- name: Distribute K3s binary
|
2023-11-14 23:36:15 +01:00
|
|
|
ansible.builtin.copy:
|
|
|
|
src: "{{ airgap_dir }}/k3s"
|
|
|
|
dest: /usr/local/bin/k3s
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0755
|
|
|
|
|
2023-11-30 21:32:19 +01:00
|
|
|
- name: Distribute K3s SELinux RPM
|
2023-11-14 23:36:15 +01:00
|
|
|
ansible.builtin.copy:
|
|
|
|
src: "{{ item }}"
|
|
|
|
dest: /tmp/
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0755
|
|
|
|
with_fileglob:
|
|
|
|
- "{{ airgap_dir }}/k3s-selinux*.rpm"
|
|
|
|
register: selinux_copy
|
|
|
|
ignore_errors: true
|
|
|
|
|
2023-11-30 21:32:19 +01:00
|
|
|
- name: Install K3s SELinux RPM
|
2023-11-14 23:36:15 +01:00
|
|
|
when:
|
|
|
|
- ansible_os_family == 'RedHat'
|
|
|
|
- selinux_copy.skipped is false
|
|
|
|
ansible.builtin.yum:
|
|
|
|
name: "{{ selinux_copy.results[0].dest }}"
|
|
|
|
state: present
|
|
|
|
disable_gpg_check: true
|
|
|
|
|
2023-11-30 21:32:19 +01:00
|
|
|
- name: Make images directory
|
2023-11-14 23:36:15 +01:00
|
|
|
ansible.builtin.file:
|
|
|
|
path: "/var/lib/rancher/k3s/agent/images/"
|
|
|
|
mode: 0755
|
|
|
|
state: directory
|
|
|
|
|
2023-11-30 21:32:19 +01:00
|
|
|
- name: Determine Architecture
|
2023-11-14 23:36:15 +01:00
|
|
|
ansible.builtin.set_fact:
|
|
|
|
k3s_arch: "{{ ansible_architecture }}"
|
|
|
|
|
2023-11-30 21:32:19 +01:00
|
|
|
- name: Distribute K3s amd64 images
|
2023-11-14 23:36:15 +01:00
|
|
|
when: ansible_architecture == 'x86_64'
|
|
|
|
ansible.builtin.copy:
|
|
|
|
src: "{{ item }}"
|
2024-04-01 20:31:44 +02:00
|
|
|
dest: /var/lib/rancher/k3s/agent/images/{{ item | basename }}
|
2023-11-14 23:36:15 +01:00
|
|
|
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
|
|
|
|
|
2023-11-30 21:32:19 +01:00
|
|
|
- name: Distribute K3s arm64 images
|
2023-11-14 23:36:15 +01:00
|
|
|
when: ansible_architecture == 'aarch64'
|
|
|
|
ansible.builtin.copy:
|
|
|
|
src: "{{ item }}"
|
2024-04-01 20:31:44 +02:00
|
|
|
dest: /var/lib/rancher/k3s/agent/images/{{ item | basename }}
|
2023-11-14 23:36:15 +01:00
|
|
|
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
|
|
|
|
|
2023-11-30 21:32:19 +01:00
|
|
|
- name: Distribute K3s arm images
|
2023-11-14 23:36:15 +01:00
|
|
|
when: ansible_architecture == 'armv7l'
|
|
|
|
ansible.builtin.copy:
|
|
|
|
src: "{{ item }}"
|
2024-04-01 20:31:44 +02:00
|
|
|
dest: /var/lib/rancher/k3s/agent/images/{{ item | basename }}
|
2023-11-14 23:36:15 +01:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
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
|
|
|
|
|
2023-11-30 21:32:19 +01:00
|
|
|
- name: Run K3s Install [server]
|
2023-11-14 23:36:15 +01:00
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: /usr/local/bin/k3s-install.sh
|
|
|
|
environment:
|
|
|
|
INSTALL_K3S_SKIP_START: "true"
|
|
|
|
INSTALL_K3S_SKIP_DOWNLOAD: "true"
|
|
|
|
changed_when: true
|
|
|
|
|
2023-11-30 21:32:19 +01:00
|
|
|
- name: Run K3s Install [agent]
|
2023-11-14 23:36:15 +01:00
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: /usr/local/bin/k3s-install.sh
|
|
|
|
environment:
|
|
|
|
INSTALL_K3S_SKIP_START: "true"
|
|
|
|
INSTALL_K3S_SKIP_DOWNLOAD: "true"
|
|
|
|
INSTALL_K3S_EXEC: "agent"
|
|
|
|
changed_when: true
|