Open Ian2020 opened 1 year ago
I also hit something like this issue on Ubuntu16.04 and Ansible 2.0.0.2 (python 2.7), I was trying to set a value to 0 and it would return the same TypeError from _escape_single_quotes() re.sub call. I landed on the same hack fix outlined here and had included it in PR #22 without realizing it might be a separate issue.
Under Fedora 37 (ansible 7.1, python 3.11.1) if your setting value resembles a Python type, e.g. a list like "[ 'some value' ]" then it gets interpreted as one, leading to an error inside gsetting. This seems quite likely given how many gsettings have the same syntax as Python lists.
This is NOT a problem under Fedora 36 (ansible 5.9, python 3.10.9).
Example task:
Gives:
I believe this is due to the value: "['&DOCUMENTS', '&DOWNLOAD', '&MUSIC', '&PICTURES']" becoming a Python list by the time it's fed to the gsetting module.
I don't know why this has changed - must be something inside ansible or python.
Looking at the history of the ansible code that launches modules lib/ansible/executor/module_common.py there has been some changes around dropping python2 support that may have altered the behaviour of how arguments are interpreted/passed but I would be surprised if this hadn't affected loads of other modules too.
This can be 'fixed' in gsetting by forcing the value back to a string:
...but this seems a total hack. A better approach might be to use
argument_spec
in the module to force values to be strings but this is not supported for the dict type.