Compare commits
4 Commits
6c14e5d923
...
485ee0f285
Author | SHA1 | Date |
---|---|---|
dreamingdeer | 485ee0f285 | |
Mykyta Orlov | 5dd8c3f5a3 | |
Jose Luis Pedrosa | 91405dc517 | |
Vivek Sarin | c84c1ce5b1 |
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -4,3 +4,4 @@ systemd_dir: "/etc/systemd/system"
|
|||
api_port: 6443
|
||||
kubeconfig: ~/.kube/config.new
|
||||
user_kubectl: true
|
||||
cluster_context: k3s-ansible
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue