Skip to content

Commit 72e7d17

Browse files
committed
fix: add check for bootstrap_distribution
Signed-off-by: Devin Buhl <[email protected]>
1 parent 1532136 commit 72e7d17

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

bootstrap/tasks/validation/net.yaml

+21-21
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,35 @@
66
loop_control:
77
label: "{{ item.address }}"
88

9-
- name: Check that master node count is odd
9+
- name: Check if master node count is odd
1010
ansible.builtin.assert:
1111
that:
1212
- bootstrap_nodes.master | length > 0
1313
- bootstrap_nodes.master | length is odd
1414
success_msg: Master node count {{ bootstrap_nodes.master | length }} is correct.
1515
fail_msg: Master node count {{ bootstrap_nodes.master | length }} is not greater than 0 or is not odd.
1616

17-
- name: Check that node CIDR is ipv4
17+
- name: Check if node CIDR is ipv4
1818
ansible.builtin.assert:
1919
that: bootstrap_node_cidr is ansible.utils.ipv4
2020
success_msg: Node CIDR {{ bootstrap_node_cidr }} is valid.
2121
fail_msg: Node CIDR {{ bootstrap_node_cidr }} is invalid.
2222

23-
- name: Check that cluster CIDR is ipv4 OR ipv6
23+
- name: Check if cluster CIDR is ipv4 OR ipv6
2424
when: not bootstrap_ipv6_enabled | default(false)
2525
ansible.builtin.assert:
2626
that: bootstrap_cluster_cidr is ansible.utils.ipv4 or bootstrap_cluster_cidr is ansible.utils.ipv6
2727
success_msg: Cluster CIDR {{ bootstrap_cluster_cidr }} is valid.
2828
fail_msg: Cluster CIDR {{ bootstrap_cluster_cidr }} is invalid.
2929

30-
- name: Check that service CIDR is ipv4 OR ipv6
30+
- name: Check if service CIDR is ipv4 OR ipv6
3131
when: not bootstrap_ipv6_enabled | default(false)
3232
ansible.builtin.assert:
3333
that: bootstrap_service_cidr is ansible.utils.ipv4 or bootstrap_service_cidr is ansible.utils.ipv6
3434
success_msg: Service CIDR {{ bootstrap_service_cidr }} is valid.
3535
fail_msg: Service CIDR {{ bootstrap_service_cidr }} is invalid.
3636

37-
- name: Check that cluster CIDR is ipv4 AND ipv6
37+
- name: Check if cluster CIDR is ipv4 AND ipv6
3838
when: bootstrap_ipv6_enabled | default(false)
3939
ansible.builtin.assert:
4040
that: >
@@ -48,7 +48,7 @@
4848
success_msg: Cluster CIDR {{ bootstrap_cluster_cidr }} is valid.
4949
fail_msg: Cluster CIDR {{ bootstrap_cluster_cidr }} is invalid.
5050

51-
- name: Check that service CIDR is ipv4 AND ipv6
51+
- name: Check if service CIDR is ipv4 AND ipv6
5252
when: bootstrap_ipv6_enabled | default(false)
5353
ansible.builtin.assert:
5454
that: >
@@ -62,31 +62,31 @@
6262
success_msg: Service CIDR {{ bootstrap_service_cidr }} is valid.
6363
fail_msg: Service CIDR {{ bootstrap_service_cidr }} is invalid.
6464

65-
- name: Check that k8s_gateway is ipv4
65+
- name: Check if k8s_gateway is ipv4
6666
ansible.builtin.assert:
6767
that: bootstrap_k8s_gateway_addr is ansible.utils.ipv4
6868
success_msg: k8s_gateway address {{ bootstrap_k8s_gateway_addr }} is valid.
6969
fail_msg: k8s_gateway address {{ bootstrap_k8s_gateway_addr }} is invalid.
7070

71-
- name: Check that k8s_gateway is in node CIDR
71+
- name: Check if k8s_gateway is in node CIDR
7272
ansible.builtin.assert:
7373
that: bootstrap_node_cidr | ansible.utils.network_in_usable(bootstrap_k8s_gateway_addr)
7474
success_msg: k8s_gateway address {{ bootstrap_k8s_gateway_addr }} is within {{ bootstrap_node_cidr }}.
7575
fail_msg: k8s_gateway address {{ bootstrap_k8s_gateway_addr }} is not within {{ bootstrap_node_cidr }}.
7676

77-
- name: Check that internal ingress is ipv4
77+
- name: Check if internal ingress is ipv4
7878
ansible.builtin.assert:
7979
that: bootstrap_internal_ingress_addr is ansible.utils.ipv4
8080
success_msg: internal ingress address {{ bootstrap_internal_ingress_addr }} is valid.
8181
fail_msg: internal ingress address {{ bootstrap_internal_ingress_addr }} is invalid.
8282

83-
- name: Check that internal ingress is in node CIDR
83+
- name: Check if internal ingress is in node CIDR
8484
ansible.builtin.assert:
8585
that: bootstrap_node_cidr | ansible.utils.network_in_usable(bootstrap_internal_ingress_addr)
8686
success_msg: internal ingress address {{ bootstrap_internal_ingress_addr }} is within {{ bootstrap_node_cidr }}.
8787
fail_msg: internal ingress address {{ bootstrap_internal_ingress_addr }} is not within {{ bootstrap_node_cidr }}.
8888

