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 (PVsLVsVGsPVsLVsVGsansible_factslsvglspvVGsPVsLVsansible_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_pvsparse_pvsload_vgsparse_vgsload_lvsparse_lvs
load_pvs
load_pvsThe load_pvsPVslspv
The load_pvsPVslspv
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_pvsThe parse_pvslspv
load_vgs
load_vgsThe load_vgsVGslsvg
The load_vgsVGslsvg
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_lvsThe load_lvsLVslsvg -l
The load_lvsLVslsvg -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