Skip to content

Commit ea7722a

Browse files
committed
Correctly set SNO api and ingress addresses in coredns Corefile.hosts
1 parent 1211530 commit ea7722a

File tree

1 file changed

+51
-23
lines changed

1 file changed

+51
-23
lines changed

ansible/roles/bastion-coredns/templates/Corefile.hosts.j2

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@ hosts {
33
# Bastion
44
{{ bastion_controlplane_ip }} {{ groups['bastion'][0] }}
55

6-
# Hub Cluster API
6+
{% if cluster_type in ["mno", "vmno"] %}
7+
# MNO Cluster API
78
{{ controlplane_network_api }} api.{{ cluster_name }}.{{ base_dns_name }}
9+
{% else %}
10+
{% for sno in groups['sno'] %}
11+
# SNO Cluster API
12+
{{ hostvars[sno].ip }} api.{{ sno }}.{{ base_dns_name }}
13+
{% endfor %}
14+
{% endif %}
815

916
# VM
1017
{% for vm in groups['hv_vm'] %}
@@ -18,38 +25,49 @@ hosts {
1825
{{ hostvars[groups['hv_vm'][0]]['machine_network'] | ansible.utils.nthhost(-2) }} api.jumbocluster00.{{ base_dns_name }}
1926

2027
# Standard cluster DNS ({{ standard_cluster_dns_count }} Entries)
21-
{% for cluster in range(1, standard_cluster_dns_count + 1, 1) %}
28+
{% for cluster in range(1, standard_cluster_dns_count + 1, 1) %}
2229
{{ hostvars[groups['hv_vm'][0]]['machine_network'] | ansible.utils.nthhost(cluster * -2) }} standard-{{ '%05d' | format(cluster) }}
2330
{{ hostvars[groups['hv_vm'][0]]['machine_network'] | ansible.utils.nthhost(cluster * -2) }} api.standard-{{ '%05d' | format(cluster) }}.{{ base_dns_name }}
24-
{% endfor %}
31+
{% endfor %}
2532

2633
# Compact cluster DNS ({{ compact_cluster_dns_count }} Entries)
27-
{% for cluster in range(1, compact_cluster_dns_count + 1, 1) %}
34+
{% for cluster in range(1, compact_cluster_dns_count + 1, 1) %}
2835
{{ hostvars[groups['hv_vm'][0]]['machine_network'] | ansible.utils.nthhost((cluster + standard_cluster_dns_count) * -2) }} compact-{{ '%05d' | format(cluster) }}
2936
{{ hostvars[groups['hv_vm'][0]]['machine_network'] | ansible.utils.nthhost((cluster + standard_cluster_dns_count) * -2) }} api.compact-{{ '%05d' | format(cluster) }}.{{ base_dns_name }}
30-
{% endfor %}
37+
{% endfor %}
3138
{% endif %}
3239
fallthrough
3340
}
3441

3542
# *.apps All Clusters
3643
{% if bastion_controlplane_ip | ansible.utils.ipv6 %}
44+
{% if cluster_type in ["mno", "vmno"] %}
3745
# *.apps for hub cluster
3846
template IN AAAA {{ cluster_name }}.{{ base_dns_name }} {
3947
match .*.apps.{{ cluster_name }}.{{ base_dns_name }}
4048
answer "{%raw%}{{ .Name }} 60 in {{ .Type }}{%endraw%} {{ controlplane_network_ingress }}"
4149
fallthrough
4250
}
51+
{% else %}
52+
{% for sno in groups['sno'] %}
53+
# *.apps for {{ sno }} SNO
54+
template IN AAAA {{ sno }}.{{ base_dns_name }} {
55+
match .*.apps.{{ sno }}.{{ base_dns_name }}
56+
answer "{%raw%}{{ .Name }} 60 in {{ .Type }}{%endraw%} {{ hostvars[sno].ip }}"
57+
fallthrough
58+
}
59+
{% endfor %}
60+
{% endif %}
4361

4462
# *.apps for VMs
45-
{% for vm in groups['hv_vm'] %}
63+
{% for vm in groups['hv_vm'] %}
4664
template IN AAAA {{ vm }}.{{ base_dns_name }} {
4765
match .*.apps.{{ vm }}.{{ base_dns_name }}
4866
answer "{%raw%}{{ .Name }} 60 in {{ .Type }}{%endraw%} {{ hostvars[vm].ip }}"
4967
fallthrough
5068
}
51-
{% endfor %}
52-
{% if groups['hv_vm'] | length > 0 %}
69+
{% endfor %}
70+
{% if groups['hv_vm'] | length > 0 %}
5371

5472
# *.apps for jumbocluster00
5573
template IN AAAA jumbocluster00.{{ base_dns_name }} {
@@ -59,41 +77,51 @@ template IN AAAA jumbocluster00.{{ base_dns_name }} {
5977
}
6078

6179
# *.apps for standard clusters
62-
{% for cluster in range(1, standard_cluster_dns_count + 1, 1) %}
80+
{% for cluster in range(1, standard_cluster_dns_count + 1, 1) %}
6381
template IN AAAA standard-{{ '%05d' | format(cluster) }}.{{ base_dns_name }} {
6482
match .*.apps.standard-{{ '%05d' | format(cluster) }}.{{ base_dns_name }}
6583
answer "{%raw%}{{ .Name }} 60 in {{ .Type }}{%endraw%} {{ hostvars[groups['hv_vm'][0]]['machine_network'] | ansible.utils.nthhost( (cluster * -2) - 1 ) }}"
6684
fallthrough
6785
}
68-
{% endfor %}
86+
{% endfor %}
6987

7088
# *.apps for compact clusters
71-
{% for cluster in range(1, compact_cluster_dns_count + 1, 1) %}
89+
{% for cluster in range(1, compact_cluster_dns_count + 1, 1) %}
7290
template IN AAAA compact-{{ '%05d' | format(cluster) }}.{{ base_dns_name }} {
7391
match .*.apps.compact-{{ '%05d' | format(cluster) }}.{{ base_dns_name }}
7492
answer "{%raw%}{{ .Name }} 60 in {{ .Type }}{%endraw%} {{ hostvars[groups['hv_vm'][0]]['machine_network'] | ansible.utils.nthhost( ((cluster + standard_cluster_dns_count) * -2) - 1 ) }}"
7593
fallthrough
7694
}
77-
{% endfor %}
78-
{% endif %}
95+
{% endfor %}
96+
{% endif %}
7997
{% else %}
80-
81-
# *.apps for hub cluster
98+
{% if cluster_type in ["mno", "vmno"] %}
99+
# *.apps for mno cluster
82100
template IN A {{ cluster_name }}.{{ base_dns_name }} {
83101
match .*.apps.{{ cluster_name }}.{{ base_dns_name }}
84102
answer "{%raw%}{{ .Name }} 60 in {{ .Type }}{%endraw%} {{ controlplane_network_ingress }}"
85103
fallthrough
86104
}
105+
{% else %}
106+
{% for sno in groups['sno'] %}
107+
# *.apps for {{ sno }} SNO
108+
template IN A {{ sno }}.{{ base_dns_name }} {
109+
match .*.apps.{{ sno }}.{{ base_dns_name }}
110+
answer "{%raw%}{{ .Name }} 60 in {{ .Type }}{%endraw%} {{ hostvars[sno].ip }}"
111+
fallthrough
112+
}
113+
{% endfor %}
114+
{% endif %}
87115

88116
# *.apps for VMs
89-
{% for vm in groups['hv_vm'] %}
117+
{% for vm in groups['hv_vm'] %}
90118
template IN A {{ vm }}.{{ base_dns_name }} {
91119
match .*.apps.{{ vm }}.{{ base_dns_name }}
92120
answer "{%raw%}{{ .Name }} 60 in {{ .Type }}{%endraw%} {{ hostvars[vm].ip }}"
93121
fallthrough
94122
}
95-
{% endfor %}
96-
{% if groups['hv_vm'] | length > 0 %}
123+
{% endfor %}
124+
{% if groups['hv_vm'] | length > 0 %}
97125

98126
# *.apps for jumbocluster00
99127
template IN A jumbocluster00.{{ base_dns_name }} {
@@ -103,21 +131,21 @@ template IN A jumbocluster00.{{ base_dns_name }} {
103131
}
104132

105133
# *.apps for standard clusters
106-
{% for cluster in range(1, standard_cluster_dns_count + 1, 1) %}
134+
{% for cluster in range(1, standard_cluster_dns_count + 1, 1) %}
107135
template IN A standard-{{ '%05d' | format(cluster) }}.{{ base_dns_name }} {
108136
match .*.apps.standard-{{ '%05d' | format(cluster) }}.{{ base_dns_name }}
109137
answer "{%raw%}{{ .Name }} 60 in {{ .Type }}{%endraw%} {{ hostvars[groups['hv_vm'][0]]['machine_network'] | ansible.utils.nthhost( (cluster * -2) - 1 ) }}"
110138
fallthrough
111139
}
112-
{% endfor %}
140+
{% endfor %}
113141

114142
# *.apps for compact clusters
115-
{% for cluster in range(1, compact_cluster_dns_count + 1, 1) %}
143+
{% for cluster in range(1, compact_cluster_dns_count + 1, 1) %}
116144
template IN A compact-{{ '%05d' | format(cluster) }}.{{ base_dns_name }} {
117145
match .*.apps.compact-{{ '%05d' | format(cluster) }}.{{ base_dns_name }}
118146
answer "{%raw%}{{ .Name }} 60 in {{ .Type }}{%endraw%} {{ hostvars[groups['hv_vm'][0]]['machine_network'] | ansible.utils.nthhost( ((cluster + standard_cluster_dns_count) * -2) - 1 ) }}"
119147
fallthrough
120148
}
121-
{% endfor %}
122-
{% endif %}
149+
{% endfor %}
150+
{% endif %}
123151
{% endif %}

0 commit comments

Comments
 (0)