added check_mode support
added support for the --check option during execution of the playbooks
This commit is contained in:
parent
c3d49d7db0
commit
a7e088c683
1 changed files with 13 additions and 4 deletions
|
@ -145,6 +145,10 @@ def install_overlay(module, name, list_url=None):
|
||||||
if layman.is_installed(name):
|
if layman.is_installed(name):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if module.check_mode:
|
||||||
|
mymsg = 'Would add layman repo \'' + name + '\''
|
||||||
|
module.exit_json(changed=True, msg=mymsg)
|
||||||
|
|
||||||
if not layman.is_repo(name):
|
if not layman.is_repo(name):
|
||||||
if not list_url:
|
if not list_url:
|
||||||
raise ModuleError("Overlay '%s' is not on the list of known " \
|
raise ModuleError("Overlay '%s' is not on the list of known " \
|
||||||
|
@ -164,7 +168,7 @@ def install_overlay(module, name, list_url=None):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def uninstall_overlay(name):
|
def uninstall_overlay(module, name):
|
||||||
'''Uninstalls the given overlay repository from the system.
|
'''Uninstalls the given overlay repository from the system.
|
||||||
|
|
||||||
:param name: the overlay id to uninstall
|
:param name: the overlay id to uninstall
|
||||||
|
@ -178,6 +182,10 @@ def uninstall_overlay(name):
|
||||||
if not layman.is_installed(name):
|
if not layman.is_installed(name):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if module.check_mode:
|
||||||
|
mymsg = 'Would remove layman repo \'' + name + '\''
|
||||||
|
module.exit_json(changed=True, msg=mymsg)
|
||||||
|
|
||||||
layman.delete_repos(name)
|
layman.delete_repos(name)
|
||||||
if layman.get_errors(): raise ModuleError(layman.get_errors())
|
if layman.get_errors(): raise ModuleError(layman.get_errors())
|
||||||
|
|
||||||
|
@ -216,7 +224,8 @@ def main():
|
||||||
list_url = dict(aliases=['url']),
|
list_url = dict(aliases=['url']),
|
||||||
state = dict(default="present", choices=['present', 'absent', 'updated']),
|
state = dict(default="present", choices=['present', 'absent', 'updated']),
|
||||||
validate_certs = dict(required=False, default=True, type='bool'),
|
validate_certs = dict(required=False, default=True, type='bool'),
|
||||||
)
|
),
|
||||||
|
supports_check_mode=True
|
||||||
)
|
)
|
||||||
|
|
||||||
if not HAS_LAYMAN_API:
|
if not HAS_LAYMAN_API:
|
||||||
|
@ -237,7 +246,7 @@ def main():
|
||||||
else:
|
else:
|
||||||
sync_overlay(name)
|
sync_overlay(name)
|
||||||
else:
|
else:
|
||||||
changed = uninstall_overlay(name)
|
changed = uninstall_overlay(module, name)
|
||||||
|
|
||||||
except ModuleError, e:
|
except ModuleError, e:
|
||||||
module.fail_json(msg=e.message)
|
module.fail_json(msg=e.message)
|
||||||
|
|
Loading…
Reference in a new issue