Ansible yum module unable to find certain packages

9,064 views
Skip to first unread message

Jeffrey Wen

unread,
Nov 22, 2016, 2:27:51 PM11/22/16
to Ansible Project
My playbook that installs some generic applications on all of my servers:

- name: Install base applications
  yum
: name={{ item }} state=present
  with_items
:
   
- epel-release
   
- vim-enhanced
   
- gcc
   
- wget
   
- libsemanage-python
   
- policycoreutils-python
   
- setroubleshoot
   
- tmux


I get an error message for each of the following packages:
"msg": "No package matching 'libsemanage-python' found available, installed or updated", "rc": 126

"msg": "No package matching 'policycoreutils-python' found available, installed or updated", "rc": 126

"msg": "No package matching 'setroubleshoot found available, installed or updated", "rc": 126

"msg": "No package matching 'tmux' found available, installed or updated", "rc": 126

If I remove those packages from the item list, the install goes through fine.

I have also verified that if I manually run the following command on the remote server, it exists
yum install libsemanage-python policycoreutils-python setroubleshoot tmux

If I remove the package from the item list and install it individually, it will work:
- name: Install libsemanage-python
  yum
: name=libsemanage-python state=present

Has anyone run into a similar scenario and figured out why it is causing this?

Alexander H. Laughlin

unread,
Nov 22, 2016, 5:23:51 PM11/22/16
to Ansible Project
I'm afraid I can't reproduce this on a CentOS 7 vm running in virtualbox. Are you using RedHat? If so, which version?

The playbook I used for reference, along with the results.






(duchess) [duchess@centos:jeffrey-wen] cat yum.yml

---

- name: Test yum module installs.

 hosts: localhost

 become: yes

 tasks:

   - name: Install base applications

     yum:

        name: "{{ item }}"

        state: present

      with_items:

       - epel-release

       - vim-enhanced

       - gcc

       - wget

       - libsemanage-python

       - policycoreutils-python

       - setroubleshoot

       - tmux

...

# vim: ft=ansible:

(duchess) [duchess@centos:jeffrey-wen] ansible-playbook yum.yml


PLAY [Test yum module installs.] ***********************************************


TASK
[setup] *******************************************************************


ok
: [localhost]


TASK
[Install base applications] ***********************************************

changed: [localhost] => (item=[u'epel-release', u'vim-enhanced', u'gcc', u'wget', u'libsemanage-python', u'policycoreutils-python', u'setroubleshoot', u'tmux'])


PLAY RECAP
*********************************************************************

localhost                  : ok=2    changed=1    unreachable=0    failed=0  


(duchess)
[duchess@centos:jeffrey-wen] ansible --version

ansible 2.2.0.0

 config file = /etc/ansible/ansible.cfg

 configured module search path = Default w/o overrides

(duchess) [duchess@centos:jeffrey-wen]

Jeffrey Wen

unread,
Nov 22, 2016, 9:50:36 PM11/22/16
to Ansible Project
I am using Red Hat Enterprise Linux Server release 7.3 (Maipo)

Jeffrey Wen

unread,
Nov 23, 2016, 9:19:59 AM11/23/16
to Ansible Project
I have confirmed that this does work on CentOS Linux release 7.2.1511 (Core)

However, it does not work on Red Hat Enterprise Linux Server release 7.3 (Maipo)

Alexander H. Laughlin

unread,
Nov 23, 2016, 3:27:53 PM11/23/16
to Ansible Project
I have not yet had time to set up a test bed for this, but I'm planning on doing that today so I'll update you with my results. 

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/WnKg0GYz0O8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0380bea5-1624-41c4-ad2a-270caf8d8efa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
A. H. Laughlin
Chief Financial Officer
Office of Finance
Gahan Corporation

Alexander H. Laughlin

unread,
Nov 24, 2016, 2:18:54 AM11/24/16
to Ansible Project
I can reproduce this error on a Red Hat Enterprise Linux Server 7.3 Maipo vm. 

(duchess) [duchess@localhost:jeffrey-wen] ansible-playbook yum.yml

PLAY [Test yum module installs.] ***********************************************

TASK [setup] *******************************************************************

ok: [localhost]

TASK [Install base applications] ***********************************************

failed: [localhost] (item=[u'epel-release', u'vim-enhanced', u'gcc', u'wget', u'libsemanage-python', u'policycoreutils-python', u'setroubleshoot', u'tmux']) => {"changed":false,"failed":true,"item": ["epel-release", "vim-enhanced", "gcc", "wget", "libsemanage-python", "policycoreutils-python", "setroubleshoot", "tmux"], "msg": "No package matching 'epel-release' found available,installed or updated", "rc": 126, "results": ["No package matching 'epel-release' found available, installed or updated"]}


PLAY RECAP *********************************************************************

localhost                  : ok=1    changed=0    unreachable=0    failed=1  


(duchess) [duchess@localhost:jeffrey-wen] ansible --version

ansible 2.2.0.0

 config file = /etc/ansible/ansible.cfg

 configured module search path = Default w/o overrides

(duchess) [duchess@localhost:jeffrey-wen] cat yum.yml

---

- name: Test yum module installs.

 hosts: localhost

 become: yes

 tasks:

   - name: Install base applications

     yum:

        name: "{{ item }}"

        state: present

      with_items:

       - epel-release

       - vim-enhanced

       - gcc

       - wget

       - libsemanage-python
       - policycoreutils-python

       - setroubleshoot
       - tmux

...

# vim: ft=ansible:

(duchess) [duchess@localhost:jeffrey-wen] cat /etc/redhat-release

Red Hat Enterprise Linux Server release 7.3 (Maipo)


I suppose CentOS is more forgiving than RHEL, but the way to make this work as you intend is to adjust your playbook so that 'epel-release' is installed with the yum_repository module, like so:

---

- name: Test yum module installs.

 hosts: localhost

 become: yes

 tasks:

   - name: What if we use yum_repository?

     yum_repository:

       baseurl: https://dl.fedoraproject.org/pub/epel/7Server/x86_64/

       description: "Epel release."

       name: epel-release

       state: present

   - name: Install base applications

     yum:

        name: "{{ item }}"

        state: present

      with_items:

       - gcc

       - libsemanage-python

       - policycoreutils-python

       - setroubleshoot

       - tmux

       - vim-enhanced

       - wget

...

# vim: ft=ansible:


Which will produce the following output:

(duchess) [duchess@localhost:jeffrey-wen] ansible-playbook yum.yml

PLAY [Test yum module installs.] ***********************************************

TASK [setup] *******************************************************************

ok: [localhost]


TASK [What if we use yum_repository?] ******************************************

changed: [localhost]


TASK [Install base applications] ***********************************************

changed: [localhost] => (item=[u'gcc', u'libsemanage-python', u'policycoreutils-python', u'setroubleshoot', u'tmux', u'vim-enhanced', u'wget'])


PLAY RECAP *********************************************************************

localhost                  : ok=3    changed=2    unreachable=0    failed=0


Hope that helps.

Cheers mate!



On Wednesday, November 23, 2016 at 12:27:53 PM UTC-8, Alexander H. Laughlin wrote:
I have not yet had time to set up a test bed for this, but I'm planning on doing that today so I'll update you with my results. 

To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.

Jeffrey Wen

unread,
Nov 24, 2016, 7:57:32 AM11/24/16
to Ansible Project
Hey Alexander,

Thank you so much for helping me out! However, there is still an issue with a few of the other packages.

For example: try removing epel-release from the list and watch it complain about a few of the other packages.

Dick Davies

unread,
Nov 25, 2016, 2:50:36 AM11/25/16
to ansible list
Isn't that because those packages are from EPEL ? You need to add the
repo in one task,
and then add the other packages in the second.

On 24 November 2016 at 12:57, 'Jeffrey Wen' via Ansible Project
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a346869e-76b8-4b00-a114-aa99ae2d791f%40googlegroups.com.

Alexander H. Laughlin

unread,
Nov 25, 2016, 4:15:00 AM11/25/16
to ansible list
Indeed, it is not possible to install packages from the epel repo without first installing the repo in yum.
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/WnKg0GYz0O8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

kprku...@gmail.com

unread,
Jun 8, 2018, 12:20:09 PM6/8/18
to Ansible Project
This happens on RHEL when you run the tasks as non-root user.
Just specify become and become_user in yum task to fix this issue
Reply all
Reply to author
Forward
0 new messages