From f929422dacbd0f69f42fe43b26fbc4470984d09a Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 10 Sep 2022 10:52:14 +0200 Subject: [PATCH] osx_defaults: add expand_user_and_vars flag to write (#5243) * Add expand_user_and_vars flag to write Closes #5234 * Add changelog * Update changelogs/fragments/5243-osx-defaults-expand-user-flags.yml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- changelogs/fragments/5243-osx-defaults-expand-user-flags.yml | 2 ++ plugins/modules/system/osx_defaults.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5243-osx-defaults-expand-user-flags.yml diff --git a/changelogs/fragments/5243-osx-defaults-expand-user-flags.yml b/changelogs/fragments/5243-osx-defaults-expand-user-flags.yml new file mode 100644 index 0000000000..c7e17fb8ca --- /dev/null +++ b/changelogs/fragments/5243-osx-defaults-expand-user-flags.yml @@ -0,0 +1,2 @@ +bugfixes: + - osx_defaults - no longer expand ``~`` in ``value`` to the user's home directory, or expand environment variables (https://github.com/ansible-collections/community.general/issues/5234, https://github.com/ansible-collections/community.general/pull/5243). \ No newline at end of file diff --git a/plugins/modules/system/osx_defaults.py b/plugins/modules/system/osx_defaults.py index 5ad390ca33..f905493a31 100644 --- a/plugins/modules/system/osx_defaults.py +++ b/plugins/modules/system/osx_defaults.py @@ -304,7 +304,8 @@ class OSXDefaults(object): if not isinstance(value, list): value = [value] - rc, out, err = self.module.run_command(self._base_command() + ['write', self.domain, self.key, '-' + self.type] + value) + rc, out, err = self.module.run_command(self._base_command() + ['write', self.domain, self.key, '-' + self.type] + value, + expand_user_and_vars=False) if rc != 0: raise OSXDefaultsException('An error occurred while writing value to defaults: %s' % out)