yum module fails to install multiple packages

Name : ansible
Version : 1.9.2

I’ve got a simple play

`

Okay
I found this
https://github.com/ansible/ansible/issues/9552
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.

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 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
https://github.com/kostyrevaa/ansible-role-foreman

We’ve got vars
for Ubuntu https://github.com/kostyrevaa/ansible-role-foreman/blob/wip_plugins/vars/Ubuntu.yml
and for RHEL
https://github.com/kostyrevaa/ansible-role-foreman/blob/wip_plugins/vars/RedHat_7.yml

those vars are pulled with
https://github.com/kostyrevaa/ansible-role-foreman/blob/wip_plugins/tasks/main.yml#L4

and code that installs those plugins:
https://github.com/kostyrevaa/ansible-role-foreman/blob/wip_plugins/tasks/plugins.yml#L21

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!

I don’t know which plugins someone would like to install so I can’t have hard-coded list.

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.

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