yum module fails to install multiple packages

97 views
Skip to first unread message

Александр Костырев

unread,
Dec 7, 2015, 11:37:14 AM12/7/15
to Ansible Project
Name        : ansible
Version     : 1.9.2

I've got a simple play

---
 - hosts: all
   tasks:
    - name: debug
      debug: 
        msg: "{{ item }}"
      with_items:
        - foreman_discovery
        - foreman_default_hostgroup
      tags: foreman-plugins-debug

    - name: debug install plugin
      debug:
        msg: "ruby193-rubygem-{{ item }}"
      with_items:
        - foreman_discovery
        - foreman_default_hostgroup
      tags: foreman-plugins-debug

    - name: install plugins
      yum: name='ruby193-rubygem-{{ item }}' state=present
      with_items:
        - foreman_discovery
        - foreman_default_hostgroup
      tags: 
        - foreman-plugins-install
        - foreman-plugins-debug


that fails

PLAY [all] ******************************************************************** 

GATHERING FACTS *************************************************************** 


TASK: [debug] ***************************************************************** 

ok: [foreman.qa.linx.sbx.avp.ru] => (item=foreman_discovery) => {
    "item": "foreman_discovery",
    "msg": "foreman_discovery"
}

ok: [foreman.qa.linx.sbx.avp.ru] => (item=foreman_default_hostgroup) => {
    "item": "foreman_default_hostgroup",
    "msg": "foreman_default_hostgroup"
}

TASK: [debug install plugin] ************************************************** 

ok: [foreman.qa.linx.sbx.avp.ru] => (item=foreman_discovery) => {
    "item": "foreman_discovery",
    "msg": "ruby193-rubygem-foreman_discovery"
}

ok: [foreman.qa.linx.sbx.avp.ru] => (item=foreman_default_hostgroup) => {
    "item": "foreman_default_hostgroup",
    "msg": "ruby193-rubygem-foreman_default_hostgroup"
}

TASK: [install plugins] ******************************************************* 
failed: [foreman.qa.linx.sbx.avp.ru] => (item=foreman_discovery,foreman_default_hostgroup) => {"changed": false, "failed": true, "item": "foreman_discovery,foreman_default_hostgroup", "rc": 0, "results": ["ruby193-rubygem-foreman_discovery-4.0.0-1.fm1_9.el7.noarch providing ruby193-rubygem-foreman_discovery is already installed"]}
msg: No Package matching 'foreman_default_hostgroup' found available, installed or updated

FATAL: all hosts have already failed -- aborting

at the same time

$ yum install -q ruby193-rubygem-foreman_discovery ruby193-rubygem-foreman_default_hostgroup

=========================================================================================================================================================================================================
 Package                                                              Arch                              Version                                         Repository                                  Size
=========================================================================================================================================================================================================
Installing:
 ruby193-rubygem-foreman_default_hostgroup                            noarch                            3.0.0-1.el7                                     foreman-plugins                             19 k
 ruby193-rubygem-foreman_discovery                                    noarch                            4.0.0-1.fm1_9.el7                               foreman-plugins                            206 k

Transaction Summary
=========================================================================================================================================================================================================
Install  2 Packages

Is this ok [y/d/N]: y

succeed

How can I workaround this?

Thanks!

Александр Костырев

unread,
Dec 7, 2015, 11:44:42 AM12/7/15
to Ansible Project
Okay
I found this
and the solution is to specify full package name in with_items

what the hell.. it's not a solution at all

I wanted to use some var as a package name prefix because
on Fedora and Red Hat systems
# yum install tfm-rubygem-foreman_discovery

on on Debian and Ubuntu systems.
# apt-get install ruby-foreman-discovery
f
I'd like to write a multi-platform code.

Dick Davies

unread,
Dec 7, 2015, 4:04:19 PM12/7/15
to ansible list
Right, i'd suggest you have 2 dicts or lists - one for Debians and one for EL linuxes - and conditionally load them into the yum: task based on ansible_os_family.

--
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/69f8e2cd-b902-4237-a31d-d545edf81dcd%40googlegroups.com.

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

Александр Костырев

unread,
Dec 7, 2015, 5:38:03 PM12/7/15
to Ansible Project, di...@hellooperator.net
You don't get it.
Plugins are optional.
They may or may not be wanted by user.

So I pushed to my repo the code that breaks just to illustrate want I'd like to achieve with ansible

We've got vars
and for RHEL

those vars are pulled with

and code that installs those plugins:

Of course it's not gonna work for ubuntu 'cause I don't render repo files for it
but
it also fails for rhel with aforementioned error.

Is there any workaround I could use to get what I want?

Thanks!

Александр Костырев

unread,
Dec 7, 2015, 5:42:32 PM12/7/15
to Ansible Project, di...@hellooperator.net
I don't know which plugins someone would like to install so I can't have hard-coded list.


On Tuesday, 8 December 2015 00:04:19 UTC+3, Dick Davies wrote:

Александр Костырев

unread,
Dec 7, 2015, 6:06:12 PM12/7/15
to ansible...@googlegroups.com

and I'd like to add that end-user should not be bothered with differences in packages' names in OSes
Setting

foreman_plugins:
  - discovery
  - bootdisk

is all what have to be done.

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/7NshAYwEpbo/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.

Александр Костырев

unread,
Dec 8, 2015, 8:42:55 AM12/8/15
to Ansible Project
Strangely enough but after rewriting

    - name: install plugins
     yum: name='ruby193-rubygem-{{ item }}' state=present

into

- name: install plugins OS agnostic
  action: >
    {{ ansible_pkg_mgr }}
    name="{{ foreman_plugin_prefix }}{{ item }}"

it works! so my problem solved


On Monday, 7 December 2015 19:37:14 UTC+3, Александр Костырев wrote:
Reply all
Reply to author
Forward
0 new messages