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

**URL:** <https://forum.ansible.com/t/pulling-an-rpm-via-a-url-and-installing-it-what-am-i-doing-wrong/21569>\
**Category:** Ansible Project\
**Tags:** rhel\
**Created:** [May 25, 2016, 8:58pm UTC](https://forum.ansible.com/t/pulling-an-rpm-via-a-url-and-installing-it-what-am-i-doing-wrong/21569 "2016-05-25T20:58:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adam\_Morris](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@Adam\_Morris](https://forum.ansible.com/u/Adam_Morris)\
**Post date:** [May 25, 2016, 8:58pm UTC](https://forum.ansible.com/t/pulling-an-rpm-via-a-url-and-installing-it-what-am-i-doing-wrong/21569/1 "2016-05-25T20:58:24Z")

</div>

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-](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](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

yum install [https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm](https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm)  
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?

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [May 25, 2016, 9:06pm UTC](https://forum.ansible.com/t/pulling-an-rpm-via-a-url-and-installing-it-what-am-i-doing-wrong/21569/2 "2016-05-25T21:06:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Adam\_Morris](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@Adam\_Morris](https://forum.ansible.com/u/Adam_Morris)\
**Post date:** [May 25, 2016, 10:47pm UTC](https://forum.ansible.com/t/pulling-an-rpm-via-a-url-and-installing-it-what-am-i-doing-wrong/21569/3 "2016-05-25T22:47:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Stephen\_John\_Smoogen](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@Stephen\_John\_Smoogen](https://forum.ansible.com/u/Stephen_John_Smoogen)\
**Post date:** [May 25, 2016, 11:31pm UTC](https://forum.ansible.com/t/pulling-an-rpm-via-a-url-and-installing-it-what-am-i-doing-wrong/21569/4 "2016-05-25T23:31:54Z")

</div>

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](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](https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm)  
2) Then install the file.

---

<div class="post-metadata">

**Author:** ![Adam\_Morris](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@Adam\_Morris](https://forum.ansible.com/u/Adam_Morris)\
**Post date:** [May 26, 2016, 12:11am UTC](https://forum.ansible.com/t/pulling-an-rpm-via-a-url-and-installing-it-what-am-i-doing-wrong/21569/5 "2016-05-26T00:11:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [May 26, 2016, 8:37am UTC](https://forum.ansible.com/t/pulling-an-rpm-via-a-url-and-installing-it-what-am-i-doing-wrong/21569/6 "2016-05-26T08:37:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Adam\_Morris](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@Adam\_Morris](https://forum.ansible.com/u/Adam_Morris)\
**Post date:** [May 26, 2016, 4:25pm UTC](https://forum.ansible.com/t/pulling-an-rpm-via-a-url-and-installing-it-what-am-i-doing-wrong/21569/7 "2016-05-26T16:25:45Z")

</div>

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
