Fixed some errors thrown by ansible-lint
Some checks failed
--> Linted: ANSIBLE Errors were detected, please view logs
--> Linted: GITLEAKS No errors were found in the linting process
--> Linted: JSCPD No errors were found in the linting process
--> Linted: YAML No errors were found in the linting process
Lint Code Base / run-lint (push) Failing after 38s

This commit is contained in:
2024-10-17 18:11:47 +02:00
parent 82693a3389
commit ce55ca5303
2 changed files with 39 additions and 41 deletions

View File

@@ -1,7 +1,7 @@
---
# tasks file for kubernetes_worker
- name: Install required packages
apt:
ansible.builtin.apt:
name:
- curl
- gnupg2
@@ -9,20 +9,18 @@
- apt-transport-https
- ca-certificates
state: present
update_cache: yes
update_cache: true
- name: Install Docker
apt:
ansible.builtin.apt:
name: docker.io
state: present
update_cache: yes
update_cache: true
- name: Remove Keyrings Directory (if it exists)
ansible.builtin.shell: rm -rf /etc/apt/keyrings
ansible.builtin.command: rm -rf /etc/apt/keyrings
- name: Remove Existing Kubernetes Directory (if it exists)
ansible.builtin.shell: sudo rm -rf /etc/apt/sources.list.d/pkgs_k8s_io_core_stable_v1_30_deb.list
ansible.builtin.command: sudo rm -rf /etc/apt/sources.list.d/pkgs_k8s_io_core_stable_v1_30_deb.list
- name: Disable swap
ansible.builtin.command:
cmd: swapoff -a
@@ -109,7 +107,7 @@
cmd: sudo ufw allow 5473/tcp
- name: Enable the firewall
ansible.builtin.ufw:
community.general.ufw:
state: enabled
- name: Reload the firewall
@@ -117,17 +115,17 @@
cmd: sudo ufw reload
- name: Prepare keyrings directory and update permissions
file:
ansible.builtin.file:
path: /etc/apt/keyrings
state: directory
mode: '0755'
mode: "0755"
- name: Download Kubernetes GPG key securely
ansible.builtin.shell: curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
- name: Add Kubernetes repository
ansible.builtin.apt_repository:
repo: "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /"
repo: deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /
state: present
- name: Install kubeadm, kubelet, kubectl
@@ -137,7 +135,7 @@
- kubeadm
- kubectl
state: present
update_cache: yes
update_cache: true
- name: Hold kubelet, kubeadm, kubectl packages
ansible.builtin.command:
@@ -146,7 +144,7 @@
- name: Replace /etc/default/kubelet contents
ansible.builtin.copy:
dest: /etc/default/kubelet
content: 'KUBELET_EXTRA_ARGS="--cgroup-driver=cgroupfs"'
content: KUBELET_EXTRA_ARGS="--cgroup-driver=cgroupfs"
- name: Reload systemd configuration
ansible.builtin.command:
@@ -159,15 +157,15 @@
- name: Reboot the system
ansible.builtin.reboot:
msg: "Reboot initiated by Ansible for Kubernetes setup"
msg: Reboot initiated by Ansible for Kubernetes setup
reboot_timeout: 150
- name: Copy join-command file to worker nodes
copy:
ansible.builtin.copy:
src: /tmp/join-command
dest: /tmp/join-command
mode: 0755
mode: "0755"
- name: Join Worker Nodes
ansible.builtin.shell: sh /tmp/join-command
become: yes
ansible.builtin.command: sh /tmp/join-command
become: true