Skip to content

Commit

Permalink
Allow the usage of external address.
Browse files Browse the repository at this point in the history
  • Loading branch information
samip5 committed Sep 13, 2023
1 parent 59174cb commit de0e3e7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
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: # 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: # 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
# ...

0 comments on commit de0e3e7

Please sign in to comment.