Skip to content

Commit 4a494df

Browse files
committed
feat: allow to specific vip interface
1 parent 8f02111 commit 4a494df

File tree

5 files changed

+34
-22
lines changed

5 files changed

+34
-22
lines changed

main.tf

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ module "servers" {
6060
keypair_name = openstack_compute_keypair_v2.key.name
6161
ssh_authorized_keys = local.ssh_authorized_keys
6262

63-
network_id = openstack_networking_network_v2.net.id
64-
subnet_id = openstack_networking_subnet_v2.servers.id
65-
secgroup_id = openstack_networking_secgroup_v2.server.id
66-
internal_vip = local.internal_vip
67-
bastion_host = local.external_ip
68-
san = distinct(concat([local.external_ip, local.internal_vip], var.additional_san))
63+
network_id = openstack_networking_network_v2.net.id
64+
subnet_id = openstack_networking_subnet_v2.servers.id
65+
secgroup_id = openstack_networking_secgroup_v2.server.id
66+
internal_vip = local.internal_vip
67+
vip_interface = var.vip_interface
68+
bastion_host = local.external_ip
69+
san = distinct(concat([local.external_ip, local.internal_vip], var.additional_san))
6970

7071
manifests_folder = var.manifests_folder
7172
manifests = merge(
@@ -200,11 +201,12 @@ module "agents" {
200201
keypair_name = openstack_compute_keypair_v2.key.name
201202
ssh_authorized_keys = local.ssh_authorized_keys
202203

203-
network_id = openstack_networking_network_v2.net.id
204-
subnet_id = openstack_networking_subnet_v2.agents.id
205-
secgroup_id = openstack_networking_secgroup_v2.agent.id
206-
internal_vip = local.internal_vip
207-
bastion_host = local.external_ip
204+
network_id = openstack_networking_network_v2.net.id
205+
subnet_id = openstack_networking_subnet_v2.agents.id
206+
secgroup_id = openstack_networking_secgroup_v2.agent.id
207+
internal_vip = local.internal_vip
208+
vip_interface = var.vip_interface
209+
bastion_host = local.external_ip
208210

209211
ff_autoremove_agent = var.ff_autoremove_agent
210212
ff_wait_ready = var.ff_wait_ready

node/cloud-init.yaml.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ write_files:
157157
- name: port
158158
value: "6443"
159159
- name: vip_interface
160-
value: ens3
160+
value: "${vip_interface}"
161161
- name: vip_cidr
162162
value: "32"
163163
- name: cp_enable

node/main.tf

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,17 @@ resource "openstack_compute_instance_v2" "instance" {
7878

7979
# yamlencode(yamldecode to debug yaml
8080
user_data = base64encode(templatefile("${path.module}/cloud-init.yaml.tpl", {
81-
rke2_token = var.rke2_token
82-
rke2_version = var.rke2_version
83-
rke2_conf = var.rke2_config != null ? var.rke2_config : ""
84-
rke2_device = var.rke2_volume_device
85-
is_server = var.is_server
86-
is_first = var.is_first && count.index == 0
87-
bootstrap = var.bootstrap && var.is_first && count.index == 0
88-
internal_vip = var.internal_vip
89-
node_ip = openstack_networking_port_v2.port[count.index].all_fixed_ips[0]
90-
san = var.is_server ? var.san : []
81+
rke2_token = var.rke2_token
82+
rke2_version = var.rke2_version
83+
rke2_conf = var.rke2_config != null ? var.rke2_config : ""
84+
rke2_device = var.rke2_volume_device
85+
is_server = var.is_server
86+
is_first = var.is_first && count.index == 0
87+
bootstrap = var.bootstrap && var.is_first && count.index == 0
88+
internal_vip = var.internal_vip
89+
vip_interface = var.vip_interface
90+
node_ip = openstack_networking_port_v2.port[count.index].all_fixed_ips[0]
91+
san = var.is_server ? var.san : []
9192
manifests_files = var.is_server ? merge(
9293
var.manifests_folder != "" ? {
9394
for f in fileset(var.manifests_folder, "*.{yml,yaml}") : f => base64gzip(file("${var.manifests_folder}/${f}"))

node/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ variable "internal_vip" {
7373
default = ""
7474
}
7575

76+
variable "vip_interface" {
77+
type = string
78+
}
79+
7680
variable "bastion_host" {
7781
type = string
7882
}

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ variable "subnet_lb_cidr" {
8484
default = "192.168.44.0/24"
8585
}
8686

87+
variable "vip_interface" {
88+
type = string
89+
default = "ens3"
90+
}
91+
8792
variable "dns_nameservers4" {
8893
type = list(string)
8994
# Cloudflare

0 commit comments

Comments
 (0)