1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

correct and clarify deprecation (#45234)

* correct and clarify deprecation
This commit is contained in:
Brian Coca 2018-09-06 13:24:44 -04:00 committed by GitHub
parent db34d3923a
commit 64c594d226
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 13 deletions

View file

@ -50,8 +50,9 @@ options:
aliases: [ daemon-reload ] aliases: [ daemon-reload ]
user: user:
description: description:
- run systemctl talking to the service manager of the calling user, rather than the service manager - (deprecated) run ``systemctl`` talking to the service manager of the calling user, rather than the service manager
of the system. This is deprecated and the scope paramater should be used instead. of the system.
- This option is deprecated and will eventually be removed in 2.11. The ``scope`` option should be used instead.
type: bool type: bool
default: 'no' default: 'no'
scope: scope:
@ -305,26 +306,37 @@ def main():
force=dict(type='bool'), force=dict(type='bool'),
masked=dict(type='bool'), masked=dict(type='bool'),
daemon_reload=dict(type='bool', default=False, aliases=['daemon-reload']), daemon_reload=dict(type='bool', default=False, aliases=['daemon-reload']),
user=dict(type='bool', default=False), user=dict(type='bool'),
scope=dict(type='str', default='system', choices=['system', 'user', 'global']), scope=dict(type='str', choices=['system', 'user', 'global']),
no_block=dict(type='bool', default=False), no_block=dict(type='bool', default=False),
), ),
supports_check_mode=True, supports_check_mode=True,
required_one_of=[['state', 'enabled', 'masked', 'daemon_reload']], required_one_of=[['state', 'enabled', 'masked', 'daemon_reload']],
mutually_exclusive=[['scope', 'user']],
) )
systemctl = module.get_bin_path('systemctl', True) systemctl = module.get_bin_path('systemctl', True)
if module.params['user'] and module.params['scope'] == 'system':
module.deprecate("The 'user' paramater is being renamed to 'scope'", version=2.8) ''' Set CLI options depending on params '''
systemctl = systemctl + " --user" if module.params['user'] is not None:
if module.params['scope'] == 'user': # handle user deprecation, mutually exclusive with scope
systemctl = systemctl + " --user" module.deprecate("The 'user' option is being replaced by 'scope'", version='2.11')
if module.params['scope'] == 'global': if module.params['user']:
systemctl = systemctl + " --global" module.params['scope'] = 'user'
else:
module.params['scope'] = 'system'
# if scope is 'system' or None, we can ignore as there is no extra switch.
# The other choices match the corresponding switch
if module.params['scope'] not in (None, 'system'):
systemctl += " --%s" % module.params['scope']
if module.params['no_block']: if module.params['no_block']:
systemctl = systemctl + " --no-block" systemctl += " --no-block"
if module.params['force']: if module.params['force']:
systemctl = systemctl + " --force" systemctl += " --force"
unit = module.params['name'] unit = module.params['name']
rc = 0 rc = 0
out = err = '' out = err = ''

View file

@ -1134,6 +1134,7 @@ lib/ansible/modules/system/selinux_permissive.py E322
lib/ansible/modules/system/seport.py E324 lib/ansible/modules/system/seport.py E324
lib/ansible/modules/system/service.py E323 lib/ansible/modules/system/service.py E323
lib/ansible/modules/system/service.py E210 lib/ansible/modules/system/service.py E210
lib/ansible/modules/system/systemd.py E324
lib/ansible/modules/system/solaris_zone.py E324 lib/ansible/modules/system/solaris_zone.py E324
lib/ansible/modules/system/svc.py E322 lib/ansible/modules/system/svc.py E322
lib/ansible/modules/system/svc.py E324 lib/ansible/modules/system/svc.py E324