mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Added support for --check in zfs module
This commit is contained in:
parent
e4ccf2d8e0
commit
ee517ea53c
1 changed files with 16 additions and 4 deletions
18
library/zfs
18
library/zfs
|
@ -240,6 +240,9 @@ class Zfs(object):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
|
if self.module.check_mode:
|
||||||
|
self.changed = True
|
||||||
|
return
|
||||||
properties=self.properties
|
properties=self.properties
|
||||||
volsize = properties.pop('volsize', None)
|
volsize = properties.pop('volsize', None)
|
||||||
volblocksize = properties.pop('volblocksize', None)
|
volblocksize = properties.pop('volblocksize', None)
|
||||||
|
@ -266,6 +269,9 @@ class Zfs(object):
|
||||||
self.module.fail_json(msg=out)
|
self.module.fail_json(msg=out)
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
|
if self.module.check_mode:
|
||||||
|
self.changed = True
|
||||||
|
return
|
||||||
cmd = [self.module.get_bin_path('zfs', True)]
|
cmd = [self.module.get_bin_path('zfs', True)]
|
||||||
cmd.append('destroy')
|
cmd.append('destroy')
|
||||||
cmd.append(self.name)
|
cmd.append(self.name)
|
||||||
|
@ -276,6 +282,9 @@ class Zfs(object):
|
||||||
self.module.fail_json(msg=out)
|
self.module.fail_json(msg=out)
|
||||||
|
|
||||||
def set_property(self, prop, value):
|
def set_property(self, prop, value):
|
||||||
|
if self.module.check_mode:
|
||||||
|
self.changed = True
|
||||||
|
return
|
||||||
cmd = [self.module.get_bin_path('zfs', True)]
|
cmd = [self.module.get_bin_path('zfs', True)]
|
||||||
cmd.append('set')
|
cmd.append('set')
|
||||||
cmd.append(prop + '=' + value)
|
cmd.append(prop + '=' + value)
|
||||||
|
@ -356,15 +365,18 @@ def main():
|
||||||
'vscan': {'required': False, 'choices':['on', 'off']},
|
'vscan': {'required': False, 'choices':['on', 'off']},
|
||||||
'xattr': {'required': False, 'choices':['on', 'off']},
|
'xattr': {'required': False, 'choices':['on', 'off']},
|
||||||
'zoned': {'required': False, 'choices':['on', 'off']},
|
'zoned': {'required': False, 'choices':['on', 'off']},
|
||||||
}
|
},
|
||||||
|
supports_check_mode=True
|
||||||
)
|
)
|
||||||
|
|
||||||
state = module.params.pop('state')
|
state = module.params.pop('state')
|
||||||
name = module.params.pop('name')
|
name = module.params.pop('name')
|
||||||
# Remaining items in module.params are zfs properties
|
|
||||||
|
|
||||||
# Remove 'null' value properties
|
# Get all valid zfs-properties
|
||||||
properties = dict()
|
properties = dict()
|
||||||
for prop, value in module.params.iteritems():
|
for prop, value in module.params.iteritems():
|
||||||
|
if prop in ['CHECKMODE']:
|
||||||
|
continue
|
||||||
if value:
|
if value:
|
||||||
properties[prop] = value
|
properties[prop] = value
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue