Skip to content

Commit 53d35c3

Browse files
committed
Applied cosmetic changes
1 parent 4995718 commit 53d35c3

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

plugins/modules/lvm_pv.py

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,38 @@
1313
---
1414
module: lvm_pv
1515
short_description: Manage LVM Physical Volumes
16-
version_added: "1.0.0"
16+
version_added: "10.7.0"
1717
description:
18-
- Creates, resizes or removes LVM Physical Volumes.
18+
- Creates, resizes or removes LVM Physical Volumes.
1919
author:
20-
- Klention Mali (@klention)
20+
- Klention Mali (@klention)
2121
options:
2222
device:
2323
description:
24-
- Path to the block device to manage.
24+
- Path to the block device to manage.
2525
type: str
2626
required: true
2727
state:
2828
description:
29-
- Control if the physical volume exists.
29+
- Control if the physical volume exists.
3030
type: str
3131
choices: [ present, absent ]
3232
default: present
3333
force:
3434
description:
35-
- Force dangerous operations (equivalent to C(pvcreate -f) or C(pvremove -ff)).
35+
- Force the operation.
36+
- When O(state=present) (creating a PV), this uses C(pvcreate -f) to force creation.
37+
- When O(state=absent) (removing a PV), this uses C(pvremove -ff) to force removal even if part of a volume group.
3638
type: bool
3739
default: false
3840
resize:
3941
description:
40-
- Resize PV to device size when O(state=present).
42+
- Resize PV to device size when O(state=present).
4143
type: bool
4244
default: false
4345
notes:
44-
- Requires LVM2 utilities installed on the target system.
45-
- Device path must exist when creating a PV.
46+
- Requires LVM2 utilities installed on the target system.
47+
- Device path must exist when creating a PV.
4648
'''
4749

4850
EXAMPLES = r'''
@@ -178,26 +180,19 @@ def main():
178180
if is_pv:
179181
if module.check_mode:
180182
changed = True
181-
actions.append('would be removed')
182-
else:
183-
cmd = ['pvremove']
183+
cmd = ['pvremove', '-y']
184184
if force:
185-
cmd.extend(['-ff', '-y'])
186-
else:
187-
cmd.append('-y')
185+
cmd.append('-ff')
186+
188187
cmd.append(device)
189-
rc, out, err = module.run_command(cmd)
190-
if rc != 0:
191-
module.fail_json(msg="Failed to remove PV: %s" % err)
192-
changed = True
188+
rc, out, err = module.run_command(cmd, check_rc=True)
193189
actions.append('removed')
194190

195191
# Generate final message
196-
if not actions:
197-
msg = "No changes needed for PV %s" % device
198-
else:
192+
if actions:
199193
msg = "PV %s: %s" % (device, ', '.join(actions))
200-
194+
else:
195+
msg = "No changes needed for PV %s" % device
201196
module.exit_json(changed=changed, msg=msg)
202197

203198

0 commit comments

Comments
 (0)