Yum update on multiple hosts but using a cusom repo file

17 views
Skip to first unread message

Quad Zero

unread,
Apr 22, 2020, 12:44:23 AM4/22/20
to Ansible Project
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 

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

Thank you so much.



Vivek Kothawale

unread,
Apr 22, 2020, 12:50:52 AM4/22/20
to ansible...@googlegroups.com
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

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ad7b76e9-6307-46f4-936a-b5cbfc7302e0%40googlegroups.com.

Quad Zero

unread,
Apr 22, 2020, 12:52:53 AM4/22/20
to Ansible Project
Vivek,

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

Thank you sir.


On Wednesday, April 22, 2020 at 2:50:52 PM UTC+10, Vivek Kothawale wrote:
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

On Wed, Apr 22, 2020, 10:14 AM Quad Zero <quad...@gmail.com> wrote:
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 

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

Thank you so much.



--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.

Dick Visser

unread,
Apr 22, 2020, 1:04:08 AM4/22/20
to ansible...@googlegroups.com
If you are really new then you are better off reading about the basics first, for instance 

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



To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f0395e8d-460c-4d75-9340-8d7ce6fa1562%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Vivek Kothawale

unread,
Apr 22, 2020, 1:06:57 AM4/22/20
to ansible...@googlegroups.com
Hi  
Could you please let me know how you doing it in manually ?

Thanks
Vivek

Javi Legido

unread,
Apr 22, 2020, 1:15:20 AM4/22/20
to ansible...@googlegroups.com
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

Quad Zero

unread,
Apr 22, 2020, 4:27:17 AM4/22/20
to ansible...@googlegroups.com
Hi Vivek,

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

Thank you.

Stefan Hornburg (Racke)

unread,
Apr 22, 2020, 4:47:39 AM4/22/20
to ansible...@googlegroups.com
On 4/22/20 10:26 AM, Quad Zero wrote:
> 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/

Give the yum_repository module a try:

https://docs.ansible.com/ansible/latest/modules/yum_repository_module.html

Regards
Racke

>
> Thank you.
>
> On Wed, Apr 22, 2020 at 3:06 PM Vivek Kothawale <vkkot...@gmail.com <mailto:vkkot...@gmail.com>> wrote:
>
> Hi  
> Could you please let me know how you doing it in manually ?
>
> Thanks
> Vivek
>
> <https://groups.google.com/d/msgid/ansible-project/ad7b76e9-6307-46f4-936a-b5cbfc7302e0%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/f0395e8d-460c-4d75-9340-8d7ce6fa1562%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/f0395e8d-460c-4d75-9340-8d7ce6fa1562%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> Sent from a mobile device - please excuse the brevity, spelling and punctuation.
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwNnBttcaDzpfVE%3DQt46s9oAUHuE6Sk6T%2BECz4Y9rgAoEg%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAL8fbwNnBttcaDzpfVE%3DQt46s9oAUHuE6Sk6T%2BECz4Y9rgAoEg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAA420E9KgDDWSo5vYgmpqhT6AvA3hLKxjRAiStWHF6ZFKJhZfg%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAA420E9KgDDWSo5vYgmpqhT6AvA3hLKxjRAiStWHF6ZFKJhZfg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAKr7FntkWu3ntYXAu0V61%3DxMo-OyhXrz%3Df%2BqjzCDGkS5uYow8g%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAKr7FntkWu3ntYXAu0V61%3DxMo-OyhXrz%3Df%2BqjzCDGkS5uYow8g%40mail.gmail.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc

Jack Morgan

unread,
Apr 22, 2020, 12:41:43 PM4/22/20
to ansible...@googlegroups.com
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.

---

- hosts: fedora
  tasks:
  - name: UPDATE | upgrade packages
    dnf:
      name: "*"
      state: latest

  - name: UPDATE | check if reboot is needed due to new kernel
    shell: if [ $(rpm -q kernel|tail -n 1) != kernel-$(uname -r) ]; then
echo 'reboot'; else echo 'no'; fi
    register: reboot_hint

  - name: UPDATE | rebooting host...
    shell: shutdown -r now "Reboot required for updated kernel"
    async: 1
    poll: 0
    when: reboot_hint.stdout.find("reboot") != -1

  - name: UPDATE | wait for host to reboot...
    wait_for_connection:
      connect_timeout: 20
      sleep: 5
      delay: 5
      timeout: 300
    when: reboot_hint.stdout.find("reboot") != -1

  - name: UPDATE | remove unused packages
    dnf:
      autoremove: yes
--
Jack Morgan


signature.asc

Quad Zero

unread,
Apr 29, 2020, 1:54:12 AM4/29/20
to ansible...@googlegroups.com
Thank you so much!!! :)

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1ae55ac5-4443-bdb7-c72f-2831ba2a7434%40jento.io.
Reply all
Reply to author
Forward
0 new messages