# Yum update on multiple hosts but using a cusom repo file

**URL:** <https://forum.ansible.com/t/yum-update-on-multiple-hosts-but-using-a-cusom-repo-file/32752>\
**Category:** Ansible Project\
**Created:** [April 22, 2020, 4:44am UTC](https://forum.ansible.com/t/yum-update-on-multiple-hosts-but-using-a-cusom-repo-file/32752 "2020-04-22T04:44:23Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quad\_Zero](https://avatars.discourse-cdn.com/v4/letter/q/eb9ed0/32.png) [@Quad\_Zero](https://forum.ansible.com/u/Quad_Zero)\
**Post date:** [April 22, 2020, 4:44am UTC](https://forum.ansible.com/t/yum-update-on-multiple-hosts-but-using-a-cusom-repo-file/32752/1 "2020-04-22T04:44:23Z")

</div>

G’day all Ansible gurus,

I am very new to Ansible and I am learning through youtube videos as I am enquiring about this problem. It might be a simple one to some of you guys:

So I have multiple servers on my System. I have a VM by the name of YUM which has all the updates (updates folder) on its /var/www/html folder so it can be referenced from other systems if it was done manually (which is what i have been doing until now).

How do I specify this folder in Ansible to all other hosts?

For eg:

if my YUM server has all its updates in  
[http://192.168.0.5/rhel6pathes/april/](http://192.168.0.5/rhel6pathes/april/)

how do i get the other servers to look at this location and update it from here?

Thank you so much.

---

<div class="post-metadata">

**Author:** ![Vivek\_Kothawale](https://avatars.discourse-cdn.com/v4/letter/v/ea666f/32.png) [@Vivek\_Kothawale](https://forum.ansible.com/u/Vivek_Kothawale)\
**Post date:** [April 22, 2020, 4:50am UTC](https://forum.ansible.com/t/yum-update-on-multiple-hosts-but-using-a-cusom-repo-file/32752/2 "2020-04-22T04:50:16Z")

</div>

Hi

You could use variable and reference that variable inside playbook.  
I this way you don’t have to repeat on call same path mutiple time instead you can call that variable.

Thanks,  
Vivek

---

<div class="post-metadata">

**Author:** ![Quad\_Zero](https://avatars.discourse-cdn.com/v4/letter/q/eb9ed0/32.png) [@Quad\_Zero](https://forum.ansible.com/u/Quad_Zero)\
**Post date:** [April 22, 2020, 4:52am UTC](https://forum.ansible.com/t/yum-update-on-multiple-hosts-but-using-a-cusom-repo-file/32752/3 "2020-04-22T04:52:53Z")

</div>

Vivek,

Could you actually show that to me in code? I am very new to this.

Thank you sir.

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [April 22, 2020, 5:03am UTC](https://forum.ansible.com/t/yum-update-on-multiple-hosts-but-using-a-cusom-repo-file/32752/4 "2020-04-22T05:03:37Z")

</div>

If you are really new then you are better off reading about the basics first, for instance

[https://docs.ansible.com/ansible/latest/user\_guide/intro\_getting\_started.html](https://docs.ansible.com/ansible/latest/user_guide/intro_getting_started.html)

This should give enough inspiration to get going with your task at hand.

---

<div class="post-metadata">

**Author:** ![Vivek\_Kothawale](https://avatars.discourse-cdn.com/v4/letter/v/ea666f/32.png) [@Vivek\_Kothawale](https://forum.ansible.com/u/Vivek_Kothawale)\
**Post date:** [April 22, 2020, 5:06am UTC](https://forum.ansible.com/t/yum-update-on-multiple-hosts-but-using-a-cusom-repo-file/32752/5 "2020-04-22T05:06:27Z")

</div>

Hi  
Could you please let me know how you doing it in manually ?

Thanks  
Vivek

---

<div class="post-metadata">

**Author:** ![Javi\_Legido](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@Javi\_Legido](https://forum.ansible.com/u/Javi_Legido)\
**Post date:** [April 22, 2020, 5:14am UTC](https://forum.ansible.com/t/yum-update-on-multiple-hosts-but-using-a-cusom-repo-file/32752/6 "2020-04-22T05:14:28Z")

</div>

Good morning.

You could concept ansible as the automated execution of commands through SSH connection to the target hosts.

If you want to keep your approach you could:

1. Expose the source files through SSHFS
2. Mount on each host above directory

All those tasks could be automated through ansible.

Cheers.

Javier

---

<div class="post-metadata">

**Author:** ![Quad\_Zero](https://avatars.discourse-cdn.com/v4/letter/q/eb9ed0/32.png) [@Quad\_Zero](https://forum.ansible.com/u/Quad_Zero)\
**Post date:** [April 22, 2020, 8:26am UTC](https://forum.ansible.com/t/yum-update-on-multiple-hosts-but-using-a-cusom-repo-file/32752/7 "2020-04-22T08:26:52Z")

</div>

Hi Vivek,

On each machine, I would run yum update on it. My repo file points to the server

[http://192.168.0.5/rhel6pathes/april/](http://192.168.0.5/rhel6pathes/april/)

Thank you.

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [April 22, 2020, 8:47am UTC](https://forum.ansible.com/t/yum-update-on-multiple-hosts-but-using-a-cusom-repo-file/32752/8 "2020-04-22T08:47:11Z")

</div>

> Hi Vivek,
> 
> On each machine, I would run yum update on it. My repo file points to the server  
> [http://192.168.0.5/rhel6pathes/april/](http://192.168.0.5/rhel6pathes/april/)

Give the yum\_repository module a try:

[https://docs.ansible.com/ansible/latest/modules/yum\_repository\_module.html](https://docs.ansible.com/ansible/latest/modules/yum_repository_module.html)

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Jack\_Morgan](https://avatars.discourse-cdn.com/v4/letter/j/b9bd4f/32.png) [@Jack\_Morgan](https://forum.ansible.com/u/Jack_Morgan)\
**Post date:** [April 22, 2020, 4:41pm UTC](https://forum.ansible.com/t/yum-update-on-multiple-hosts-but-using-a-cusom-repo-file/32752/9 "2020-04-22T16:41:21Z")

</div>

Hello,

Based on the situation you define below, it sounds like you are wanting  
to add a custom yum repository to some hosts. Let's look at how you  
could go about doing it.

(1) You will need to create a yum repository file on your hosts. This  
file will point to your custom repository on your Yum server. You can  
achieve that via ansible module(s) or just copy the yum repository file  
that you created to each host. You will need to do some research on how  
to do it. As others have pointed out, the yum module is a good place to  
start. I'm only offering two ways to achieve this step but there might  
be others strategies.

(2) You will need to have ansible update your systems. I'm including  
part of my upgrade playbook below to use as a reference (I'm on fedora  
so using dnf instead of yum). You can have your hosts defined in your  
ansible hosts file (/etc/ansible/hosts). I'm not sure your strategy for  
organizing your hosts as there is a lot to say here but again some  
investigation is needed.

Finally, you could combine step 1 and 2 into a single playbook to have  
them be two playbooks depending on your needs. I hope this is helpful.

---

<div class="post-metadata">

**Author:** ![Quad\_Zero](https://avatars.discourse-cdn.com/v4/letter/q/eb9ed0/32.png) [@Quad\_Zero](https://forum.ansible.com/u/Quad_Zero)\
**Post date:** [April 29, 2020, 5:53am UTC](https://forum.ansible.com/t/yum-update-on-multiple-hosts-but-using-a-cusom-repo-file/32752/10 "2020-04-29T05:53:45Z")

</div>

Thank you so much!!! 🙂
