Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rke2_ha_mode_kubevip: false
# Kubernetes API and RKE2 registration IP address. The default Address is the IPv4 of the Server/Master node.
# In HA mode choose a static IP which will be set as VIP in keepalived.
# Or if the keepalived is disabled, use IP address of your LB.
rke2_api_ip: "{{ hostvars[groups[rke2_servers_group_name].0]['ansible_default_ipv4']['address'] | default(hostvars[groups[rke2_servers_group_name].0]['ansible_default_ipv6']['address'] ) }}"
rke2_api_ip: "{{ hostvars[groups[rke2_servers_group_name].0].get('ansible_default_ipv4', {}).get('address') or hostvars[groups[rke2_servers_group_name].0].get('ansible_default_ipv6', {}).get('address') }}"

# optional option for RKE2 Server to listen on a private IP address & port
# rke2_api_private_ip:
Expand Down
2 changes: 1 addition & 1 deletion meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ argument_specs:

rke2_api_ip:
type: str
default: "{{ hostvars[groups[rke2_servers_group_name].0].ansible_facts['default_ipv4']['address'] | default(hostvars[groups[rke2_servers_group_name].0].ansible_facts['default_ipv6']['address'] ) }}"
default: "{{ hostvars[groups[rke2_servers_group_name].0].ansible_facts.get('default_ipv4', {}).get('address') or hostvars[groups[rke2_servers_group_name].0].ansible_facts.get('default_ipv6', {}).get('address') }}"
description: "Kubernetes API and RKE2 registration IP address. The default Address is the IPv4 of the Server/Master node. In HA mode choose a static IP which will be set as VIP in keepalived. Or if the keepalived is disabled, use IP address of your LB."

rke2_api_private_ip:
Expand Down
6 changes: 3 additions & 3 deletions templates/keepalived.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ vrrp_script chk_rke2server {
}

vrrp_instance VI_1 {
interface {{ ansible_facts.default_ipv4.interface | default(ansible_facts.default_ipv6.interface) }}
interface {{ ansible_facts.get('default_ipv4', {}).get('interface') or ansible_facts.get('default_ipv6', {}).get('interface') }}
virtual_router_id 11
{% if groups[rke2_servers_group_name].0 == inventory_hostname|string() %}
state MASTER
Expand All @@ -41,11 +41,11 @@ vrrp_instance VI_1 {
{% endif -%}
{% endfor %}
advert_int 1
unicast_src_ip {{ ansible_facts.default_ipv4.address | default(ansible_facts.default_ipv6.address) }}
unicast_src_ip {{ ansible_facts.get('default_ipv4', {}).get('address') or ansible_facts.get('default_ipv6', {}).get('address') }}
unicast_peer {
{% for host in groups[rke2_servers_group_name] %}
{% if host|string() != inventory_hostname|string() %}
{{ hostvars[host]['ansible_facts']['default_ipv4']['address'] | default(hostvars[host]['ansible_facts']['default_ipv6']['address'] ) }}
{{ hostvars[host]['ansible_facts'].get('default_ipv4', {}).get('address') or hostvars[host]['ansible_facts'].get('default_ipv6', {}).get('address') }}
{% endif %}
{% endfor %}
}
Expand Down
2 changes: 1 addition & 1 deletion templates/kube-vip/kube-vip.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
fieldRef:
fieldPath: spec.nodeName
- name: vip_interface
value: "{{ rke2_interface | default(ansible_facts.default_ipv4.interface | default(ansible_facts.default_ipv6.interface)) }}"
value: "{{ rke2_interface | default(ansible_facts.get('default_ipv4', {}).get('interface') or ansible_facts.get('default_ipv6', {}).get('interface')) }}"
- name: port
value: "{{ rke2_api_port | default('6443') }}"
- name: vip_cidr
Expand Down