Fixed Errors from wrong version
This commit is contained in:
@@ -4,8 +4,8 @@ ansible_user: mastermito
|
|||||||
# ansible-vault encrypt_string 'your_password' --name 'vault_ssh_password'
|
# ansible-vault encrypt_string 'your_password' --name 'vault_ssh_password'
|
||||||
# then put the result here.
|
# then put the result here.
|
||||||
# For now, we expect these variables to be defined, e.g. in a vault file or extra vars.
|
# For now, we expect these variables to be defined, e.g. in a vault file or extra vars.
|
||||||
# ansible_password: "{{ vault_ssh_password }}"
|
ansible_password: "{{ vault_ssh_password }}"
|
||||||
# ansible_become_password: "{{ vault_become_password }}"
|
ansible_become_password: "{{ vault_ssh_password }}"
|
||||||
|
|
||||||
# Kubernetes Version
|
# Kubernetes Version
|
||||||
k8s_version: "1.28.0-00"
|
k8s_version: "1.28.0-00"
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
---
|
---
|
||||||
|
- name: Wait for APT lock
|
||||||
|
shell: |
|
||||||
|
while fuser /var/lib/dpkg/lock-frontend >/dev/null 2>&1; do
|
||||||
|
echo "Waiting for other software managers to finish..."
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
register: apt_lock_wait
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
- name: Update apt cache
|
- name: Update apt cache
|
||||||
apt:
|
apt:
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
@@ -8,6 +17,26 @@
|
|||||||
apt:
|
apt:
|
||||||
upgrade: dist
|
upgrade: dist
|
||||||
|
|
||||||
|
- name: Check if cloud-init exists
|
||||||
|
stat:
|
||||||
|
path: /etc/cloud/cloud.cfg
|
||||||
|
register: cloud_init_cfg
|
||||||
|
|
||||||
|
- name: Prevent cloud-init from changing hostname
|
||||||
|
copy:
|
||||||
|
dest: /etc/cloud/cloud.cfg.d/99-preserve-hostname.cfg
|
||||||
|
content: "preserve_hostname: true"
|
||||||
|
when: cloud_init_cfg.stat.exists
|
||||||
|
|
||||||
|
- name: Set hostname
|
||||||
|
command: "hostnamectl set-hostname {{ inventory_hostname }}"
|
||||||
|
|
||||||
|
- name: Update /etc/hosts with inventory hostname
|
||||||
|
lineinfile:
|
||||||
|
path: /etc/hosts
|
||||||
|
regexp: '^127\.0\.1\.1'
|
||||||
|
line: "127.0.1.1 {{ inventory_hostname }}"
|
||||||
|
|
||||||
- name: Install required system packages
|
- name: Install required system packages
|
||||||
apt:
|
apt:
|
||||||
name:
|
name:
|
||||||
@@ -22,16 +51,32 @@
|
|||||||
command: swapoff -a
|
command: swapoff -a
|
||||||
when: ansible_swaptotal_mb > 0
|
when: ansible_swaptotal_mb > 0
|
||||||
|
|
||||||
- name: Disable swap in dphys-swapfile
|
- name: Disable swap in /etc/fstab
|
||||||
lineinfile:
|
replace:
|
||||||
path: /etc/dphys-swapfile
|
path: /etc/fstab
|
||||||
regexp: '^CONF_SWAPSIZE='
|
regexp: '^([^#].*?\sswap\s+.*)$'
|
||||||
line: 'CONF_SWAPSIZE=0'
|
replace: '# \1'
|
||||||
notify: restart kubelet
|
|
||||||
|
- name: Stop and disable dphys-swapfile service (if exists)
|
||||||
|
service:
|
||||||
|
name: dphys-swapfile
|
||||||
|
state: stopped
|
||||||
|
enabled: no
|
||||||
|
failed_when: false
|
||||||
|
when: ansible_distribution == 'Raspbian'
|
||||||
|
|
||||||
|
- name: Determine cmdline.txt location
|
||||||
|
stat:
|
||||||
|
path: /boot/firmware/cmdline.txt
|
||||||
|
register: cmdline_firmware
|
||||||
|
|
||||||
|
- name: Set cmdline path
|
||||||
|
set_fact:
|
||||||
|
cmdline_path: "{{ '/boot/firmware/cmdline.txt' if cmdline_firmware.stat.exists else '/boot/cmdline.txt' }}"
|
||||||
|
|
||||||
- name: Enable cgroup features in cmdline.txt
|
- name: Enable cgroup features in cmdline.txt
|
||||||
replace:
|
replace:
|
||||||
path: /boot/cmdline.txt
|
path: "{{ cmdline_path }}"
|
||||||
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1\b).*)$'
|
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1\b).*)$'
|
||||||
replace: '\1 cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1'
|
replace: '\1 cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1'
|
||||||
register: cgroup_update
|
register: cgroup_update
|
||||||
@@ -100,13 +145,13 @@
|
|||||||
|
|
||||||
- name: Download Kubernetes GPG key
|
- name: Download Kubernetes GPG key
|
||||||
get_url:
|
get_url:
|
||||||
url: https://pkgs.k8s.io/core:/stable:/v1.35/deb/Release.key
|
url: "https://pkgs.k8s.io/core:/stable:/v{{ k8s_version | regex_search('^[0-9]+\\.[0-9]+') }}/deb/Release.key"
|
||||||
dest: /etc/apt/keyrings/kubernetes-apt-keyring.asc
|
dest: /etc/apt/keyrings/kubernetes-apt-keyring.asc
|
||||||
mode: '0644'
|
mode: '0644'
|
||||||
|
|
||||||
- name: Add Kubernetes apt repository
|
- name: Add Kubernetes apt repository
|
||||||
apt_repository:
|
apt_repository:
|
||||||
repo: "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.asc] https://pkgs.k8s.io/core:/stable:/v1.35/deb/ /"
|
repo: "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.asc] https://pkgs.k8s.io/core:/stable:/v{{ k8s_version | regex_search('^[0-9]+\\.[0-9]+') }}/deb/ /"
|
||||||
state: present
|
state: present
|
||||||
filename: kubernetes
|
filename: kubernetes
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
---
|
---
|
||||||
|
- name: Pre-pull Kubernetes images
|
||||||
|
command: kubeadm config images pull
|
||||||
|
|
||||||
- name: Initialize Kubernetes Control Plane
|
- name: Initialize Kubernetes Control Plane
|
||||||
command: kubeadm init --pod-network-cidr=10.244.0.0/16
|
command: kubeadm init --pod-network-cidr=10.244.0.0/16
|
||||||
args:
|
args:
|
||||||
|
|||||||
Reference in New Issue
Block a user