- name: Install Kube tools (Kubeadm, Kubelet, Kubectl) using OS tools hosts: all become: yes become_method: sudo become_user: root tasks: - name: Install apt tools and accesories package: name: {{ item }} state: present with_items: - "apt-transport-https" - "ca-certificates" - "curl" - "gpg" - name: Creates keyrings directory file: path: /etc/apt/keyrings state: directory mode: '755' - name: Install certificate command: "{{ item }} chdir=/tmp" with_items: - "curl -fsSL https://pkgs.k8s.io/core:/stable:/{{ K8S_VERSION }}/deb/Release.key" - "gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg Release.key" - "rm Release.key" - name: Setup APT repo copy: dest: /etc/apt/sources.list.d/kubernetes.list content: "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/{{ K8S_VERSION }}/deb/ /" - name: Update cache apt: update_cache: yes - name: Setup tools package: name: {{ item }} state: present with_items: - "kubelet" - "kubeadm" - "kubectl" - name: Hold packages dpkg_selections: name: {{ item }} selection: hold with_items: - "kubelet" - "kubeadm" - name: Start kubelet service: name: kubelet enabled: true state: started