Allow the usage of external address (#938)

Co-authored-by: Devin Buhl <onedr0p@users.noreply.github.com>
This commit is contained in:
Skyler MäntysaariandDevin Buhl authored and GitHub committed 2023-09-13 09:25:08 -04:00
1 parent 59174cbf9b
commit 4bf9724afd
3 files changed
+20 -2

No files matched your search

+10 -2
View File
@@ -1,4 +1,11 @@
--- ---
- name: Set reachable address
set_fact:
current_address: "{{ item.external_address | default(item.address) }}"
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}"
loop_control:
label: "{{ item.address }}"
- name: Verify master node count - name: Verify master node count
ansible.builtin.assert: ansible.builtin.assert:
that: that:
@@ -142,16 +149,17 @@
fail_msg: Node address {{ item.address }} is not within {{ bootstrap_node_cidr }}. fail_msg: Node address {{ item.address }} is not within {{ bootstrap_node_cidr }}.
quiet: true quiet: true
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}" loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}"
when: item.external_address is not defined
loop_control: loop_control:
label: "{{ item.address }}" label: "{{ item.address }}"
- name: Verify SSH port is reachable - name: Verify SSH port is reachable
ansible.builtin.wait_for: ansible.builtin.wait_for:
host: "{{ item.address }}" host: "{{ current_address }}"
port: 22 port: 22
search_regex: OpenSSH search_regex: OpenSSH
timeout: 10 timeout: 10
connection: local connection: local
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}" loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}"
loop_control: loop_control:
label: "{{ item.address }}" label: "{{ current_address }}"
@@ -7,7 +7,11 @@ kubernetes:
{% for item in bootstrap_nodes.master %} {% for item in bootstrap_nodes.master %}
{{ item.name }}: {{ item.name }}:
ansible_user: {{ item.username }} ansible_user: {{ item.username }}
{% if item.external_address is defined %}
ansible_host: {{ item.external_address }}
{% else %}
ansible_host: {{ item.address }} ansible_host: {{ item.address }}
{% endif %}
{% endfor %} {% endfor %}
{% if bootstrap_nodes.worker | default([]) | length > 0 %} {% if bootstrap_nodes.worker | default([]) | length > 0 %}
worker: worker:
@@ -15,6 +19,10 @@ kubernetes:
{% for item in bootstrap_nodes.worker %} {% for item in bootstrap_nodes.worker %}
{{ item.name }}: {{ item.name }}:
ansible_user: {{ item.username }} ansible_user: {{ item.username }}
{% if item.external_address is defined %}
ansible_host: {{ item.external_address }}
{% else %}
ansible_host: {{ item.address }} ansible_host: {{ item.address }}
{% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
+2
View File
@@ -64,10 +64,12 @@ bootstrap_nodes:
# address: # ip address of the master node # address: # ip address of the master node
# username: # ssh username of the master node # username: # ssh username of the master node
# password: # password of ssh username for the master node # password: # password of ssh username for the master node
# # external_address: # Only use when SSH is not reachable on the IP specified in 'address' field
# ... # ...
worker: # set to [] or omit if no workers are needed worker: # set to [] or omit if no workers are needed
# - name: # name of the worker node (must match [a-z0-9-]+) # - name: # name of the worker node (must match [a-z0-9-]+)
# address: # ip address of the worker node # address: # ip address of the worker node
# username: # ssh username of the worker node # username: # ssh username of the worker node
# password: # password of ssh username for the worker node # password: # password of ssh username for the worker node
# # external_address: # Only use when SSH is not reachable on the IP specified in 'address' field
# ... # ...