From f534ecbd2c3499a892de9c6abea8776f44a2415d Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Wed, 7 Apr 2021 20:20:30 +1200 Subject: [PATCH] [stable-1] xfconf - state absent was not honoring check_mode (#2185) (#2187) * xfconf - state absent was not honoring check_mode (#2185) * state absent was not honoring check_mode * added changelog fragment * adjusted run_command() call for stable-1 --- changelogs/fragments/2185-xfconf-absent-check-mode.yml | 2 ++ plugins/modules/system/xfconf.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/2185-xfconf-absent-check-mode.yml diff --git a/changelogs/fragments/2185-xfconf-absent-check-mode.yml b/changelogs/fragments/2185-xfconf-absent-check-mode.yml new file mode 100644 index 0000000000..059f4acd9a --- /dev/null +++ b/changelogs/fragments/2185-xfconf-absent-check-mode.yml @@ -0,0 +1,2 @@ +bugfixes: + - xfconf - module was not honoring check mode when ``state`` was ``absent`` (https://github.com/ansible-collections/community.general/pull/2185). diff --git a/plugins/modules/system/xfconf.py b/plugins/modules/system/xfconf.py index 8d0700ae11..5dc87f539c 100644 --- a/plugins/modules/system/xfconf.py +++ b/plugins/modules/system/xfconf.py @@ -219,8 +219,9 @@ class XFConfProperty(CmdMixin, StateMixin, ModuleHelper): self.update_xfconf_output(value=self.vars.value) def state_absent(self): + if not self.module.check_mode: + self.run_command(params=('channel', 'property', 'reset'), extra_params={"reset": True}) self.vars.value = None - self.run_command(params=('channel', 'property', 'reset'), extra_params={"reset": True}) self.update_xfconf_output(previous_value=self.vars.previous_value, value=None)