mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-06-30 07:50:43 +00:00
Update various modules for check_mode
This updates the following modules to support check_mode: * apt_key * apt_repository * easy_install * pip - will always report changed due to the way it handles state * seboolean * selinux * slurp - since nothing changes, it just adds that it supports check_mode * subversion - reports changed when checking out new repo and when updating. * supervisorctl * svr4pkg See issue #2114.
This commit is contained in:
parent
0342b054fd
commit
8f0d8a8546
10 changed files with 58 additions and 9 deletions
|
|
@ -51,7 +51,7 @@ def main():
|
|||
state=dict(required=True, choices=['present', 'started', 'restarted', 'stopped'])
|
||||
)
|
||||
|
||||
module = AnsibleModule(argument_spec=arg_spec)
|
||||
module = AnsibleModule(argument_spec=arg_spec, supports_check_mode=True)
|
||||
|
||||
name = module.params['name']
|
||||
state = module.params['state']
|
||||
|
|
@ -63,6 +63,8 @@ def main():
|
|||
|
||||
if state == 'present':
|
||||
if not present:
|
||||
if module.check_mode:
|
||||
module.exit_json(changed=True)
|
||||
module.run_command('%s reread' % SUPERVISORCTL, check_rc=True)
|
||||
rc, out, err = module.run_command('%s add %s' % (SUPERVISORCTL, name))
|
||||
|
||||
|
|
@ -80,6 +82,8 @@ def main():
|
|||
module.exit_json(changed=False, name=name, state=state)
|
||||
|
||||
if running and state == 'stopped':
|
||||
if module.check_mode:
|
||||
module.exit_json(changed=True)
|
||||
rc, out, err = module.run_command('%s stop %s' % (SUPERVISORCTL, name))
|
||||
|
||||
if '%s: stopped' % name in out:
|
||||
|
|
@ -88,6 +92,8 @@ def main():
|
|||
module.fail_json(msg=out)
|
||||
|
||||
elif state == 'restarted':
|
||||
if module.check_mode:
|
||||
module.exit_json(changed=True)
|
||||
rc, out, err = module.run_command('%s update %s' % (SUPERVISORCTL, name))
|
||||
rc, out, err = module.run_command('%s restart %s' % (SUPERVISORCTL, name))
|
||||
|
||||
|
|
@ -97,6 +103,8 @@ def main():
|
|||
module.fail_json(msg=out)
|
||||
|
||||
elif not running and state == 'started':
|
||||
if module.check_mode:
|
||||
module.exit_json(changed=True)
|
||||
rc, out, err = module.run_command('%s start %s' % (SUPERVISORCTL, name))
|
||||
|
||||
if '%s: started' % name in out:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue