Ansible - Manage LVM volume groups using the lvg module
by
Jeremy Canfield |
Updated: October 05 2023
| Ansible articles
If you are not familiar with modules, check out Ansible - Getting Started with Modules.
The lvg module can be used to:
- Create an LVM volume group
- Delete an LVM volume group
- Add or Remove physical volumes from a volume group
In this example, volume group vg001 is created, and physical volume /dev/sda1 is in the volume group.
---
- hosts: all
tasks:
- name: create LVM volume group vg001
lvg:
vg: vg001
pvs: /dev/sda1
pesize: 32
...
In this example, physical volume /dev/sdb1 is added to volume group vg001.
---
- hosts: all
tasks:
- name: add physical volume /dev/sdb1 to volume group vg001
lvg:
vg: vg001
pvs: /dev/sdb1
...
In this example, volume group vg001 is removed.
---
- hosts: all
tasks:
- name: remove LVM volume group vg001
lvg:
vg: vg001
state: absent
...
Did you find this article helpful?
If so, consider buying me a coffee over at