89-
- name: Check that external ingress is ipv4
89+
- name: Check if external ingress is ipv4
9090
ansible.builtin.assert:
9191
that: bootstrap_external_ingress_addr is ansible.utils.ipv4
9292
success_msg: external ingress address {{ bootstrap_external_ingress_addr }} is valid.
@@ -98,19 +98,19 @@
9898
success_msg: external ingress address {{ bootstrap_external_ingress_addr }} is within {{ bootstrap_node_cidr }}.
9999
fail_msg: external ingress address {{ bootstrap_external_ingress_addr }} is not within {{ bootstrap_node_cidr }}.
100100

101-
- name: Check that Kube API address is ipv4
101+
- name: Check if Kube API address is ipv4
102102
ansible.builtin.assert:
103103
that: bootstrap_kube_api_addr is ansible.utils.ipv4
104104
success_msg: Kube API address {{ bootstrap_kube_api_addr }} is valid.
105105
fail_msg: Kube API address {{ bootstrap_kube_api_addr }} is invalid.
106106

107-
- name: Check that Kube API address is in node CIDR
107+
- name: Check if Kube API address is in node CIDR
108108
ansible.builtin.assert:
109109
that: bootstrap_node_cidr | ansible.utils.network_in_usable(bootstrap_kube_api_addr)
110110
success_msg: Kube API address {{ bootstrap_kube_api_addr }} is within {{ bootstrap_node_cidr }}.
111111
fail_msg: Kube API address {{ bootstrap_kube_api_addr }} is not within {{ bootstrap_node_cidr }}.
112112

113-
- name: Check that all IP addresses are unique
113+
- name: Check if all IP addresses are unique
114114
ansible.builtin.assert:
115115
that: >
116116
[
@@ -122,7 +122,7 @@
122122
success_msg: All IP addresses are unique.
123123
fail_msg: All IP addresses are not unique.
124124

125-
- name: Check that nodes are not the same IPs as k8s_gateway or ingress external/internal
125+
- name: Check if nodes are not the same IPs as k8s_gateway or ingress external/internal
126126
when: not bootstrap_kube_vip_enabled | default(true)
127127
ansible.builtin.assert:
128128
that: item.address not in (bootstrap_k8s_gateway_addr, bootstrap_external_ingress_addr, bootstrap_internal_ingress_addr)
@@ -133,7 +133,7 @@
133133
loop_control:
134134
label: "{{ item.address }}"
135135

136-
- name: Check that nodes are not the same IPs as k8s_gateway, ingress external/internal or Kube API address
136+
- name: Check if nodes are not the same IPs as k8s_gateway, ingress external/internal or Kube API address
137137
when: (bootstrap_distribution == "k3s") and (bootstrap_kube_vip_enabled | default(true))
138138
ansible.builtin.assert:
139139
that: item.address not in (bootstrap_k8s_gateway_addr, bootstrap_external_ingress_addr, bootstrap_internal_ingress_addr, bootstrap_kube_api_addr)
@@ -144,7 +144,7 @@
144144
loop_control:
145145
label: "{{ item.address }}"
146146

147-
- name: Check that node addresses are ipv4
147+
- name: Check if node addresses are ipv4
148148
ansible.builtin.assert:
149149
that: item.address is ansible.utils.ipv4
150150
success_msg: Node address {{ item.address }} is valid.
@@ -154,7 +154,7 @@
154154
loop_control:
155155
label: "{{ item.address }}"
156156

157-
- name: Check that node addresses are in node CIDR
157+
- name: Check if node addresses are in node CIDR
158158
ansible.builtin.assert:
159159
that: bootstrap_node_cidr | ansible.utils.network_in_usable(item.address)
160160
success_msg: Node address {{ item.address }} is within {{ bootstrap_node_cidr }}.
@@ -165,7 +165,7 @@
165165
loop_control:
166166
label: "{{ item.address }}"
167167

168-
- name: Check that node IP addresses are unique
168+
- name: Check if node IP addresses are unique
169169
ansible.builtin.assert:
170170
that: >
171171
(
@@ -179,7 +179,7 @@
179179
fail_msg: All node IP addresses are not unique.
180180
quiet: true
181181

182-
- name: Check that node names are unique
182+
- name: Check if node names are unique
183183
ansible.builtin.assert:
184184
that: >
185185
(
@@ -193,7 +193,7 @@
193193
fail_msg: All node names are not unique.
194194
quiet: true
195195

196-
- name: Check that nodes SSH ports are reachable
196+
- name: Check if nodes SSH ports are reachable
197197
when: not ci_test | default(false)
198198
ansible.builtin.wait_for:
199199
host: "{{ current_address }}"

bootstrap/tasks/validation/vars.yaml

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- name: Check that required bootstrap vars are set
2+
- name: Check if required bootstrap vars are set
33
ansible.builtin.assert:
44
that:
55
- item in vars
@@ -31,7 +31,13 @@
3131
- bootstrap_service_cidr
3232
- bootstrap_timezone
3333

34-
- name: Check that bootstrap node names are valid
34+
- name: Check if bootstrap distribution is valid
35+
ansible.builtin.assert:
36+
that: bootstrap_distribution in ['k0s', 'k3s']
37+
success_msg: Distribution {{ bootstrap_distribution }} is valid
38+
fail_msg: Distribution {{ bootstrap_distribution }} is not valid
39+
40+
- name: Check if bootstrap node names are valid
3541
ansible.builtin.assert:
3642
that: item.name is match('^[a-z0-9-\.]+$')
3743
success_msg: Node name {{ item.name }} is valid

0 commit comments

Comments
 (0)