Bootstrap FreeKB - Ansible - Manage LVM volume groups using the lvg module
Ansible - Manage LVM volume groups using the lvg module

Updated:   |  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 Buy Me A Coffee



Comments


Add a Comment


Please enter aa6aee in the box below so that we can be sure you are a human.