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

xfconf: feature flag to disable facts and deprecation warning (#1747) (#1778)

* Added feature flag to disable facts and its associated deprecatoin warning

* added changelog fragment

* Update plugins/modules/system/xfconf.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/system/xfconf.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/system/xfconf.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Fixed deprecation message

* Fixed changelog frag

* Update changelogs/fragments/1475-xfconf-facts.yml

* Update plugins/modules/system/xfconf.py

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit af64c9a432)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2021-02-10 20:37:31 +01:00 committed by GitHub
parent 983b292399
commit d871378574
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

View file

@ -0,0 +1,4 @@
minor_changes:
- xfconf - added option ``disable_facts`` to disable facts and its associated deprecation warning (https://github.com/ansible-collections/community.general/issues/1475).
deprecated_features:
- xfconf - returning output as facts is deprecated, this will be removed in community.general 4.0.0. Please register the task output in a variable and use it instead. You can already switch to the new behavior now by using the new ``disable_facts`` option (https://github.com/ansible-collections/community.general/pull/1747).

View file

@ -57,6 +57,14 @@ options:
default: 'no' default: 'no'
aliases: ['array'] aliases: ['array']
version_added: 1.0.0 version_added: 1.0.0
disable_facts:
description:
- For backward compatibility, output results are also returned as C(ansible_facts), but this behaviour is deprecated
and will be removed in community.general 4.0.0.
- This flag disables the output as facts and also disables the deprecation warning.
type: bool
default: no
version_added: 2.1.0
''' '''
EXAMPLES = """ EXAMPLES = """
@ -158,13 +166,13 @@ class XFConfProperty(CmdMixin, StateMixin, ModuleHelper):
elements='str', choices=('int', 'uint', 'bool', 'float', 'double', 'string')), elements='str', choices=('int', 'uint', 'bool', 'float', 'double', 'string')),
value=dict(required=False, type='list', elements='raw'), value=dict(required=False, type='list', elements='raw'),
force_array=dict(default=False, type='bool', aliases=['array']), force_array=dict(default=False, type='bool', aliases=['array']),
disable_facts=dict(type='bool', default=False),
), ),
required_if=[('state', 'present', ['value', 'value_type'])], required_if=[('state', 'present', ['value', 'value_type'])],
required_together=[('value', 'value_type')], required_together=[('value', 'value_type')],
supports_check_mode=True, supports_check_mode=True,
) )
facts_name = "xfconf"
default_state = 'present' default_state = 'present'
command = 'xfconf-query' command = 'xfconf-query'
command_args_formats = dict( command_args_formats = dict(
@ -178,7 +186,8 @@ class XFConfProperty(CmdMixin, StateMixin, ModuleHelper):
def update_xfconf_output(self, **kwargs): def update_xfconf_output(self, **kwargs):
self.update_output(**kwargs) self.update_output(**kwargs)
self.update_facts(**kwargs) if not self.module.params['disable_facts']:
self.update_facts(**kwargs)
def __init_module__(self): def __init_module__(self):
self.does_not = 'Property "{0}" does not exist on channel "{1}".'.format(self.module.params['property'], self.does_not = 'Property "{0}" does not exist on channel "{1}".'.format(self.module.params['property'],
@ -187,6 +196,15 @@ class XFConfProperty(CmdMixin, StateMixin, ModuleHelper):
self.update_xfconf_output(property=self.module.params['property'], self.update_xfconf_output(property=self.module.params['property'],
channel=self.module.params['channel'], channel=self.module.params['channel'],
previous_value=None) previous_value=None)
if not self.module.params['disable_facts']:
self.facts_name = "xfconf"
self.module.deprecate(
msg="Returning results as facts is deprecated. "
"Please register the module output to a variable instead."
" You can use the disable_facts option to switch to the "
"new behavior already now and disable this warning",
version="4.0.0", collection_name="community.general"
)
def process_command_output(self, rc, out, err): def process_command_output(self, rc, out, err):
if err.rstrip() == self.does_not: if err.rstrip() == self.does_not: