LVM Facts Overview
LVM Facts Overview
LVM Facts is a module that reports Logical Volume Manager (LVM) information as facts. It lists and reports details about defined AIX LVM components such as Physical Volumes (PVs
LVs
VGs
PVs
LVs
VGs
ansible_facts
lsvg
lspv
VGs
PVs
LVs
ansible_facts
How to Use LVM Facts
This example shows how to gather all LVM facts, VG facts, update PV facts to existing LVM facts, and gather LV facts using the lvm_facts
The following code demonstrates how to gather all LVM facts, VG facts, update PV facts to existing LVM facts, and gather LV facts using the lvm_facts
- name: Gather all lvm facts
lvm_facts:
- name: Gather VG facts
lvm_facts:
name: all
component: vg
- name: Update PV facts to existing LVM facts
lvm_facts:
name: all
component: pv
lvm: "{{ ansible_facts.LVM }}"
- name: Gather LV facts
lvm_facts:
name: all
component: lv
'''
Main Functions
There are several main functions in this module. Some of them are load_pvs
parse_pvs
load_vgs
parse_vgs
load_lvs
parse_lvs
load_pvs
load_pvs
The load_pvs
PVs
lspv
The load_pvs
PVs
lspv
def load_pvs(module, name, LVM):
"""
Get the details for the specified PV or all
arguments:
module (dict): Ansible module argument spec.
name (str): physical volume name.
LVM (dict): LVM facts.
return:
warnings (list): List of warning messages
LVM (dict): LVM facts
"""
warnings = []
cmd = "lspv"
rc, stdout, stderr = module.run_command(cmd)
if rc != 0:
warnings.append(
f"Command failed. cmd={cmd} rc={rc} stdout={stdout} stderr={stderr}")
else:
for ln in stdout.splitlines():
fields = ln.split()
pv = fields[0]
parse_pvs
parse_pvs
The parse_pvs
lspv
load_vgs
load_vgs
The load_vgs
VGs
lsvg
The load_vgs
VGs
lsvg
def load_vgs(module, name, LVM):
"""
Get the details for the specified VG or all
arguments:
module (dict): Ansible module argument spec.
name (str): volume group name.
LVM (dict): LVM facts.
return:
warnings (list): List of warning messages
LVM (dict): LVM facts
"""
warnings = []
cmd = "lsvg"
rc, stdout, stderr = module.run_command(cmd)
if rc != 0:
warnings.append(f"Command failed. cmd={cmd} rc={rc} stdout={stdout} stderr={stderr}")
else:
for ln in stdout.splitlines():
vg = ln.split()[0].strip()
if (name != 'all' and name != vg):
continue
load_lvs
load_lvs
The load_lvs
LVs
lsvg -l
The load_lvs
LVs
lsvg -l
def load_lvs(module, name, LVM):
"""
Get the details for the specified LV or all
arguments:
module (dict): Ansible module argument spec.
name (str): logical volume name.
LVM (dict): LVM facts.
return:
warnings (list): List of warning messages
LVM (dict): LVM facts
"""
warnings = []
cmd = "lsvg"
rc, stdout, stderr = module.run_command(cmd)
if rc != 0:
warnings.append(f"Command failed. cmd={cmd} rc={rc} stdout={stdout} stderr={stderr}")
else:
for line in stdout.splitlines():
vg = line.split()[0].strip()
cmd = f"lsvg -l { vg }"
rc, stdout, stderr = module.run_command(cmd)
This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human