# Install rpm from control machine to ansible managed hosts

**URL:** <https://forum.ansible.com/t/install-rpm-from-control-machine-to-ansible-managed-hosts/18154>\
**Category:** Ansible Project\
**Created:** [May 4, 2015, 7:55am UTC](https://forum.ansible.com/t/install-rpm-from-control-machine-to-ansible-managed-hosts/18154 "2015-05-04T07:55:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![satheesh\_kumar](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@satheesh\_kumar](https://forum.ansible.com/u/satheesh_kumar)\
**Post date:** [May 4, 2015, 7:55am UTC](https://forum.ansible.com/t/install-rpm-from-control-machine-to-ansible-managed-hosts/18154/1 "2015-05-04T07:55:50Z")

</div>

I tried to install rpm in ansible control machine to target machines using playbook

- name: Install local rpm in server  
yum: pkg=files/mod\_jk-1.2.40-5.el6.x86\_64.rpm state=present  
when: ansible\_os\_family == ‘RedHat’

I got error :  
failed: [[xyz.cloudapp.net](http://xyz.cloudapp.net)] =\> {“changed”: false, “failed”: true, “rc”: 0, “results”: }  
msg: No Package file matching ‘files/mod\_jk-1.2.40-5.el6.x86\_64.rpm’ found on system

When I copied the same file in server and installed as local installation it works.

- name: copy mod\_jk rpm to server  
copy: src=files/mod\_jk-1.2.40-5.el6.x86\_64.rpm dest=/home/user/mod\_jk-1.2.40-5.el6.x86\_64.rpm owner=user group=azureuser mode=755  
when: ansible\_os\_family == ‘RedHat’

- name: Install mod\_jk local rpm in server  
yum: name=/home/user/mod\_jk-1.2.40-5.el6.x86\_64.rpm state=present  
when: ansible\_os\_family == ‘RedHat’

Is there a way to directly install from control machine without copying it

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [May 4, 2015, 7:39pm UTC](https://forum.ansible.com/t/install-rpm-from-control-machine-to-ansible-managed-hosts/18154/2 "2015-05-04T19:39:33Z")

</div>

no, currently the yum module only operates with files already on the  
remote machine.

---

<div class="post-metadata">

**Author:** ![satheesh\_kumar](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@satheesh\_kumar](https://forum.ansible.com/u/satheesh_kumar)\
**Post date:** [May 5, 2015, 6:43am UTC](https://forum.ansible.com/t/install-rpm-from-control-machine-to-ansible-managed-hosts/18154/3 "2015-05-05T06:43:43Z")

</div>

Thanks !

---

<div class="post-metadata">

**Author:** ![Sam\_Hartsfield](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@Sam\_Hartsfield](https://forum.ansible.com/u/Sam_Hartsfield)\
**Post date:** [May 6, 2015, 9:40pm UTC](https://forum.ansible.com/t/install-rpm-from-control-machine-to-ansible-managed-hosts/18154/4 "2015-05-06T21:40:20Z")

</div>

I’m installing packages from the control machine, but it’s a bit of work (so it probably won’t be worth it for just a few packages), and I’m still figuring out the details.

Basically, I create a local yum repository, then temporarily run an HTTP server on the control machine (maybe with Ansible 2.0 I can reliably start and kill it as part of the playbook, but right now it’s a manual process); for example using “python -m SimpleHTTPServer 8000”

I set the host to the control server using the SSH\_CLIENT environment variable (if there’s a better way to access that, I’d like to know):

`  
yum\_local\_host: “{{ (ansible\_connection is defined and ansible\_connection == ‘local’) | ternary(‘localhost’, ansible\_env.SSH\_CLIENT.split()[0]) }}”  
yum\_local\_port: 8000  
yum\_repo\_base: “http://{{ yum\_local\_host }}:{{ yum\_local\_port }}”

`

Then I use templates to set up the repositories on the remote side. Currently I’m looking at using a custom yum.conf so that it doesn’t interfere with the normal configuration.

If anyone wants more details, or has suggestions for how to improve this setup, let me know.

---

<div class="post-metadata">

**Author:** ![Reza\_Ghafari](https://avatars.discourse-cdn.com/v4/letter/r/b77776/32.png) [@Reza\_Ghafari](https://forum.ansible.com/u/Reza_Ghafari)\
**Post date:** [May 26, 2017, 3:51am UTC](https://forum.ansible.com/t/install-rpm-from-control-machine-to-ansible-managed-hosts/18154/5 "2017-05-26T03:51:58Z")

</div>

Is this still the case in ansible 2.2? The module document is not really clear.
