haproxytech / vmware-haproxy

Apache License 2.0
50 stars 25 forks source link

terraform deployment #32

Open jeffdroibnson opened 7 months ago

jeffdroibnson commented 7 months ago

Hello! Has anyone tried deploying this with terraform? I have been able to deploy into vsphere, but it looks like it is trying to deploy as a "frontend" haproxy and not the "default" configuration option. After deploying, I run ifconfig on the command line and see a "frontend" NIC and a "workload" NIC. If I deploy manually through the vsphere GUI, everything works as expected. Here's the code I'm working with. I'm looking for help please =)

haproxy.tf

data "vsphere_datacenter" "dc" { name = var.datacenter_name }

data "vsphere_datastore" "datastore" { name = var.datastore_name datacenter_id = data.vsphere_datacenter.dc.id }

data "vsphere_resource_pool" "pool" { name = "${var.cluster_name}/Resources" datacenter_id = data.vsphere_datacenter.dc.id }

data "vsphere_network" "management" { name = "Tanzu Management Network"
datacenter_id = data.vsphere_datacenter.dc.id }

data "vsphere_network" "workload" { name = "Tanzu Workload Network"
datacenter_id = data.vsphere_datacenter.dc.id }

data "vsphere_host" "host" { name = "vmhost" datacenter_id = data.vsphere_datacenter.dc.id }

resource "vsphere_virtual_machine" "tanzu-haproxy" { name = var.vm_name datacenter_id = data.vsphere_datacenter.dc.id resource_pool_id = data.vsphere_resource_pool.pool.id datastore_id = data.vsphere_datastore.datastore.id host_system_id = data.vsphere_host.host.id folder = "Tanzu" wait_for_guest_net_timeout = 0 wait_for_guest_ip_timeout = 0 wait_for_guest_net_routable = false

ovf_deploy { local_ovf_path = "./haproxy-v0.2.0.ova" disk_provisioning = "thin" ip_protocol = "IPV4" ip_allocation_policy = "STATIC_MANUAL" ovf_network_map = { "management" = data.vsphere_network.management.id "workload" = data.vsphere_network.workload.id } }

network_interface { network_id = data.vsphere_network.management.id }

network_interface { network_id = data.vsphere_network.workload.id }

vapp { properties = { "root_pwd" = "12345" "permit_root_login" = "True" "hostname" = "tanzu-haproxy" "nameservers" = "10.1.1.224, 10.6.100.55" "management_ip" = "10.6.15.40/27" "management_gateway" = "10.6.15.33" "workload_ip" = "172.28.201.135/25" "workload_gateway" = "172.28.201.129"
"service_ip_range" = "172.28.201.208/28" "dataplane_port" = "5556" "haproxy_user" = "dataplane-api" "haproxy_pwd" = "12345" } }

}

jeffdroibnson commented 7 months ago

It seems like we need a userconfigurable option in the OVF to set "configuration" to "default" or "frontend"? We could put that in the vapp code block.