|
|
@ -22,10 +22,10 @@ ANSIBLE_METADATA = {'status': ['preview'],
|
|
|
|
'supported_by': 'community',
|
|
|
|
'supported_by': 'community',
|
|
|
|
'metadata_version': '1.0'}
|
|
|
|
'metadata_version': '1.0'}
|
|
|
|
|
|
|
|
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
DOCUMENTATION = r'''
|
|
|
|
---
|
|
|
|
---
|
|
|
|
author:
|
|
|
|
author:
|
|
|
|
- "Alain Dejoux (@adejoux)"
|
|
|
|
- Alain Dejoux (@adejoux)
|
|
|
|
module: aix_lvol
|
|
|
|
module: aix_lvol
|
|
|
|
short_description: Configure AIX LVM logical volumes
|
|
|
|
short_description: Configure AIX LVM logical volumes
|
|
|
|
description:
|
|
|
|
description:
|
|
|
@ -42,83 +42,84 @@ options:
|
|
|
|
required: true
|
|
|
|
required: true
|
|
|
|
lv_type:
|
|
|
|
lv_type:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The type of the logical volume. Default to jfs2.
|
|
|
|
- The type of the logical volume.
|
|
|
|
|
|
|
|
default: jfs2
|
|
|
|
size:
|
|
|
|
size:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The size of the logical volume with one of the [MGT] units.
|
|
|
|
- The size of the logical volume with one of the [MGT] units.
|
|
|
|
copies:
|
|
|
|
copies:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- the number of copies of the logical volume. By default, 1 copy. Maximum copies are 3.
|
|
|
|
- The number of copies of the logical volume. Maximum copies are 3.
|
|
|
|
|
|
|
|
default: '1'
|
|
|
|
policy:
|
|
|
|
policy:
|
|
|
|
choices: [ "maximum", "minimum" ]
|
|
|
|
choices: [ maximum, minimum ]
|
|
|
|
default: maximum
|
|
|
|
default: maximum
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Sets the interphysical volume allocation policy. "maximum" allocates logical partitions across the maximum number of physical volumes.
|
|
|
|
- Sets the interphysical volume allocation policy. C(maximum) allocates logical partitions across the maximum number of physical volumes.
|
|
|
|
"minimum" allocates logical partitions across the minimum number of physical volumes.
|
|
|
|
C(minimum) allocates logical partitions across the minimum number of physical volumes.
|
|
|
|
state:
|
|
|
|
state:
|
|
|
|
choices: [ "present", "absent" ]
|
|
|
|
choices: [ absent, present ]
|
|
|
|
default: present
|
|
|
|
default: present
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Control if the logical volume exists. If C(present) and the
|
|
|
|
- Control if the logical volume exists. If C(present) and the
|
|
|
|
volume does not already exist then the C(size) option is required.
|
|
|
|
volume does not already exist then the C(size) option is required.
|
|
|
|
opts:
|
|
|
|
opts:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Free-form options to be passed to the mklv command
|
|
|
|
- Free-form options to be passed to the mklv command.
|
|
|
|
pvs:
|
|
|
|
pvs:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Comma separated list of physical volumes e.g. hdisk1,hdisk2
|
|
|
|
- Comma separated list of physical volumes e.g. C(hdisk1,hdisk2).
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
|
|
|
EXAMPLES = r'''
|
|
|
|
# Create a logical volume of 512M.
|
|
|
|
- name: Create a logical volume of 512M
|
|
|
|
- aix_lvol:
|
|
|
|
aix_lvol:
|
|
|
|
vg: testvg
|
|
|
|
vg: testvg
|
|
|
|
lv: testlv
|
|
|
|
lv: testlv
|
|
|
|
size: 512M
|
|
|
|
size: 512M
|
|
|
|
|
|
|
|
|
|
|
|
# Create a logical volume of 512M with disks hdisk1 and hdisk2
|
|
|
|
- name: Create a logical volume of 512M with disks hdisk1 and hdisk2
|
|
|
|
- aix_lvol:
|
|
|
|
aix_lvol:
|
|
|
|
vg: testvg
|
|
|
|
vg: testvg
|
|
|
|
lv: test2lv
|
|
|
|
lv: test2lv
|
|
|
|
size: 512M
|
|
|
|
size: 512M
|
|
|
|
pvs: hdisk1,hdisk2
|
|
|
|
pvs: hdisk1,hdisk2
|
|
|
|
|
|
|
|
|
|
|
|
# Create a logical volume of 512M mirrored.
|
|
|
|
- name: Create a logical volume of 512M mirrored
|
|
|
|
- aix_lvol:
|
|
|
|
aix_lvol:
|
|
|
|
vg: testvg
|
|
|
|
vg: testvg
|
|
|
|
lv: test3lv
|
|
|
|
lv: test3lv
|
|
|
|
size: 512M
|
|
|
|
size: 512M
|
|
|
|
copies: 2
|
|
|
|
copies: 2
|
|
|
|
|
|
|
|
|
|
|
|
# Create a logical volume of 1G with a minimum placement policy .
|
|
|
|
- name: Create a logical volume of 1G with a minimum placement policy
|
|
|
|
- aix_lvol:
|
|
|
|
aix_lvol:
|
|
|
|
vg: rootvg
|
|
|
|
vg: rootvg
|
|
|
|
lv: test4lv
|
|
|
|
lv: test4lv
|
|
|
|
size: 1G
|
|
|
|
size: 1G
|
|
|
|
policy: minimum
|
|
|
|
policy: minimum
|
|
|
|
|
|
|
|
|
|
|
|
# Create a logical volume with special options like mirror pool
|
|
|
|
- name: Create a logical volume with special options like mirror pool
|
|
|
|
- aix_lvol:
|
|
|
|
aix_lvol:
|
|
|
|
vg: testvg
|
|
|
|
vg: testvg
|
|
|
|
lv: testlv
|
|
|
|
lv: testlv
|
|
|
|
size: 512M
|
|
|
|
size: 512M
|
|
|
|
opts: -p copy1=poolA -p copy2=poolB
|
|
|
|
opts: -p copy1=poolA -p copy2=poolB
|
|
|
|
|
|
|
|
|
|
|
|
# Extend the logical volume to 1200M.
|
|
|
|
- name: Extend the logical volume to 1200M
|
|
|
|
- aix_lvol:
|
|
|
|
aix_lvol:
|
|
|
|
vg: testvg
|
|
|
|
vg: testvg
|
|
|
|
lv: test4lv
|
|
|
|
lv: test4lv
|
|
|
|
size: 1200M
|
|
|
|
size: 1200M
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Remove the logical volume
|
|
|
|
# Remove the logical volume.
|
|
|
|
aix_lvol:
|
|
|
|
- aix_lvol:
|
|
|
|
|
|
|
|
vg: testvg
|
|
|
|
vg: testvg
|
|
|
|
lv: testlv
|
|
|
|
lv: testlv
|
|
|
|
state: absent
|
|
|
|
state: absent
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
RETURN = '''
|
|
|
|
RETURN = r'''
|
|
|
|
msg:
|
|
|
|
msg:
|
|
|
|
type: string
|
|
|
|
type: string
|
|
|
|
description: A friendly message describing the task result.
|
|
|
|
description: A friendly message describing the task result.
|
|
|
@ -126,15 +127,16 @@ msg:
|
|
|
|
sample: Logical volume testlv created.
|
|
|
|
sample: Logical volume testlv created.
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
|
|
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def convert_size(module, size):
|
|
|
|
def convert_size(module, size):
|
|
|
|
unit = size[-1].upper()
|
|
|
|
unit = size[-1].upper()
|
|
|
|
units = ['M', 'G', 'T']
|
|
|
|
units = ['M', 'G', 'T']
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
multiplier = 1024**units.index(unit)
|
|
|
|
multiplier = 1024 ** units.index(unit)
|
|
|
|
except ValueError:
|
|
|
|
except ValueError:
|
|
|
|
module.fail_json(msg="No valid size unit specified.")
|
|
|
|
module.fail_json(msg="No valid size unit specified.")
|
|
|
|
|
|
|
|
|
|
|
@ -208,14 +210,14 @@ def parse_vg(data):
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
module = AnsibleModule(
|
|
|
|
module = AnsibleModule(
|
|
|
|
argument_spec=dict(
|
|
|
|
argument_spec=dict(
|
|
|
|
vg=dict(required=True, type='str'),
|
|
|
|
vg=dict(type='str', required=True),
|
|
|
|
lv=dict(required=True, type='str'),
|
|
|
|
lv=dict(type='str', required=True),
|
|
|
|
lv_type=dict(default='jfs2', type='str'),
|
|
|
|
lv_type=dict(type='str', default='jfs2'),
|
|
|
|
size=dict(type='str'),
|
|
|
|
size=dict(type='str'),
|
|
|
|
opts=dict(default='', type='str'),
|
|
|
|
opts=dict(type='str', default=''),
|
|
|
|
copies=dict(default='1', type='str'),
|
|
|
|
copies=dict(type='str', default='1'),
|
|
|
|
state=dict(choices=["absent", "present"], default='present'),
|
|
|
|
state=dict(type='str', default='present', choices=['absent', 'present']),
|
|
|
|
policy=dict(choices=["maximum", "minimum"], default='maximum'),
|
|
|
|
policy=dict(type='str', default='maximum', choices=['maximum', 'minimum']),
|
|
|
|
pvs=dict(type='list', default=list())
|
|
|
|
pvs=dict(type='list', default=list())
|
|
|
|
),
|
|
|
|
),
|
|
|
|
supports_check_mode=True,
|
|
|
|
supports_check_mode=True,
|
|
|
|