# Unable to use 'yum install'

**URL:** <https://forum.ansible.com/t/unable-to-use-yum-install/27507>\
**Category:** Ansible Project\
**Tags:** kubernetes\
**Created:** [May 10, 2018, 4:25pm UTC](https://forum.ansible.com/t/unable-to-use-yum-install/27507 "2018-05-10T16:25:35Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fabio\_Gomes\_Sakiyama](https://avatars.discourse-cdn.com/v4/letter/f/b77776/32.png) [@Fabio\_Gomes\_Sakiyama](https://forum.ansible.com/u/Fabio_Gomes_Sakiyama)\
**Post date:** [May 10, 2018, 4:25pm UTC](https://forum.ansible.com/t/unable-to-use-yum-install/27507/1 "2018-05-10T16:25:35Z")

</div>

Hi,

I’m trying to install kubelet with **Ansible** , but I’m struggling to do it.

This is my **playbook** :

```auto
---
  - hosts: all
    become: yes
    tasks:
      - name: install docker
        yum:
          name: docker
          state: present
          update_cache: true

      - name: add repo
        yum_repository:
          name: kuberepo
          description: kubernetes-repo
          baseurl: "https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64"
          enabled: yes
          gpgcheck: yes
          repo_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: setenforce
        shell: setenforce 0

      - name: install kubelet
        yum:
          name: kubelet
          state: present
          update_cache: true

```

`

`

This is the **error** when i run the playbook (ansible-playbook -i hosts kube-dependencies.yml)

[![](https://lh3.googleusercontent.com/-oT8v8pXEIb0/WvRyKSWIGvI/AAAAAAAATK8/ZpT3y8kJ5cwPjxgUQ3hBkMhMSxI_ByIjgCLcBGAs/s1600/ansibleError.png)](https://lh3.googleusercontent.com/-oT8v8pXEIb0/WvRyKSWIGvI/AAAAAAAATK8/ZpT3y8kJ5cwPjxgUQ3hBkMhMSxI_ByIjgCLcBGAs/s1600/ansibleError.png)

The “ok” from [master] node is because I manually executed “sudo yum install kubelet” on that machine, and it worked.

**Conclusions:** So basically, manually executing the yum install command it works, but I can’t make it work with ansible.

Any clues? What am I doing wrong?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Nick\_Rogers](https://avatars.discourse-cdn.com/v4/letter/n/eb8c5e/32.png) [@Nick\_Rogers](https://forum.ansible.com/u/Nick_Rogers)\
**Post date:** [May 10, 2018, 5:05pm UTC](https://forum.ansible.com/t/unable-to-use-yum-install/27507/2 "2018-05-10T17:05:21Z")

</div>

I would try to `curl [https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86\_64/repodata/repomd.xml](https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml)’ from the error on worker1/2 and see if it reports anything more helpful than what you’re getting back. Feels like a networking problem to me.

---

<div class="post-metadata">

**Author:** ![Fabio\_Gomes\_Sakiyama](https://avatars.discourse-cdn.com/v4/letter/f/b77776/32.png) [@Fabio\_Gomes\_Sakiyama](https://forum.ansible.com/u/Fabio_Gomes_Sakiyama)\
**Post date:** [May 10, 2018, 5:12pm UTC](https://forum.ansible.com/t/unable-to-use-yum-install/27507/3 "2018-05-10T17:12:58Z")

</div>

Hi Nick, thanks for helping!

the curl executed fine, I didn’t mention but my environment is running on google cloud.  
If I enter the worker node and manually execute ‘yum install kubelet’, it works. But the same command on ansible playbook throws the error i mentioned… ☹

---

<div class="post-metadata">

**Author:** ![Tchia04](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@Tchia04](https://forum.ansible.com/u/Tchia04)\
**Post date:** [May 10, 2018, 6:21pm UTC](https://forum.ansible.com/t/unable-to-use-yum-install/27507/4 "2018-05-10T18:21:17Z")

</div>

Maybe try adding “disable\_gpg\_check: true” to the “install kuberlet” task?

---

<div class="post-metadata">

**Author:** ![Fabio\_Gomes\_Sakiyama](https://avatars.discourse-cdn.com/v4/letter/f/b77776/32.png) [@Fabio\_Gomes\_Sakiyama](https://forum.ansible.com/u/Fabio_Gomes_Sakiyama)\
**Post date:** [May 10, 2018, 7:57pm UTC](https://forum.ansible.com/t/unable-to-use-yum-install/27507/5 "2018-05-10T19:57:59Z")

</div>

Hi Tony,

Does it mean that it’ll not use the security provided by gpg signatures of the packages?

---

<div class="post-metadata">

**Author:** ![jean-yves](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jean-yves](https://forum.ansible.com/u/jean-yves)\
**Post date:** [May 10, 2018, 8:02pm UTC](https://forum.ansible.com/t/unable-to-use-yum-install/27507/6 "2018-05-10T20:02:42Z")

</div>

Hi,

Could you try to add the GPG key with something like this before doing the yum ansible command ?

```auto
- name: Add repository key
  rpm_key:
    key: ["https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg"](https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg)

```

Regards,

---

<div class="post-metadata">

**Author:** ![js.a](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@js.a](https://forum.ansible.com/u/js.a)\
**Post date:** [May 11, 2018, 3:11am UTC](https://forum.ansible.com/t/unable-to-use-yum-install/27507/7 "2018-05-11T03:11:45Z")

</div>

Hey Fabio, like Jean-Yves said, try to split up your “Add repo” task in two, key install and package install. Something like this:

- name: add key repo  
rpm\_key:  
key: “[https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg](https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg)”  
state: present

- name: add repo  
yum\_repository:  
name: kuberepo  
description: kubernetes-repo  
baseurl: “[https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86\_64](https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64)”  
enabled: yes  
gpgcheck: yes  
repo\_gpgcheck: yes

---

<div class="post-metadata">

**Author:** ![Fabio\_Gomes\_Sakiyama](https://avatars.discourse-cdn.com/v4/letter/f/b77776/32.png) [@Fabio\_Gomes\_Sakiyama](https://forum.ansible.com/u/Fabio_Gomes_Sakiyama)\
**Post date:** [May 11, 2018, 11:26am UTC](https://forum.ansible.com/t/unable-to-use-yum-install/27507/8 "2018-05-11T11:26:32Z")

</div>

Hi Jean/js.a

I splitted up but the error persists. I’m not sure if my playbook is correct though. Here’s the splitted playbook.

`

```auto
---
  - hosts: all
    become: yes
    tasks:
      - name: install docker
        yum:
          name: docker
          state: present
          update_cache: true

      - name: add yum key repo
        rpm_key:
          key: "https://packages.cloud.google.com/yum/doc/yum-key.gpg"
          state: present

      - name: add rpm key repo
        rpm_key:
          key: "https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg"
          state: present

      - name: add repo
        yum_repository:
          name: kuberepo
          description: kubernetes-repo
          baseurl: "https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64"
          enabled: yes
          gpgcheck: yes
          repo_gpgcheck: yes

```

`

---

<div class="post-metadata">

**Author:** ![jean-yves](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jean-yves](https://forum.ansible.com/u/jean-yves)\
**Post date:** [May 11, 2018, 11:44am UTC](https://forum.ansible.com/t/unable-to-use-yum-install/27507/9 "2018-05-11T11:44:25Z")

</div>

Hi,

Please provide logs to see the exact problem

Perhaps information given by a manual yum could help also…

But looking for your problem I found some related information that could (not sure) let us know that the problem is somewhere else :

[https://github.com/kubernetes/kubernetes/issues/37922](https://github.com/kubernetes/kubernetes/issues/37922)

[https://github.com/kubernetes/kubernetes/issues/60134](https://github.com/kubernetes/kubernetes/issues/60134)

Regards,

JY

---

<div class="post-metadata">

**Author:** ![Fabio\_Gomes\_Sakiyama](https://avatars.discourse-cdn.com/v4/letter/f/b77776/32.png) [@Fabio\_Gomes\_Sakiyama](https://forum.ansible.com/u/Fabio_Gomes_Sakiyama)\
**Post date:** [May 11, 2018, 12:28pm UTC](https://forum.ansible.com/t/unable-to-use-yum-install/27507/10 "2018-05-11T12:28:19Z")

</div>

Hi all,

The problem was that the workers needed to be updated with ‘‘yum -y update’’. I added the following code to my playbook:

`

```auto
      - name: yum update
        yum:
          name: '*'
          state: latest

```

`

Unfortunately I don’t know why this solved the problem ☹

Thanks for helping!
