Skip to content

Commit

Permalink
Configurable private_zone in all calls to the route53 module
Browse files Browse the repository at this point in the history
  • Loading branch information
Kris Shaw committed Jan 14, 2020
1 parent 71104da commit 984049a
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions group_vars/_skel/cluster_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ bind9:
# The global {{cluster_name}} is prefixed with {{app_name}}
cluster_name: "{{app_name}}-{{buildenv}}"

### AWS example
cluster_vars:
type: aws # aws, gcp, openstack
image: "" # Ubuntu images can be located at https://cloud-images.ubuntu.com/locator/
Expand All @@ -69,6 +70,7 @@ cluster_vars:
assign_public_ip: "no"
inventory_ip: "private" # 'public' or 'private', (private in case we're operating in a private LAN). If public, 'assign_public_ip' must be 'yes'
instance_profile_name: "vpc_lock_{{buildenv}}"
route53_private_zone: true # Only used when cluster_vars.type == 'aws'. Defaults to true if not set.
secgroups_existing: []
secgroup_new:
- proto: "tcp"
Expand Down
8 changes: 4 additions & 4 deletions roles/clusterbuild/clean/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
zone: "{{cluster_vars.dns_zone_external}}"
record: "{{item.hostname}}.{{cluster_vars.dns_zone_external}}"
type: "A"
private_zone: true
private_zone: "{{cluster_vars.route53_private_zone | default(true)}}"
register: dns_rec
with_items: "{{ cluster_hosts_flat }}"

Expand All @@ -78,7 +78,7 @@
type: "{{ item.set.type }}"
ttl: "{{ item.set.ttl }}"
value: ["{{ item.set.value }}"]
private_zone: true
private_zone: "{{cluster_vars.route53_private_zone | default(true)}}"
with_items: "{{ dns_rec.results }}"
when: item.set.value is defined

Expand All @@ -90,7 +90,7 @@
zone: "{{cluster_vars.dns_zone_external}}"
record: "{{item.hostname | regex_replace('-(?!.*-)[0-9]{10}$')}}.{{cluster_vars.dns_zone_external}}"
type: "CNAME"
private_zone: true
private_zone: "{{cluster_vars.route53_private_zone | default(true)}}"
register: dns_rec
with_items: "{{ cluster_hosts_flat }}"

Expand All @@ -104,7 +104,7 @@
type: "{{ item.set.type }}"
ttl: "{{ item.set.ttl }}"
value: ["{{ item.set.value }}"]
private_zone: true
private_zone: "{{cluster_vars.route53_private_zone | default(true)}}"
with_items: "{{ dns_rec.results }}"
when: item.set.value is defined
when: cluster_vars.dns_server == "route53" and cluster_vars.dns_zone_external is defined and cluster_vars.dns_zone_external != ""
Expand Down
4 changes: 2 additions & 2 deletions roles/clusterbuild/config/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
type: A
ttl: 60
value: "{{ hostvars[item.hostname]['ansible_host'] }}"
private_zone: true
private_zone: "{{cluster_vars.route53_private_zone | default(true)}}"
overwrite: true
become: false
delegate_to: localhost
Expand Down Expand Up @@ -183,7 +183,7 @@
type: CNAME
ttl: 30
value: "{{item.hostname}}.{{cluster_vars.dns_zone_external}}"
private_zone: true
private_zone: "{{cluster_vars.route53_private_zone | default(true)}}"
overwrite: true
become: false
delegate_to: localhost
Expand Down
2 changes: 1 addition & 1 deletion roles/clusterbuild/redeploy/tasks/aws_rescue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
value: "{{ host_to_recover}}.{{cluster_vars.dns_zone_external}}"
type: CNAME
ttl: 30
private_zone: true
private_zone: "{{cluster_vars.route53_private_zone | default(true)}}"
overwrite: true
when: cluster_vars.dns_server == "route53"

Expand Down
4 changes: 2 additions & 2 deletions roles/clusterbuild/redeploy/tasks/aws_stop_instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
zone: "{{cluster_vars.dns_zone_external}}"
record: "{{existing.instances[0].tags.Name}}.{{cluster_vars.dns_zone_external}}"
type: "A"
private_zone: true
private_zone: "{{cluster_vars.route53_private_zone | default(true)}}"
register: dns_rec

- name: Remove DNS entries from route53
Expand All @@ -83,7 +83,7 @@
type: "{{ dns_rec.set.type }}"
ttl: "{{ dns_rec.set.ttl }}"
value: ["{{ dns_rec.set.value }}"]
private_zone: true
private_zone: "{{cluster_vars.route53_private_zone | default(true)}}"
when: dns_rec.set.value is defined
when: cluster_vars.dns_server == "route53" and cluster_vars.dns_zone_external is defined and cluster_vars.dns_zone_external != ""

Expand Down
2 changes: 1 addition & 1 deletion roles/clusterbuild/redeploy/tasks/by_type_host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
value: "{{instance_to_create}}.{{cluster_vars.dns_zone_external}}"
type: CNAME
ttl: 30
private_zone: true
private_zone: "{{cluster_vars.route53_private_zone | default(true)}}"
overwrite: true
when: cluster_vars.dns_server == "route53"

Expand Down
2 changes: 1 addition & 1 deletion roles/clusterbuild/redeploy/tasks/gce_stop_instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
type: "{{ dns_rec.set.type }}"
ttl: "{{ dns_rec.set.ttl }}"
value: ["{{ dns_rec.set.value }}"]
private_zone: true
private_zone: "{{cluster_vars.route53_private_zone | default(true)}}"
when: dns_rec.set.value is defined
when: cluster_vars.dns_server == "route53" and cluster_vars.dns_zone_external is defined and cluster_vars.dns_zone_external != ""

Expand Down

0 comments on commit 984049a

Please sign in to comment.