From 622e29b35b2deb88116d41add264b0a6ca0142f3 Mon Sep 17 00:00:00 2001 From: Amin Vakil Date: Fri, 26 Mar 2021 04:18:11 +0430 Subject: [PATCH 1/6] vdo: add force option --- plugins/modules/system/vdo.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/modules/system/vdo.py b/plugins/modules/system/vdo.py index 4049f82ed31..23fd1dcefa5 100644 --- a/plugins/modules/system/vdo.py +++ b/plugins/modules/system/vdo.py @@ -258,6 +258,15 @@ configured setting unless a different value is specified in the playbook. type: str + force: + description: + - When creating a volume, ignores any existing file system + or VDO signature already present in the storage device. + When stopping or removing a VDO volume, first unmounts + the file system stored on the device if mounted. + type: bool + default: no + version_added: 2.4.0 notes: - In general, the default thread configuration should be used. requirements: @@ -409,6 +418,9 @@ def add_vdooptions(params): if ('indexmode' in params) and (params['indexmode'] == 'sparse'): options.append("--sparseIndex=enabled") + if ('force' in params) and (params['force']): + options.append("--force") + # Entering an invalid thread config results in a cryptic # 'Could not set up device mapper for %s' error from the 'vdo' # command execution. The dmsetup module on the system will @@ -465,7 +477,8 @@ def run_module(): biothreads=dict(type='str'), cputhreads=dict(type='str'), logicalthreads=dict(type='str'), - physicalthreads=dict(type='str') + physicalthreads=dict(type='str'), + force=dict(type='bool', default=False) ) # Seed the result dictionary in the object. There will be an From ef5a6e7306ef9bb4d54ce052e1840f9711483c8b Mon Sep 17 00:00:00 2001 From: Amin Vakil Date: Fri, 26 Mar 2021 04:21:19 +0430 Subject: [PATCH 2/6] Add changelog --- changelogs/fragments/2110-vdo-add_force_option.yaml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelogs/fragments/2110-vdo-add_force_option.yaml diff --git a/changelogs/fragments/2110-vdo-add_force_option.yaml b/changelogs/fragments/2110-vdo-add_force_option.yaml new file mode 100644 index 00000000000..9e93a919a23 --- /dev/null +++ b/changelogs/fragments/2110-vdo-add_force_option.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - vdo - add ``force`` option (https://github.com/ansible-collections/community.general/issues/2101). From c295622f17858633949840f446aa37ece9ffc82c Mon Sep 17 00:00:00 2001 From: Amin Vakil Date: Fri, 26 Mar 2021 15:32:18 +0430 Subject: [PATCH 3/6] Improve the diff the next time something is added :) Co-authored-by: Felix Fontein --- plugins/modules/system/vdo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/system/vdo.py b/plugins/modules/system/vdo.py index 23fd1dcefa5..042eb19fa19 100644 --- a/plugins/modules/system/vdo.py +++ b/plugins/modules/system/vdo.py @@ -478,7 +478,7 @@ def run_module(): cputhreads=dict(type='str'), logicalthreads=dict(type='str'), physicalthreads=dict(type='str'), - force=dict(type='bool', default=False) + force=dict(type='bool', default=False), ) # Seed the result dictionary in the object. There will be an From d67edc5708cd1de06083ee379bf8dc8ae2860f9b Mon Sep 17 00:00:00 2001 From: Amin Vakil Date: Sat, 27 Mar 2021 01:11:31 +0430 Subject: [PATCH 4/6] Add warning text placeholder by felixfontein Co-authored-by: Felix Fontein --- plugins/modules/system/vdo.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/system/vdo.py b/plugins/modules/system/vdo.py index 042eb19fa19..5c8fa7c7c6b 100644 --- a/plugins/modules/system/vdo.py +++ b/plugins/modules/system/vdo.py @@ -264,6 +264,7 @@ or VDO signature already present in the storage device. When stopping or removing a VDO volume, first unmounts the file system stored on the device if mounted. + - "B(Warning:) ." type: bool default: no version_added: 2.4.0 From 5f4ab5928eba8e09d0846444e077f70b5147e8e3 Mon Sep 17 00:00:00 2001 From: Amin Vakil Date: Sat, 27 Mar 2021 01:14:21 +0430 Subject: [PATCH 5/6] Add warning text --- plugins/modules/system/vdo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/modules/system/vdo.py b/plugins/modules/system/vdo.py index 5c8fa7c7c6b..4a0a4d82411 100644 --- a/plugins/modules/system/vdo.py +++ b/plugins/modules/system/vdo.py @@ -264,7 +264,8 @@ or VDO signature already present in the storage device. When stopping or removing a VDO volume, first unmounts the file system stored on the device if mounted. - - "B(Warning:) ." + - "B(Warning:) This will destroy existing data if there is + any. Use at your own risk." type: bool default: no version_added: 2.4.0 From 9033d385903e6fa4dd9f22f02eb73df929481d48 Mon Sep 17 00:00:00 2001 From: Amin Vakil Date: Sat, 27 Mar 2021 16:23:50 +0430 Subject: [PATCH 6/6] Apply suggestion for warning text from rhawalsh --- plugins/modules/system/vdo.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/modules/system/vdo.py b/plugins/modules/system/vdo.py index 4a0a4d82411..a27745510a3 100644 --- a/plugins/modules/system/vdo.py +++ b/plugins/modules/system/vdo.py @@ -264,8 +264,9 @@ or VDO signature already present in the storage device. When stopping or removing a VDO volume, first unmounts the file system stored on the device if mounted. - - "B(Warning:) This will destroy existing data if there is - any. Use at your own risk." + - "B(Warning:) Since this parameter removes all safety + checks it is important to make sure that all parameters + provided are accurate and intentional." type: bool default: no version_added: 2.4.0