Pulling an RPM via a URL and installing it... What am I doing wrong?

175 views
Skip to first unread message

Adam Morris

unread,
May 25, 2016, 4:58:24 PM5/25/16
to Ansible Project
Greetings,

I have a playbook which includes this piece...

- name: Install the appropriate EPEL package for RHEL/OEL
  package: name="https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm" state=latest
  when: ansible_distribution == "RedHat" or ansible_distribution == "Oracle"

When run I get this error message

TASK [EPEL : Install the appropriate EPEL package for RHEL/OEL] ****************
fatal: [host]: FAILED! => {"changed": false, "failed": true, "msg": "No Package matching 'https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm' found available, installed or updated", "rc": 0, "results": []}

If I run it on the target server manually I get

Loaded plugins: product-id, search-disabled-repos, subscription-manager
epel-release-latest-7.noarch.rpm                         |  14 kB     00:00     
Examining /var/tmp/yum-root-NZVCS_/epel-release-latest-7.noarch.rpm: epel-release-7-6.noarch
Marking /var/tmp/yum-root-NZVCS_/epel-release-latest-7.noarch.rpm to be installed
Resolving Dependencies
blahblahblah

I'm running Ansible 2.0.2.0

Any ideas?



J Hawkesworth

unread,
May 25, 2016, 5:06:46 PM5/25/16
to Ansible Project
I think you can avoid this altogether.

I believe there's an epel-release package in the main yum repo which you can use to add EPEL to your yum sources (may not have the right terminology here).

- name: ADD EPEL release using a yum package to do so
  yum:
    name: epel-release
    state: present

Hope this helps,

Jon

Adam Morris

unread,
May 25, 2016, 6:47:05 PM5/25/16
to Ansible Project
Thanks Jon,

Unfortunately that package is available for CentOS not Red Hat Enterprise Linux or Oracle Enterprise Linux.

While it is unlikely that I will be installing many RPMs from a URL I would like to know why it isn't working here.

In my situation the real solution will be to set up my own local repositories and install from those but I am curious as to what I am doing wrong here.

Adam

Stephen John Smoogen

unread,
May 25, 2016, 7:33:11 PM5/25/16
to ansible...@googlegroups.com
I think it is telling you literally what is wrong. It is trying to
install a package named:
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
which it isn't finding in any of the yum repositories it knows about.
I think you need to do this in a two stage process.

1) Download the file from
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
2) Then install the file.

--
Stephen J Smoogen.

Adam Morris

unread,
May 25, 2016, 8:11:45 PM5/25/16
to Ansible Project
To quote from the module documentation page for yum...
Package name, or package specifier with version, like name-1.0. When using state=latest, this can be '*' which means run: yum -y update. You can also pass a url or a local path to a rpm file (using state=present). To operate on several packages this can accept a comma separated list of packages or (as of 2.0) a list of packages.

To me that suggests that that should work...

rereading this I spotted where I went wrong... With a URL you have to use state as present not latest. I have changed that and this works.

Thanks everyone.

Adam

Johannes Kastl

unread,
May 26, 2016, 4:37:49 AM5/26/16
to ansible...@googlegroups.com
On 25.05.16 22:58 Adam Morris wrote:

> - name: Install the appropriate EPEL package for RHEL/OEL
> package:
> name="https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{
> ansible_distribution_major_version }}.noarch.rpm" state=latest

> Any ideas?

What happens when you use state=present instead of latest? Latest
means it looks for newer version of the package, even if it is
installed. I think this could collide with installing from a url
(where no version info is available).

Johannes

signature.asc

Adam Morris

unread,
May 26, 2016, 12:25:45 PM5/26/16
to Ansible Project
Greetings Johannes,

I spotted that in the documentation and you are right.  For deployment from a URL you have to use state=present.  

Thanks for responding,
Adam
Reply all
Reply to author
Forward
0 new messages