Ansible yum disable_excludes giving error, how to use it correctly for a particular shell command?

https://stackoverflow.com/questions/62805006/ansible-yum-disable-excludes-giving-error-how-to-use-it-correctly-for-a-particu

Asked 5 years, 6 months ago Modified 4 years, 10 months ago Viewed 2k times 3

I need to complete one of the kubeadm installation steps which include the following commands on a centos machine

yum install -y kubelet kubeadm kubectl –disableexcludes=kubernetes 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

  • name: Install these packages - kubelet kubeadm kubectl yum: name: “{{ packages }}” vars: packages: - kubelet - kubeadm - kubectl state: latest disable_excludes: repoid disablerepo: kubernetes become: yes become_user: root And i got the following output :

TASK [Install these packages - kubelet kubeadm kubectl] ************************************* fatal: [k8s-head]: FAILED! => {“ansible_facts”: {“pkg_mgr”: “yum”}, “changed”: false, “msg”: “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”} fatal: [k8s-node-1]: FAILED! => {“ansible_facts”: {“pkg_mgr”: “yum”}, “changed”: false, “msg”: “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”} 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.

EDIT : TRIED INDENTATION Disclaimer this worked but is not a solution. So i corrected my identation and tried the ansible script as following

  • name: Install these packages - kubelet kubeadm kubectl yum: name: “{{ packages }}” state: latest disable_excludes: all exclude: kubernetes vars: packages: - kubelet - kubeadm - kubectl become: yes become_user: root I still am not sure if that is the correct way to implement the following commands

yum install -y kubelet kubeadm kubectl –disableexcludes=kubernetes but my packages are getting installed without an error so it does the job that i want it to do for now.

kubernetesansibleyum Share Improve this question Follow edited Jul 10, 2020 at 3:52 asked Jul 8, 2020 at 23:11 Yashgiri Goswami’s user avatar Yashgiri Goswami 30144 silver badges1616 bronze badges 2 Did you add the kubernetes repo first like it says here? kubernetes.io/docs/setup/production-environment/tools/kubeadm/… – Brian Pursley CommentedJul 9, 2020 at 1:19 2 Does it work outside of ansible? – Rico CommentedJul 9, 2020 at 2:16 2 I can’t tell if you just indented it incorrectly for this question, or for real, but state: and the rest of those keys should not be indented under vars: or they will be just that – vars – and not parameters to the yum: module – mdaniel CommentedJul 9, 2020 at 4:49 @BrianPursley yes i did do that by using the ansible copy module and copying the .repo file from my control machine to the guest machines – Yashgiri Goswami CommentedJul 9, 2020 at 15:41 @Rico it does work outside of ansible, i have tried via both shell commands and scripts which are basically doing exactly what is specified by Brian Pursley in the link – Yashgiri Goswami CommentedJul 9, 2020 at 15:42 Show 1 more comment 1 Answer Sorted by:

Highest score (default) 3

I solved it like this:

  • 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 == “RedHat” 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 == “RedHat” yum: name: kubeadm state: present Share Improve this answer Follow edited Mar 13, 2021 at 16:39 Adrian Mole’s user avatar Adrian Mole 52.2k193193 gold badges6262 silver badges101101 bronze badges answered Mar 13, 2021 at 16:06 Brian Choi’s user avatar Brian Choi 664

Updated: