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'
|
||||
# then put the result here.
|
||||
# For now, we expect these variables to be defined, e.g. in a vault file or extra vars.
|
||||
# ansible_password: "{{ vault_ssh_password }}"
|
||||
# ansible_become_password: "{{ vault_become_password }}"
|
||||
ansible_password: "{{ vault_ssh_password }}"
|
||||
ansible_become_password: "{{ vault_ssh_password }}"
|
||||
|
||||
# Kubernetes Version
|
||||
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
|
||||
apt:
|
||||
update_cache: yes
|
||||
@@ -8,6 +17,26 @@
|
||||
apt:
|
||||
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
|
||||
apt:
|
||||
name:
|
||||
@@ -22,16 +51,32 @@
|
||||
command: swapoff -a
|
||||
when: ansible_swaptotal_mb > 0
|
||||
|
||||
- name: Disable swap in dphys-swapfile
|
||||
lineinfile:
|
||||
path: /etc/dphys-swapfile
|
||||
regexp: '^CONF_SWAPSIZE='
|
||||
line: 'CONF_SWAPSIZE=0'
|
||||
notify: restart kubelet
|
||||
- name: Disable swap in /etc/fstab
|
||||
replace:
|
||||
path: /etc/fstab
|
||||
regexp: '^([^#].*?\sswap\s+.*)$'
|
||||
replace: '# \1'
|
||||
|
||||
- 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
|
||||
replace:
|
||||
path: /boot/cmdline.txt
|
||||
path: "{{ cmdline_path }}"
|
||||
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1\b).*)$'
|
||||
replace: '\1 cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1'
|
||||
register: cgroup_update
|
||||
@@ -100,13 +145,13 @@
|
||||
|
||||
- name: Download Kubernetes GPG key
|
||||
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
|
||||
mode: '0644'
|
||||
|
||||
- name: Add Kubernetes 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
|
||||
filename: kubernetes
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
---
|
||||
- name: Pre-pull Kubernetes images
|
||||
command: kubeadm config images pull
|
||||
|
||||
- name: Initialize Kubernetes Control Plane
|
||||
command: kubeadm init --pod-network-cidr=10.244.0.0/16
|
||||
args:
|
||||
|
||||
Reference in New Issue
Block a user