2.1 KiB
EX294 9.1: Packages and repositories
Give the managed nodes their repositories, install packages and a group on the right hosts, and bring the web servers up to date.
Before you start
This VM is the control node. The lab creates the user greg (password
Lab-Pass-1) with an SSH key, and installs ansible-core. Work as greg,
in /home/greg/ansible: its ansible.cfg reads the inventory inventory,
logs in as devops and becomes root. node1 is in the group webservers
and node2 in dbservers.
The managed nodes node1 (10.99.1.11) and node2 (10.99.1.12) are
AlmaLinux 10 containers, prepared as in chapter 3.1: devops takes greg's
key and may use sudo without a password, so ansible all -m ping works
straight away. The lab has taken away every repository on both nodes
(the old files are in /root/repos.orig), and left one package on node1
a version behind. For a root shell on a node, sudo podman exec -it node1 bash.
Tasks
- Configure BaseOS and AppStream repositories on every node, with
signature checking, from URLs you choose (the AlmaLinux 10 mirrors at
https://repo.almalinux.org/almalinux/10/, for example).dnf repoliston each node lists both, anddnf installworks. - In one playbook, install a package group on the database servers, and
phpandmariadbon the web servers. - Upgrade every package on the web servers, so
dnf check-updatethere finds nothing to update.
Hints
ansible.builtin.yum_repositorywithbaseurl,gpgcheck: trueandgpgkey;ansible.builtin.rpm_keyimports the key. The key is athttps://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux-10.rpm_keyneedsgpg2; the lab installedgnupg2on the nodes before it took their repositories away.- A group is
name: "@Group Name"inansible.builtin.dnf;dnf group list --hiddenon a node shows the names. A group of only optional packages installs nothing. name: "*"withstate: latestupdates everything.- Check with
ansible all -a 'dnf repolist'andansible webservers -a 'rpm -q php mariadb'.