diff --git a/changelogs/fragments/utils.yaml b/changelogs/fragments/utils.yaml new file mode 100644 index 000000000..3c59ffe3a --- /dev/null +++ b/changelogs/fragments/utils.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - Simplifies value handling by returning direct string conversion instead of using ast.literal_eval diff --git a/plugins/module_utils/network/common/utils.py b/plugins/module_utils/network/common/utils.py index 5576e7edf..fccb5b348 100644 --- a/plugins/module_utils/network/common/utils.py +++ b/plugins/module_utils/network/common/utils.py @@ -685,11 +685,11 @@ def __call__(self, value, variables=None, fail_on_undefined=True): return None raise - if value: - try: - return ast.literal_eval(value) - except Exception: - return str(value) + if value is not None: + # Special handling for values starting with + + if isinstance(value, str) and value.startswith("+"): + return value # Keep the + prefix intact + return str(value) # Convert everything else to string else: return None