nerdexam
Red_Hat

EX294 · Question #9

09. Creating and Using Logical Volumes Create a playbook named /home/greg/ansible/lv.yml that will run on all managed nodes to perform the following tasks: Create a logical volume that meets the…

This playbook creates and formats a logical volume with specific size requirements, including fallback logic and error messages, without mounting it.

Submitted by neha2k· Apr 18, 2026Use Ansible Modules for System Administration

Question

  1. Creating and Using Logical Volumes Create a playbook named /home/greg/ansible/lv.yml that will run on all managed nodes to perform the following tasks: Create a logical volume that meets the following requirements: - The logical volume is created in the research volume group. - The size of the logical volume is 1500 MiB. - Format the logical volume using the ext4 file system. - If unable to create the requested size for the logical volume, display an error message and fallback to using a size of 800MiB. - Could not create logical volume of that size - Display an error message if the volume group research does not exist. - Volume group does not exist - Do not mount the logical volume in any way. Correct Answer: See the below explanation Explanation Explanation/Reference: Solution: [greg@control ansible]$ ansible-navigator doc community.general.lvol -m stdout [greg@control ansible]$ ansible-navigator doc community.general.filesystem -m stdout [greg@control ansible]$ ansible-doc debug [greg@control ansible]$ ansible-doc stat [greg@control ansible]$ vim /home/greg/ansible/lv.yml --- - name: Create LVM hosts: all tasks: - block: - name: lv 1500M community.general.lvol: vg: research lv: data size: 1500 - name: Create ext4 community.general.filesystem: fstype: ext4 dev: /dev/research/data rescue: - name: Could not create lvm ansible.builtin.debug: msg: Could not create logical volume of that size - name: lv 800M community.general.lvol: vg: research lv: data size: 800 - name: Create ext4 community.general.filesystem: fstype: ext4 dev: /dev/research/data when: ansible_lvm.vgs.research is defined - debug: msg: Volume group done not exist when: ansible_lvm.vgs.research is not defined [greg@control ansible]$ ansible-navigator run /home/greg/ansible/lv.yml -m stdout # Observing the execution process of the Ansible playbook to determine if it meets the requirements, and combining it with the 'blkid' command for verification (mandatory operation). [greg@control ansible]$ ansible all -m shell -a 'lvs' [greg@control ansible]$ ansible all -m shell -a 'blkid /dev/research/data'

Explanation

This playbook creates and formats a logical volume with specific size requirements, including fallback logic and error messages, without mounting it.

Concept tested. Logical Volume Management (LVM) with Ansible

Reference. https://docs.ansible.com/ansible/latest/collections/community/general/lvol_module.html

Topics

#LVM Management#Ansible Playbooks#Error Handling#Conditional Logic

Community Discussion

No community discussion yet for this question.

Full EX294 Practice