Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the usage of external address #938

Merged
merged 3 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions bootstrap/tasks/validation/net.yaml
Original file line number Diff line number Diff line change
@@ -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
ansible.builtin.assert:
that:
Expand Down Expand Up @@ -142,16 +149,17 @@
fail_msg: Node address {{ item.address }} is not within {{ bootstrap_node_cidr }}.
quiet: true
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}"
when: item.external_address is not defined
loop_control:
label: "{{ item.address }}"

- name: Verify SSH port is reachable
ansible.builtin.wait_for:
host: "{{ item.address }}"
host: "{{ current_address }}"
port: 22
search_regex: OpenSSH
timeout: 10
connection: local
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}"
loop_control:
label: "{{ item.address }}"
label: "{{ current_address }}"
8 changes: 8 additions & 0 deletions bootstrap/templates/ansible/inventory/hosts.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ kubernetes:
{% for item in bootstrap_nodes.master %}
{{ item.name }}:
ansible_user: {{ item.username }}
{% if item.external_address is defined %}
ansible_host: {{ item.external_address }}
{% else %}
ansible_host: {{ item.address }}
{% endif %}
{% endfor %}
{% if bootstrap_nodes.worker | default([]) | length > 0 %}
worker:
hosts:
{% for item in bootstrap_nodes.worker %}
{{ item.name }}:
ansible_user: {{ item.username }}
{% if item.external_address is defined %}
ansible_host: {{ item.external_address }}
{% else %}
ansible_host: {{ item.address }}
{% endif %}
{% endfor %}
{% endif %}
2 changes: 2 additions & 0 deletions bootstrap/vars/config.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ bootstrap_nodes:
master:
# - name: # name of the master node (must match [a-z0-9-]+)
# address: # ip address of the master node
# external_address: # USE ONLY when SSH is not reachable on the IP specified in address field.
# username: # ssh username of the master node
# password: # password of ssh username for the master node
# ...
worker: # set to [] or omit if no workers are needed
# - name: # name of the worker node (must match [a-z0-9-]+)
# address: # ip address of the worker node
# external_address: # USE ONLY when SSH is not reachable on the IP specified in address field.
# username: # ssh username of the worker node
# password: # password of ssh username for the worker node
onedr0p marked this conversation as resolved.
Show resolved Hide resolved
# ...