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

Update minimum ansible version requirements to avoid airgap error #258

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on processor architectures:

## System requirements

The control node must have Ansible 2.10.0+
The control node **must** have Ansible 5.0+ (ansible-core 2.12.0+)

All managed nodes in inventory must have:
- Passwordless SSH access
Expand Down
4 changes: 4 additions & 0 deletions playbook/reset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
ansible.builtin.file:
path: /home/{{ ansible_user }}/.kube/config
state: absent
- name: Remove k3s install script
ansible.builtin.file:
path: /usr/local/bin/k3s-install.sh
state: absent
30 changes: 18 additions & 12 deletions roles/airgap/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,37 @@
- name: Check for Airgap
when: airgap_dir is defined
block:
- name: Download k3s install script [Airgap]

- 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
delegate_to: localhost
ansible.builtin.get_url:
url: https://get.k3s.io/
timeout: 120
dest: "{{ airgap_dir }}/k3s-install.sh"
mode: 0755

- name: Distribute K3s install script [Airgap]
- name: Distribute K3s install script
ansible.builtin.copy:
src: "{{ airgap_dir }}/k3s-install.sh"
dest: /usr/local/bin/k3s-install.sh
owner: root
group: root
mode: 0755

- name: Distribute K3s binary [Airgap]
- name: Distribute K3s binary
ansible.builtin.copy:
src: "{{ airgap_dir }}/k3s"
dest: /usr/local/bin/k3s
owner: root
group: root
mode: 0755

- name: Distribute K3s SELinux RPM [Airgap]
- name: Distribute K3s SELinux RPM
ansible.builtin.copy:
src: "{{ item }}"
dest: /tmp/
Expand All @@ -38,7 +44,7 @@
register: selinux_copy
ignore_errors: true

- name: Install K3s SELinux RPM [Airgap]
- name: Install K3s SELinux RPM
when:
- ansible_os_family == 'RedHat'
- selinux_copy.skipped is false
Expand All @@ -47,17 +53,17 @@
state: present
disable_gpg_check: true

- name: Make images directory [Airgap]
- name: Make images directory
ansible.builtin.file:
path: "/var/lib/rancher/k3s/agent/images/"
mode: 0755
state: directory

- name: Determine Architecture [Airgap]
- name: Determine Architecture
ansible.builtin.set_fact:
k3s_arch: "{{ ansible_architecture }}"

- name: Distribute K3s amd64 images [Airgap]
- name: Distribute K3s amd64 images
when: ansible_architecture == 'x86_64'
ansible.builtin.copy:
src: "{{ item }}"
Expand All @@ -72,7 +78,7 @@
- "{{ airgap_dir }}/k3s-airgap-images-amd64.tar"
skip: true

- name: Distribute K3s arm64 images [Airgap]
- name: Distribute K3s arm64 images
when: ansible_architecture == 'aarch64'
ansible.builtin.copy:
src: "{{ item }}"
Expand All @@ -87,7 +93,7 @@
- "{{ airgap_dir }}/k3s-airgap-images-arm64.tar"
skip: true

- name: Distribute K3s arm images [Airgap]
- name: Distribute K3s arm images
when: ansible_architecture == 'armv7l'
ansible.builtin.copy:
src: "{{ item }}"
Expand All @@ -102,15 +108,15 @@
- "{{ airgap_dir }}/k3s-airgap-images-arm.tar"
skip: true

- name: Run K3s Install [server][Airgap]
- name: Run K3s Install [server]
ansible.builtin.command:
cmd: /usr/local/bin/k3s-install.sh
environment:
INSTALL_K3S_SKIP_START: "true"
INSTALL_K3S_SKIP_DOWNLOAD: "true"
changed_when: true

- name: Run K3s Install [agent][Airgap]
- name: Run K3s Install [agent]
ansible.builtin.command:
cmd: /usr/local/bin/k3s-install.sh
environment:
Expand Down
Loading