<p>I need to complete one of the kubeadm installation steps which include the following commands on a centos machine</p>
<pre><code>yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
</code></pre>
<p>I need to perform this via an Ansible automation script and I have not been able to figure out which way to correctly implement this step I tried</p>
<pre><code>- name: Install these packages - kubelet kubeadm kubectl
    yum:
      name: &quot;{{ packages }}&quot;
    vars:
      packages:
        - kubelet
        - kubeadm
        - kubectl
      state: latest
      disable_excludes: repoid
      disablerepo: kubernetes
      become: yes
      become_user: root
</code></pre>
<p>And i got the following output :</p>
<pre><code>TASK [Install these packages - kubelet kubeadm kubectl] *****************************************************************************************************
fatal: [k8s-head]: FAILED! =&gt; {&quot;ansible_facts&quot;: {&quot;pkg_mgr&quot;: &quot;yum&quot;}, &quot;changed&quot;: false, &quot;msg&quot;: &quot;Failure talking to yum: failure: repodata/repomd.xml from kubernetes: [Errno 256] No more mirrors to try.\nhttps://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno -1] repomd.xml signature could not be verified for kubernetes&quot;}
fatal: [k8s-node-1]: FAILED! =&gt; {&quot;ansible_facts&quot;: {&quot;pkg_mgr&quot;: &quot;yum&quot;}, &quot;changed&quot;: false, &quot;msg&quot;: &quot;Failure talking to yum: failure: repodata/repomd.xml from kubernetes: [Errno 256] No more mirrors to try.\nhttps://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno -1] repomd.xml signature could not be verified for kubernetes&quot;}
</code></pre>
<p>I know I am doing this wrong but I do not understand if I am supposed to use yum.conf file to rectify it or use any other option from the yum module to disable_exclude Kubernetes. I can always use the shell module but I want to keep it as a last resort.</p>
<blockquote>
<p><strong>EDIT : TRIED INDENTATION</strong>
<strong>Disclaimer this worked but is not a solution.</strong>
So i corrected my identation and tried the ansible script as following</p>
</blockquote>
<pre><code>- name: Install these packages - kubelet kubeadm kubectl
    yum:
      name: &quot;{{ packages }}&quot;
      state: latest
      disable_excludes: all
      exclude: kubernetes
    vars:
      packages:
        - kubelet
        - kubeadm
        - kubectl
    become: yes
    become_user: root
</code></pre>
<p><strong>I still am not sure if that is the correct way to implement the following commands</strong></p>
<pre><code>yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
</code></pre>
<p>but my packages are getting installed without an error so it does the job that i want it to do for now.</p>

Yashgiri Goswami
<p>I solved it like this:</p>
<pre><code>- name: Setup for the Kubernetes's Environment
  hosts: kube-master
  gather_facts: yes
  tasks:
    - name: Add Kubernetes yum repository
      become: yes
      when: ansible_os_family == &quot;RedHat&quot;
      yum_repository:
        name: Kubernetes
        description: Kubernetes Repository
        baseurl: http://yum.kubernetes.io/repos/kubernetes-el7-x86_64
        enabled: yes
        gpgcheck: yes
        gpgkey: 
          - https://packages.cloud.google.com/yum/doc/yum-key.gpg
          - https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
    - name: Install kubeadm (RHEL/CentOS)
      become: yes
      when: ansible_os_family == &quot;RedHat&quot;
      yum:
        name: kubeadm
        state: present
</code></pre>
