Fixed some errors thrown by ansible-lint
Some checks reported errors
--> 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:
Davide Oddone 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_master # tasks file for kubernetes_master
- name: Install required packages - name: Install required packages
apt: ansible.builtin.apt:
name: name:
- curl - curl
- gnupg2 - gnupg2
@ -9,20 +9,18 @@
- apt-transport-https - apt-transport-https
- ca-certificates - ca-certificates
state: present state: present
update_cache: yes update_cache: true
- name: Install Docker - name: Install Docker
apt: ansible.builtin.apt:
name: docker.io name: docker.io
state: present state: present
update_cache: yes update_cache: true
- name: Remove Keyrings Directory (if it exists) - 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) - 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_31_deb.list ansible.builtin.command: sudo rm -rf /etc/apt/sources.list.d/pkgs_k8s_io_core_stable_v1_31_deb.list
- name: Disable swap - name: Disable swap
ansible.builtin.command: ansible.builtin.command:
cmd: swapoff -a cmd: swapoff -a
@ -109,7 +107,7 @@
cmd: sudo ufw allow 5473/tcp cmd: sudo ufw allow 5473/tcp
- name: Enable the firewall - name: Enable the firewall
ansible.builtin.ufw: community.general.ufw:
state: enabled state: enabled
- name: Reload the firewall - name: Reload the firewall
@ -117,17 +115,17 @@
cmd: sudo ufw reload cmd: sudo ufw reload
- name: Prepare keyrings directory and update permissions - name: Prepare keyrings directory and update permissions
file: ansible.builtin.file:
path: /etc/apt/keyrings path: /etc/apt/keyrings
state: directory state: directory
mode: '0755' mode: "0755"
- name: Download Kubernetes GPG key securely - name: Download Kubernetes GPG key securely
ansible.builtin.shell: curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.31/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg ansible.builtin.shell: curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.31/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
- name: Add Kubernetes repository - name: Add Kubernetes repository
ansible.builtin.apt_repository: ansible.builtin.apt_repository:
repo: "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.31/deb/ /" repo: deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.31/deb/ /
state: present state: present
- name: Install kubeadm, kubelet, kubectl - name: Install kubeadm, kubelet, kubectl
@ -137,7 +135,7 @@
- kubeadm - kubeadm
- kubectl - kubectl
state: present state: present
update_cache: yes update_cache: true
- name: Hold kubelet, kubeadm, kubectl packages - name: Hold kubelet, kubeadm, kubectl packages
ansible.builtin.command: ansible.builtin.command:
@ -146,7 +144,7 @@
- name: Replace /etc/default/kubelet contents - name: Replace /etc/default/kubelet contents
ansible.builtin.copy: ansible.builtin.copy:
dest: /etc/default/kubelet dest: /etc/default/kubelet
content: 'KUBELET_EXTRA_ARGS="--cgroup-driver=cgroupfs"' content: KUBELET_EXTRA_ARGS="--cgroup-driver=cgroupfs"
- name: Reload systemd configuration - name: Reload systemd configuration
ansible.builtin.command: ansible.builtin.command:
@ -166,7 +164,7 @@
- name: Reboot the system - name: Reboot the system
ansible.builtin.reboot: ansible.builtin.reboot:
msg: "Reboot initiated by Ansible for Kubernetes setup" msg: Reboot initiated by Ansible for Kubernetes setup
reboot_timeout: 150 reboot_timeout: 150
- name: Replace Docker daemon.json configuration - name: Replace Docker daemon.json configuration
@ -215,22 +213,24 @@
changed_when: false changed_when: false
- name: Set permissions for Kubernetes Admin - name: Set permissions for Kubernetes Admin
file: ansible.builtin.file:
path: /etc/kubernetes/admin.conf path: /etc/kubernetes/admin.conf
state: file state: file
owner: ansible owner: ansible
mode: '0755' mode: "0755"
- name: Generate join command - name: Generate join command
command: kubeadm token create --print-join-command ansible.builtin.command: kubeadm token create --print-join-command
register: join_command register: join_command
- name: Copy join command to local file - name: Copy join command to local file
local_action: copy content="{{ join_command.stdout_lines[0] }}" dest="/tmp/join-command" ansible.builtin.copy:
content: '"{{ join_command.stdout_lines[0] }}"'
dest: '"/tmp/join-command"'
delegate_to: localhost
- name: Set permissions for the Join Executable - name: Set permissions for the Join Executable
file: ansible.builtin.file:
path: /tmp/join-command path: /tmp/join-command
state: file state: file
mode: '0755' mode: "0755"
delegate_to: localhost delegate_to: localhost

View File

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