diff --git a/changelogs/fragments/1475-xfconf-facts.yml b/changelogs/fragments/1475-xfconf-facts.yml new file mode 100644 index 0000000000..cffc6f023e --- /dev/null +++ b/changelogs/fragments/1475-xfconf-facts.yml @@ -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). diff --git a/plugins/modules/system/xfconf.py b/plugins/modules/system/xfconf.py index 8d0700ae11..ce85a2ba47 100644 --- a/plugins/modules/system/xfconf.py +++ b/plugins/modules/system/xfconf.py @@ -57,6 +57,14 @@ options: default: 'no' aliases: ['array'] 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 = """ @@ -158,13 +166,13 @@ class XFConfProperty(CmdMixin, StateMixin, ModuleHelper): elements='str', choices=('int', 'uint', 'bool', 'float', 'double', 'string')), value=dict(required=False, type='list', elements='raw'), force_array=dict(default=False, type='bool', aliases=['array']), + disable_facts=dict(type='bool', default=False), ), required_if=[('state', 'present', ['value', 'value_type'])], required_together=[('value', 'value_type')], supports_check_mode=True, ) - facts_name = "xfconf" default_state = 'present' command = 'xfconf-query' command_args_formats = dict( @@ -178,7 +186,8 @@ class XFConfProperty(CmdMixin, StateMixin, ModuleHelper): def update_xfconf_output(self, **kwargs): self.update_output(**kwargs) - self.update_facts(**kwargs) + if not self.module.params['disable_facts']: + self.update_facts(**kwargs) def __init_module__(self): 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'], channel=self.module.params['channel'], 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): if err.rstrip() == self.does_not: