2.6 KiB
EX294 9.4: Storage and file systems
Partition a disk, make file systems and mount them for good, size a logical volume to what each host has room for, and let the storage system role do the same from variables.
Before you start
This VM is the control node, and here also the host with the disks:
localhost ansible_connection=local, in the inventory group storage.
The lab creates the user greg (password Lab-Pass-1, sudo without a
password) 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. The ansible.posix and
community.general collections and the system roles aren't installed
yet.
Spare disks on this VM, where the chapter has vdb and friends:
/dev/loop40, 2 GiB, for task 1/dev/loop41, 1 GiB, for task 2/dev/loop42, 2 GiB, for task 3
The managed node node1 (10.99.1.11, group nodes) is an AlmaLinux 10
container, prepared as in chapter 3.1: devops takes greg's key and may
use sudo without a password. A container has no disks of its own, so it
plays the host without the volume group. For a root shell there, sudo podman exec -it node1 bash.
Tasks
- On the storage hosts, create a 1 GiB partition on
/dev/loop40, put XFS on it, and mount it at/srv/archivepersistently.findmnt /srv/archiveshows it, also after a reboot. - Create the volume group
researchon/dev/loop41on the storage hosts. Then write/home/greg/ansible/lv.ymlfor all hosts: a 1500 MiB logical volumedatainresearchwhere it fits, an 800 MiB one with the message "Could not create logical volume of that size" where it doesn't, ext4 on it mounted at/mnt/data, and the message "Volume group does not exist" on hosts withoutresearch. Each host ends with the right size or message, andlvs researchagrees. - Use the storage system role to make a 1 GiB XFS logical volume on
/dev/loop42, mounted at/srv/web. Check withlsblkand/etc/fstab.
Hints
ansible-galaxy collection install ansible.posix 'community.general:>=11,<12': community.general 12 and later need a newer ansible-core than this one.community.general.parted(needs thepartedpackage here),community.general.filesystem,ansible.posix.mountwithstate: mounted. A partition of/dev/loop40is/dev/loop40p1.community.general.lvgandlvol;blockandrescuefor the smaller volume;ansible_facts['lvm']['vgs']says which hosts haveresearch.- The system roles come from the
rhel-system-rolespackage; instorage_pools, a disk is named likeloop42.