route53_zone: enable check mode (#37201)

This commit is contained in:
Julien Vey 2018-03-12 19:43:43 +01:00 committed by Sloane Hertel
commit 099d8f0b56
2 changed files with 244 additions and 65 deletions

View file

@ -37,6 +37,23 @@
- output.name == '{{ resource_prefix }}.public.'
- not output.private_zone
# ============================================================
- name: Create a public zone (CHECK MODE)
route53_zone:
zone: "{{ resource_prefix }}.check.public"
comment: original comment
state: present
<<: *aws_connection_info
register: output
check_mode: yes
- assert:
that:
- output.changed
- output.comment == 'original comment'
- output.name == '{{ resource_prefix }}.check.public.'
- not output.private_zone
# ============================================================
- name: Do an idemptotent update of a public zone
route53_zone:
@ -53,6 +70,22 @@
- output.name == '{{ resource_prefix }}.public.'
- not output.private_zone
- name: Do an idemptotent update of a public zone (CHECK MODE)
route53_zone:
zone: "{{ resource_prefix }}.public"
comment: original comment
state: present
<<: *aws_connection_info
register: output
check_mode: yes
- assert:
that:
- not output.changed
- output.comment == 'original comment'
- output.name == '{{ resource_prefix }}.public.'
- not output.private_zone
# ============================================================
- name: Update comment of a public zone
route53_zone:
@ -67,19 +100,62 @@
- output.changed
- output.result.comment == "updated comment"
- name: Update comment of a public zone (CHECK MODE)
route53_zone:
zone: "{{ resource_prefix }}.public"
comment: updated comment for check
state: present
<<: *aws_connection_info
register: output
check_mode: yes
- assert:
that:
- output.changed
- output.result.comment == "updated comment for check"
# ============================================================
- name: Delete public zone (CHECK MODE)
route53_zone:
zone: "{{ resource_prefix }}.public"
state: absent
<<: *aws_connection_info
register: output
check_mode: yes
- assert:
that:
- output.changed
- "'Successfully deleted' in output.result"
- name: Delete public zone
route53_zone:
zone: "{{ resource_prefix }}.public"
state: absent
<<: *aws_connection_info
register: output
- assert:
that:
- output.changed
- "'Successfully deleted' in output.result"
# ============================================================
- name: Create a private zone (CHECK MODE)
route53_zone:
vpc_id: "{{ testing_vpc.vpc.id }}"
vpc_region: "{{ aws_region }}"
zone: "{{ resource_prefix }}.private"
comment: original comment
state: present
<<: *aws_connection_info
register: output
check_mode: yes
- assert:
that:
- output.changed
- name: Create a private zone
route53_zone:
vpc_id: "{{ testing_vpc.vpc.id }}"
@ -88,8 +164,11 @@
comment: original comment
state: present
<<: *aws_connection_info
register: output
- assert:
that:
- output.changed
# ============================================================
- name: Idemptotent update a private zone
route53_zone:
@ -106,6 +185,22 @@
- not output.changed
- "'There is already a private hosted zone in the same region with the same VPC' in output.msg"
- name: Idemptotent update a private zone (CHECK MODE)
route53_zone:
vpc_id: "{{ testing_vpc.vpc.id }}"
vpc_region: "{{ aws_region }}"
zone: "{{ resource_prefix }}.private"
comment: original comment
state: present
<<: *aws_connection_info
register: output
check_mode: yes
- assert:
that:
- not output.changed
- "'There is already a private hosted zone in the same region with the same VPC' in output.msg"
# ============================================================
- name: Update private zone comment
route53_zone:
@ -122,6 +217,22 @@
- output.changed
- output.result.comment == "updated_comment"
- name: Update private zone comment (CHECK MODE)
route53_zone:
vpc_id: "{{ testing_vpc.vpc.id }}"
vpc_region: "{{ aws_region }}"
zone: "{{ resource_prefix }}.private"
comment: updated_comment check
state: present
<<: *aws_connection_info
register: output
check_mode: yes
- assert:
that:
- output.changed
- output.result.comment == "updated_comment check"
# ============================================================
- name: Try to delete private zone without setting vpc_id and vpc_region
route53_zone:
@ -135,6 +246,19 @@
- not output.changed
- "output.result == 'No zone to delete.'"
- name: Try to delete private zone without setting vpc_id and vpc_region (CHECK MODE)
route53_zone:
zone: "{{ resource_prefix }}.private"
state: absent
<<: *aws_connection_info
register: output
check_mode: yes
- assert:
that:
- not output.changed
- "output.result == 'No zone to delete.'"
# ============================================================
- name: Try to delete a public zone that does not exists
route53_zone:
@ -149,7 +273,36 @@
- not output.changed
- "output.result == 'No zone to delete.'"
- name: Try to delete a public zone that does not exists (CHECK MODE)
route53_zone:
zone: "{{ resource_prefix }}.publicfake"
comment: original comment
state: absent
<<: *aws_connection_info
register: output
check_mode: yes
- assert:
that:
- not output.changed
- "output.result == 'No zone to delete.'"
# ============================================================
- name: Delete private zone (CHECK MODE)
route53_zone:
vpc_id: "{{ testing_vpc.vpc.id }}"
vpc_region: "{{ aws_region }}"
zone: "{{ resource_prefix }}.private"
state: absent
<<: *aws_connection_info
register: output
check_mode: yes
- assert:
that:
- output.changed
- "'Successfully deleted' in output.result"
- name: Delete private zone
route53_zone:
vpc_id: "{{ testing_vpc.vpc.id }}"
@ -174,6 +327,20 @@
register: new_zone
# Delete zone using its id
- name: Delete zone using attribute hosted_zone_id (CHECK MODE)
route53_zone:
zone: "{{ resource_prefix }}.public2"
hosted_zone_id: "{{new_zone.zone_id}}"
state: absent
<<: *aws_connection_info
register: output
check_mode: yes
- assert:
that:
- output.changed
- "'Successfully deleted' in output.result"
- name: Delete zone using attribute hosted_zone_id
route53_zone:
zone: "{{ resource_prefix }}.public2"