Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
789ae469
Commit
789ae469
authored
Jan 26, 2014
by
Stefan J. Betz
Committed by
Richard C Isaacson
Feb 24, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Require force for LVM shrink and remove operations in lvol. Fixes #5774
Conflicts: library/system/lvol
parent
05bf8075
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
library/system/lvol
+17
-3
No files found.
library/system/lvol
View file @
789ae469
...
@@ -47,6 +47,14 @@ options:
...
@@ -47,6 +47,14 @@ options:
description:
description:
- Control if the logical volume exists.
- Control if the logical volume exists.
required: false
required: false
force:
version_added: "1.5"
choices: [ "yes", "no" ]
default: "no"
description:
- Shrink or remove operations of volumes requires this switch. Ensures that
that filesystems get never corrupted/destroyed by mistake.
required: false
notes:
notes:
- Filesystems on top of the volume are not resized.
- Filesystems on top of the volume are not resized.
'''
'''
...
@@ -65,10 +73,10 @@ EXAMPLES = '''
...
@@ -65,10 +73,10 @@ EXAMPLES = '''
- lvol: vg=firefly lv=test size=1024
- lvol: vg=firefly lv=test size=1024
# Reduce the logical volume to 512m
# Reduce the logical volume to 512m
- lvol: vg=firefly lv=test size=512
- lvol: vg=firefly lv=test size=512
force=yes
# Remove the logical volume.
# Remove the logical volume.
- lvol: vg=firefly lv=test state=absent
- lvol: vg=firefly lv=test state=absent
force=yes
'''
'''
import
re
import
re
...
@@ -94,6 +102,7 @@ def main():
...
@@ -94,6 +102,7 @@ def main():
lv
=
dict
(
required
=
True
),
lv
=
dict
(
required
=
True
),
size
=
dict
(),
size
=
dict
(),
state
=
dict
(
choices
=
[
"absent"
,
"present"
],
default
=
'present'
),
state
=
dict
(
choices
=
[
"absent"
,
"present"
],
default
=
'present'
),
force
=
dict
(
type
=
'bool'
,
default
=
'no'
),
),
),
supports_check_mode
=
True
,
supports_check_mode
=
True
,
)
)
...
@@ -102,6 +111,7 @@ def main():
...
@@ -102,6 +111,7 @@ def main():
lv
=
module
.
params
[
'lv'
]
lv
=
module
.
params
[
'lv'
]
size
=
module
.
params
[
'size'
]
size
=
module
.
params
[
'size'
]
state
=
module
.
params
[
'state'
]
state
=
module
.
params
[
'state'
]
force
=
module
.
boolean
(
module
.
params
[
'force'
])
size_opt
=
'L'
size_opt
=
'L'
size_unit
=
'm'
size_unit
=
'm'
...
@@ -179,12 +189,14 @@ def main():
...
@@ -179,12 +189,14 @@ def main():
if
rc
==
0
:
if
rc
==
0
:
changed
=
True
changed
=
True
else
:
else
:
module
.
fail_json
(
msg
=
"Creating logical volume '
%
s' failed"
%
(
lv
)
,
rc
=
rc
,
err
=
err
)
module
.
fail_json
(
msg
=
"Creating logical volume '
%
s' failed"
%
lv
,
rc
=
rc
,
err
=
err
)
else
:
else
:
if
state
==
'absent'
:
if
state
==
'absent'
:
### remove LV
### remove LV
if
module
.
check_mode
:
if
module
.
check_mode
:
module
.
exit_json
(
changed
=
True
)
module
.
exit_json
(
changed
=
True
)
if
not
force
:
module
.
fail_json
(
msg
=
"Sorry, no removal of logical volume
%
s without force=yes."
%
(
this_lv
[
'name'
]))
rc
,
_
,
err
=
module
.
run_command
(
"lvremove --force
%
s/
%
s"
%
(
vg
,
this_lv
[
'name'
]))
rc
,
_
,
err
=
module
.
run_command
(
"lvremove --force
%
s/
%
s"
%
(
vg
,
this_lv
[
'name'
]))
if
rc
==
0
:
if
rc
==
0
:
module
.
exit_json
(
changed
=
True
)
module
.
exit_json
(
changed
=
True
)
...
@@ -199,6 +211,8 @@ def main():
...
@@ -199,6 +211,8 @@ def main():
if
size
>
this_lv
[
'size'
]:
if
size
>
this_lv
[
'size'
]:
tool
=
'lvextend'
tool
=
'lvextend'
elif
size
<
this_lv
[
'size'
]:
elif
size
<
this_lv
[
'size'
]:
if
not
force
:
module
.
fail_json
(
msg
=
"Sorry, no shrinking of
%
s without force=yes."
%
(
this_lv
[
'name'
]))
tool
=
'lvreduce --force'
tool
=
'lvreduce --force'
if
tool
:
if
tool
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment