d_little.ansible_role_aix_lvm
ansible-role-aix-lvm
Notice: This role is still being developed. Not suitable for production use at this time.
This is an Ansible role for managing Volume Groups, Logical Volumes, and Filesystems on AIX Servers. It is mainly designed for setting up new environments. Although it can extend individual filesystems, it's not the best tool for that task. It works well for defining Volume Groups (VGs), Logical Volumes (LVs), and Filesystems (FSs) on the target host using multiple Physical Volumes (PVs). This role is based on the great ansible-manage-lvm role by @mrlesmithjr.
NOTE:
- Can create and delete LVM Groups and volumes.
- Currently, it's not reliable for resizing or modifying volumes since it's not fully tested.
- It's designed for defining a complete environment; not for creating temporary LVs or FSs.
- The main use case is to set up storage on an AIX server during the initial setup.
- Currently does not support Remote/NFS mount points.
- If you have an 'overmounted' filesystem, it will fail because the
aix_filesystem
module does not create the directory when mounting.
- For example, if
/foo/
and/foo/bar/
are both filesystems and/foo/
is mounted, the/foo/bar/
directory will not be found when trying to mount it.
Requirements
You must identify the devices or disks that will be part of the LVM setup before using this role.
NOTE:
- Make sure to choose the correct devices or disks.
- To create a VG without creating LVs, set
lvname
toNone
, as shown in the example below.
Role Variable Structure
We define a list of dictionaries that describe the required VGs.
Variables | Default | Comments |
---|---|---|
manage_lvm |
false |
Safety check to ensure this role should be run. If false , LVM will not be managed by this role. |
vglist (required) |
- | A list of vglist objects, defined below. |
vglist
Here's an overview of vglist
options. Defaults follow the aix_lvg module documentation. Note: Default values in this role will always use the module defaults; if those change, this document may not reflect the updates. Please report if there are changes.
Variables | Default | Comments |
---|---|---|
vgname (required) |
- | Name of the VG. |
disks (required) |
- | List of names of PV devices. |
force |
false |
Forcefully create VG. |
ppsize |
- | Size of the VG Physical Partitions. |
state |
present |
Either absent or present . If absent , all FSs and LVs must be removed first. |
vg_type |
normal |
Type of VG: big , normal , or scalable . |
lvlist |
- | List of lvlist objects defined below. |
lvlist
Here's an overview of lvlist
options, which can be defined within the vglist
object above. Defaults are based on the aix_lvol module documentation and aix_filesystem. This role follows best practices by creating the parent LV before every FS. Note: This document may not have up-to-date default values if the corresponding modules change, so please report any discrepancies.
Variables | Default | Comments |
---|---|---|
lvname (required) |
- | Name of the LV. |
lvstate |
present |
Either present or absent . If absent , the LV and any associated FS will be removed. |
lvcopies |
1 |
Number of copies for the LV. Max is 3. |
lvtype |
jfs2 |
Type of LV to create: [jfs2 , jfs , paging , etc.]. |
lvopts |
- | Options for creating the LV. |
lvpolicy |
maximum |
Allocation policy, either maximum or minimum . |
lvpvs |
- | List of which PVs to use in the VG. |
lvsize |
- | Size of the logical volume. |
fsaccount_subsystem |
false |
Whether the FS is processed by the accounting subsystem. Boolean. |
fsattributes |
"agblksize='4096',isnapshot='no'" |
Attributes for the filesystem, separated by commas. |
fsauto_mount |
false |
Whether the filesystem is automatically mounted at restart. |
fsfilesystem |
- | The directory where the filesystem will be mounted. Required if fsstate is not absent . |
fsstate |
present |
Either present , absent , mounted , or unmounted . Set fsstate to absent to create an LV with no attached FS. |
fsmount_group |
- | FS mount group. |
fspermissions |
rw |
FS permissions; can be rw or ro . |
Dependencies
None
Example Playbooks
Simple Experimental VG
---
- hosts: test-nodes
vars:
manage_lvm: true
vglist:
- vgname: vg_exp1
disks:
- hdisk4
force: true
lvlist:
- lvname: lv_exp1
lvcopies: 1
lvsize: 5G
fsauto_mount: true
fsstate: mounted
fsfilesystem: /mnt/exp1
- lvname: lv_exp2
lvcopies: 1
lvsize: 10G
fsauto_mount: true
fsstate: mounted
fsfilesystem: /mnt/exp2
roles:
- role: d-little.aixlvm
tasks:
One VG with Multiple LVs
Note: This is a typical use case for this role.
---
- hosts: test-nodes
vars:
manage_lvm: true
vglist:
- vgname: vg_test1
disks:
- hdisk10
- hdisk11
lvlist:
- lvname: lv_test1_1
lvcopies: 2
lvsize: 5G
fsauto_mount: true
fsstate: mounted
fsfilesystem: /mnt/test1_1
- lvname: lv_test1_2
lvcopies: 2
lvsize: 10G
fsauto_mount: true
fsstate: mounted
fsfilesystem: /mnt/test1_2
roles:
- role: d-little.aixlvm
tasks:
Empty VGs Without LVs
---
- hosts: test-nodes
vars:
manage_lvm: true
vglist:
- vgname: vg_test2_1
disks:
- hdisk20
- hdisk21
lvlist:
None
- vgname: vg_test2_2
disks:
- hdisk22
- hdisk23
lvlist:
None
roles:
- role: d-little.aixlvm
tasks:
One VG, One LV, All Variables Set
This is not a typical use case, but useful if you want to customize everything.
---
- hosts: test-nodes
vars:
manage_lvm: true
vglist:
- vgname: vg_test3
force: true
disks:
- hdisk30
- hdisk31
ppsize: 128
state: present
vg_type: big
lvlist:
- lvname: lv_test3
lvstate: present
lvcopies: 2
lvopts: aaaa
lvpolicy: maximum
lvpvs: hdisk30, hdisk31
lvsize: 50G
fsaccount_subsystem: false
fsattributes: aaaaa
fsauto_mount: true
fsfilesystem: /mnt/test3_1
fsstate: mounted
fsmount_group: aaaa
fspermissions: rw
roles:
- role: ansible-manage-lvm
tasks:
Authors
- David Little - Initial work - d-little
License
MIT
Acknowledgments
- Larry Smith Jr. - mrlesmithjr
- Ansible
Role to manage LVM Groups/Logical Volumes on IBM AIX. Can be used to create, extend ~or resize~ VGs, LVs, and FSs.
ansible-galaxy install d_little.ansible_role_aix_lvm