Skip to content

Commit

Permalink
Merge pull request ansible-collections#491 from abikouo/main
Browse files Browse the repository at this point in the history
Fix cloudfront_distribution disabling ipv6 when updating resource

Reviewed-by: https://github.com/apps/ansible-zuul
  • Loading branch information
ansible-zuul[bot] authored Apr 27, 2021
2 parents 0b87626 + 80d28cd commit 299c102
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugins/modules/cloudfront_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -1975,7 +1975,7 @@ def validate_restrictions(self, config, restrictions, purge_restrictions=False):
def validate_distribution_config_parameters(self, config, default_root_object, ipv6_enabled, http_version, web_acl_id):
try:
config['default_root_object'] = default_root_object or config.get('default_root_object', '')
config['is_i_p_v_6_enabled'] = ipv6_enabled or config.get('i_p_v_6_enabled', self.__default_ipv6_enabled)
config['is_i_p_v6_enabled'] = ipv6_enabled if ipv6_enabled is not None else config.get('is_i_p_v6_enabled', self.__default_ipv6_enabled)
if http_version is not None or config.get('http_version'):
self.validate_attribute_with_allowed_values(http_version, 'http_version', self.__valid_http_versions)
config['http_version'] = http_version or config.get('http_version')
Expand Down Expand Up @@ -2056,7 +2056,7 @@ def validate_distribution_from_aliases_caller_reference(self, distribution_id, a
if caller_reference is not None:
return self.validate_distribution_from_caller_reference(caller_reference)
else:
if aliases:
if aliases and distribution_id is None:
distribution_id = self.validate_distribution_id_from_alias(aliases)
if distribution_id:
return self.__cloudfront_facts_mgr.get_distribution(distribution_id)
Expand Down
61 changes: 61 additions & 0 deletions tests/integration/targets/cloudfront_distribution/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,67 @@
- set_fact:
distribution_id: '{{ cf_distribution.id }}'

- name: ensure that default value of 'ipv6_enabled' is 'false'
assert:
that:
- cf_distribution.changed
- not cf_distribution.is_ipv6_enabled

- name: Update the distribution with tags
cloudfront_distribution:
state: present
distribution_id: "{{ distribution_id }}"
tags:
property: ansible
register: cf_update_tags

- name: ensure the 'ipv6_enabled' value has not changed
assert:
that:
- cf_update_tags.changed
- not cf_update_tags.is_ipv6_enabled

- name: Update the distribution ipv6_enabled set to true
cloudfront_distribution:
state: present
distribution_id: "{{ distribution_id }}"
ipv6_enabled: True
register: cf_update_ipv6

- name: ensure the 'ipv6_enabled' value has changed (new value is true)
assert:
that:
- cf_update_ipv6.changed
- cf_update_ipv6.is_ipv6_enabled

- name: Update the distribution with tags
cloudfront_distribution:
state: present
distribution_id: "{{ distribution_id }}"
tags:
test: integration
register: cf_update_tags

- name: ensure the 'ipv6_enabled' value has not changed (value remains true)
assert:
that:
- cf_update_tags.changed
- cf_update_tags.is_ipv6_enabled

- name: Test idempotency updating cloudfront_distribution with same value of ipv6_enabled
cloudfront_distribution:
state: present
distribution_id: "{{ distribution_id }}"
ipv6_enabled: True
register: cf_update_ipv6

- name: ensure the 'ipv6_enabled' value has changed (new value is true)
assert:
that:
# FixMe : idempotency issues
# - not cf_update_ipv6.changed
- cf_update_ipv6.is_ipv6_enabled

- name: re-run cloudfront distribution with same defaults
cloudfront_distribution:
distribution_id: "{{ distribution_id }}"
Expand Down

0 comments on commit 299c102

Please sign in to comment.