diff --git a/collection/plugins/modules/common.py b/collection/plugins/modules/common.py new file mode 100644 index 0000000..d631f87 --- /dev/null +++ b/collection/plugins/modules/common.py @@ -0,0 +1,14 @@ +import json + +def deep_equal(a, b): + """ + Compare two data structures for deep equality by converting them to JSON strings. + + Parameters: + a (any): First data structure to compare. + b (any): Second data structure to compare. + + Returns: + bool: True if the two data structures are equal, False otherwise. + """ + return json.dumps(a, sort_keys=True) == json.dumps(b, sort_keys=True) diff --git a/collection/plugins/modules/device_defaults.py b/collection/plugins/modules/device_defaults.py index 55a6f02..170c15f 100644 --- a/collection/plugins/modules/device_defaults.py +++ b/collection/plugins/modules/device_defaults.py @@ -151,11 +151,9 @@ response: ''' from ansible_collections.community.syncthing.plugins.module_utils.syncthing_api import SyncthingModule +from common.py import deep_equal import json -def deep_equal(a, b): - return json.dumps(a, sort_keys=True) == json.dumps(b, sort_keys=True) - def run_module(): module_args = dict( addresses=dict(type='list', required=False),