From 0f1ccc07c520c43ff609d1ee8862809b80c11eba Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 6 Apr 2021 17:26:52 +0200 Subject: [PATCH] xfconf - state absent was not honoring check_mode (#2185) (#2186) * state absent was not honoring check_mode * added changelog fragment (cherry picked from commit 9a5191d1f934560f82525af0f93df366c937c54d) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- 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 b6e6110e87..459991747c 100644 --- a/plugins/modules/system/xfconf.py +++ b/plugins/modules/system/xfconf.py @@ -237,8 +237,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': True})) self.vars.value = None - self.run_command(params=('channel', 'property', {'reset': True})) self.update_xfconf_output(previous_value=self.vars.previous_value, value=None)