mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-09 18:04:02 -07:00
* Move compare_policies and hashable_policy functions into module_utils/ec2 * Use compare_policies which is compatible with python 2 and 3. * rename function to indicate internal use * s3_bucket: don't set changed to false if it has had the chance to be changed to true already.
This commit is contained in:
parent
883169ab6b
commit
73abce83a9
3 changed files with 95 additions and 98 deletions
|
@ -117,7 +117,7 @@ except ImportError:
|
|||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.ec2 import (boto3_conn, get_aws_connection_info, ec2_argument_spec, AWSRetry,
|
||||
sort_json_policy_dict, camel_dict_to_snake_dict, HAS_BOTO3)
|
||||
camel_dict_to_snake_dict, HAS_BOTO3, compare_policies)
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
||||
|
@ -174,8 +174,8 @@ def get_or_create_policy_version(module, iam, policy, policy_document):
|
|||
module.fail_json(msg="Couldn't get policy version %s: %s" % (v['VersionId'], str(e)),
|
||||
exception=traceback.format_exc(),
|
||||
**camel_dict_to_snake_dict(e.response))
|
||||
if sort_json_policy_dict(document) == sort_json_policy_dict(
|
||||
json.loads(policy_document)):
|
||||
# If the current policy matches the existing one
|
||||
if not compare_policies(document, json.loads(to_native(policy_document))):
|
||||
return v, False
|
||||
|
||||
# No existing version so create one
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue