polish validation and project structure

This commit is contained in:
Bartal Læarsson
2025-02-28 11:32:10 +00:00
parent 20d1964db3
commit 24d9859b2d
5 changed files with 219 additions and 129 deletions
+5 -77
View File
@@ -1,5 +1,5 @@
---
# tasks/node-setup.yml
# tasks/kubernetes/node-setup.yml
- name: Update apt cache
apt:
update_cache: yes
@@ -13,83 +13,11 @@
- gnupg
state: present
# Add Docker GPG key
- name: Add Docker GPG key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker repository
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
state: present
filename: docker
- name: Install containerd from Docker repository
apt:
name: containerd.io
state: present
update_cache: yes
- name: Create containerd directory
file:
path: /etc/containerd
state: directory
mode: '0755'
- name: Check if containerd config command works
command: which containerd
register: containerd_check
changed_when: false
failed_when: false
- name: Generate default containerd config (if containerd exists)
command: containerd config default
register: containerd_config
changed_when: false
when: containerd_check.rc == 0
- name: Create a basic containerd config (if command failed)
copy:
content: |
version = 2
[plugins]
[plugins."io.containerd.grpc.v1.cri"]
[plugins."io.containerd.grpc.v1.cri".containerd]
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes]
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
runtime_type = "io.containerd.runc.v2"
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true
dest: /etc/containerd/config.toml
owner: root
group: root
mode: '0644'
when: containerd_check.rc != 0
- name: Write containerd config from generated output
copy:
content: "{{ containerd_config.stdout }}"
dest: /etc/containerd/config.toml
owner: root
group: root
mode: '0644'
when: containerd_check.rc == 0 and containerd_config.stdout is defined and containerd_config.stdout != ""
- name: Enable SystemdCgroup in containerd config
replace:
path: /etc/containerd/config.toml
regexp: 'SystemdCgroup = false'
replace: 'SystemdCgroup = true'
when: containerd_check.rc == 0
- name: Restart containerd
systemd:
name: containerd
state: restarted
enabled: yes
# Install containerd directly from GitHub release
- name: Install containerd directly from release
include_tasks: install-containerd.yml
# Continue with Kubernetes repository setup and installation
- name: Get latest Kubernetes version
shell: curl -L -s https://dl.k8s.io/release/stable.txt | awk 'BEGIN { FS="." } { printf "%s.%s", $1, $2 }'
register: kube_latest