This commit is contained in:
2026-02-23 21:38:58 +01:00
parent 05d7f3316b
commit 0eb5c15d2b

View File

@@ -49,39 +49,66 @@
- ca-certificates - ca-certificates
- curl - curl
- gpg - gpg
- curl
- gnupg2
- software-properties-common
state: present state: present
- name: Add Kubernetes apt key - name: Add Docker GPG key for containerd
shell: | ansible.builtin.apt_key:
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key | \ url: https://download.docker.com/linux/ubuntu/gpg
gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg keyring: /etc/apt/trusted.gpg.d/containerd.gpg
args: state: present
creates: /etc/apt/keyrings/kubernetes-apt-keyring.gpg
- name: Add Docker repository
ansible.builtin.apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable"
state: present
- name: Install required packages
apt:
name:
- containerd.io
state: present
update_cache: yes
- name: Generate default containerd config
command: containerd config default
register: containerd_config
- name: Save containerd configuration
copy:
dest: /etc/containerd/config.toml
content: "{{ containerd_config.stdout }}"
owner: root
group: root
mode: 0644
- name: Enable SystemdCgroup in containerd config
replace:
path: /etc/containerd/config.toml
regexp: 'SystemdCgroup\s*=\s*false'
replace: 'SystemdCgroup = true'
- name: Restart containerd
systemd:
name: containerd
state: restarted
enabled: yes
- name: Add Kubernetes GPG key
ansible.builtin.apt_key:
url: https://pkgs.k8s.io/core:/stable:/v1.34/deb/Release.key
keyring: /etc/apt/keyrings/k8s.gpg
state: present
- name: Add Kubernetes repository - name: Add Kubernetes repository
copy: copy:
dest: /etc/apt/sources.list.d/kubernetes.list dest: /etc/apt/sources.list.d/k8s.list
content: | content: 'deb [signed-by=/etc/apt/keyrings/k8s.gpg] https://pkgs.k8s.io/core:/stable:/v1.34/deb/ /'
deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ / owner: root
group: root
- name: Install containerd mode: 0644
apt:
name: containerd
state: present
- name: Configure containerd
shell: |
mkdir -p /etc/containerd
containerd config default > /etc/containerd/config.toml
sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml
args:
creates: /etc/containerd/config.toml
- name: Enable and start containerd
systemd:
name: containerd
enabled: yes
state: started
- name: Install Kubernetes packages - name: Install Kubernetes packages
apt: apt:
@@ -91,6 +118,7 @@
- kubectl - kubectl
state: present state: present
update_cache: yes update_cache: yes
register: k8s_install register: k8s_install
retries: 5 retries: 5
delay: 10 delay: 10