[Pull request] rpm module

Hi, I created the rpm module for ansible and sent a pull request at github.

https://github.com/ansible/ansible/pull/3938

The use cases for the rpm module are:

  • install a rpm to add a yum repository
  • install a rpm built with rpm-build

Will you take a look?
Thanks!

Hiroaki

The yum module can already take URLs for the package name (I’ve tested it with the EPEL RPM), I haven’t tried it with a local path but as mdehaan noted on the PR we would rather have the yum module extended rather than add another module that covers most of the same ground.

The yum module does work with local rpms.

- James

Hi, James

Thanks for trying it out.

I tried it myself too and I confirmed I can pass a url or a local file path to a rpm file to the name parameter of the yum module.

I think the yum module document should be updated that the name parameter can accept a url or a local file path to a rpm file.
What do you think?

Yes.

The yum module does work with local rpms.

Hmm, I’ve just had problems with that - XenServer 6.2, trying to install an RPM from a local file (as 'copy’ed over to the system). Didn’t want to play ball.

What version(s) of yum have you tested this with?

I’ve resorted to a command.

Cheers,

–Mark

On this topic, I’ve also just now had problems (using a very recent version of devel), which I suspect is the yum module trying to optimise things. The rpms have been downloaded to the target machine using a previous task, and there is a var ‘3rdparty_prereqs’ containing a list of rpm filenames (register:ed via another shell command). This definition amounts to: The failing task looks like this: It fails like this: It seems to be squashing the with_items into one run, passing a comma-delimited list of the filenames to yum as the item to install, losing the necessary paths. Converting the task to a debug shows two correctly constructed paths printed. Is there a way of supplying a path (or paths) to the yum module in cases like this? Also, how does apt handle this sort of thing? Thanks N

Hi Nick,

I had the same problem at past. A workaround I used was:

`

3rdparty_prereqs: [ {{download_dir}}/rpms/apples-1.0.el6.i686.rpm’, {{download_dir}}/rpms/oranges-1.0.el6.i686.rpm’ ]`

- name: install 3rd party prerequisites
action: yum name="{{item}}"'
with_items: 3rdparty_prereqs

But with ansible at github, your example should work.
Here is my playbook actually works.

``

You should only pass in “item” as the parameter in this case.

It’s actually not the yum module per se, but something higher up in with_items to group things into one transaction.

You can solve this by having the paths in the collection.

Yep, exactly!

Hi,

By looking a log with -vvv option with running my example,
I found yum are executed separetely for each rpm.

So it seems to be treated differently from your example.

I found this code does joining strings with comma if items is a list of strings.
https://github.com/ansible/ansible/blob/6e9fa5019f3d43500d6ad65bccf4291ffc550320/lib/ansible/runner/init.py#L456-L459

I’m not sure why you say it’s executed once per each RPM in the list.

Can you post an example and output of the playbook that would show this case?

Hi, Michael.

Here is a result of my playbook.
https://gist.github.com/hnakamur/6559322

tasks
https://github.com/hnakamur/ansible-playbooks/blob/master/roles/mysql/client/tasks/main.yml

variables
https://github.com/hnakamur/ansible-playbooks/blob/master/roles/mysql/client/vars/main.yml

I use a list of objects, not a list of strings, as items.

So this is an expected result and I’m happy with it.

This is probably because of the way you are using with_items.

Yes, you are right.

To sum it up, if we pass a list of strings to with_items, the yum module will run yum with all items at once.
If we pass a list of compound objects, the yum module will run yum for each item.