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