Compare commits

...

4 Commits

Author SHA1 Message Date
dreamingdeer 485ee0f285
fix keep extension on uploaded file on airgap install (#311)
* fix keep extension on uploaded file on airgap install
* fix other tasks distribute K3s images

Signed-off-by: dreamingdeer <dreamingdeer@yandex.ru>
Co-authored-by: dreamingdeer <dreamingdeer@yandex.ru>
2024-04-01 11:31:44 -07:00
Mykyta Orlov 5dd8c3f5a3
Fix typo in main.yml (#317)
Signed-off-by: Mykyta Orlov <orlovmyk@gmail.com>
2024-04-01 11:15:20 -07:00
Jose Luis Pedrosa 91405dc517
fix: skip cgroups when cmdline.txt is not present (#320)
Signed-off-by: Jose Luis Pedrosa <jlpedrosa@gmail.com>
2024-04-01 11:08:05 -07:00
Vivek Sarin c84c1ce5b1
Added custom context name (#315)
* Added custom context name

Signed-off-by: Vivek Sarin <vivek@sarin.info>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Co-authored-by: Vivek Sarin <vivek@sarin.info>
Co-authored-by: Derek Nola <derek.nola@suse.com>
2024-04-01 09:35:55 -07:00
6 changed files with 12 additions and 9 deletions

View File

@ -20,6 +20,7 @@ k3s_cluster:
extra_agent_args: ""
# Optional vars
# cluster_context: k3s-ansible
# api_port: 6443
# k3s_server_location: /var/lib/rancher/k3s
# systemd_dir: /etc/systemd/system

View File

@ -9,6 +9,7 @@
msg: "The Airgap role requires at least ansible-core 2.12"
- name: Download k3s install script
become: false
delegate_to: localhost
ansible.builtin.get_url:
url: https://get.k3s.io/
@ -67,7 +68,7 @@
when: ansible_architecture == 'x86_64'
ansible.builtin.copy:
src: "{{ item }}"
dest: /var/lib/rancher/k3s/agent/images/k3s-airgap-images-amd64.tar
dest: /var/lib/rancher/k3s/agent/images/{{ item | basename }}
owner: root
group: root
mode: 0755
@ -82,7 +83,7 @@
when: ansible_architecture == 'aarch64'
ansible.builtin.copy:
src: "{{ item }}"
dest: /var/lib/rancher/k3s/agent/images/k3s-airgap-images-arm64.tar
dest: /var/lib/rancher/k3s/agent/images/{{ item | basename }}
owner: root
group: root
mode: 0755
@ -97,7 +98,7 @@
when: ansible_architecture == 'armv7l'
ansible.builtin.copy:
src: "{{ item }}"
dest: /var/lib/rancher/k3s/agent/images/k3s-airgap-images-arm.tar
dest: /var/lib/rancher/k3s/agent/images/{{ item | basename }}
owner: root
group: root
mode: 0755

View File

@ -14,7 +14,7 @@
# We should be downloading and installing the newer version only if we are in one of the following cases :
# - we couldn't get k3s installed version in the first task of this role
# - the installed version of K3s on the nodes is older than the requested version in ansible vars
- name: Download artefact only if needed
- name: Download artifact only if needed
when: k3s_version_output.rc != 0 or installed_k3s_version is version(k3s_version, '<') and airgap_dir is undefined
block:
- name: Download K3s install script

View File

@ -4,3 +4,4 @@ systemd_dir: "/etc/systemd/system"
api_port: 6443
kubeconfig: ~/.kube/config.new
user_kubectl: true
cluster_context: k3s-ansible

View File

@ -14,7 +14,7 @@
# We should be downloading and installing the newer version only if we are in one of the following cases :
# - we couldn't get k3s installed version in the first task of this role
# - the installed version of K3s on the nodes is older than the requested version in ansible vars
- name: Download artefact only if needed
- name: Download artifact only if needed
when: k3s_version_output.rc != 0 or installed_k3s_version is version(k3s_version, '<') and airgap_dir is undefined
block:
- name: Download K3s install script
@ -120,12 +120,12 @@
changed_when:
- csa_result.rc == 0
- name: Setup kubeconfig k3s-ansible context on control node
- name: Setup kubeconfig context on control node - {{ cluster_context }}
when: kubeconfig != "~/.kube/config"
ansible.builtin.replace:
path: "{{ kubeconfig }}"
regexp: 'name: default'
replace: 'name: k3s-ansible'
replace: 'name: {{ cluster_context }}'
delegate_to: 127.0.0.1
become: false
@ -133,7 +133,7 @@
when: kubeconfig != "~/.kube/config"
ansible.builtin.shell: |
TFILE=$(mktemp)
KUBECONFIG={{ kubeconfig }} kubectl config set-context k3s-ansible --user=k3s-ansible --cluster=k3s-ansible
KUBECONFIG={{ kubeconfig }} kubectl config set-context {{ cluster_context }} --user={{ cluster_context }} --cluster={{ cluster_context }}
KUBECONFIG={{ kubeconfig }} kubectl config view --flatten > ${TFILE}
mv ${TFILE} {{ kubeconfig }}
delegate_to: 127.0.0.1

View File

@ -1,6 +1,6 @@
---
- name: Enable cgroup via boot commandline if not already enabled
when: lookup('fileglob', '/boot/firmware/cmdline.txt', errors='warn') | length == 0
when: lookup('fileglob', '/boot/firmware/cmdline.txt', errors='warn') | length > 0
ansible.builtin.lineinfile:
path: /boot/firmware/cmdline.txt
backrefs: true