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 00000000000..c7e17fb8ca8 --- /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 5ad390ca332..f905493a31a 100644 --- a/plugins/modules/system/osx_defaults.py +++ b/plugins/modules/system/osx_defaults.py @@ -304,7 +304,8 @@ def write(self): 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)