Initial draft w/ new vsphere provider
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
c66d489865
commit
eb19e05995
@ -1,11 +1,26 @@
|
|||||||
resource "vsphere_virtual_machine" "TF-DC01" {
|
data "vsphere_ovf_vm_template" {
|
||||||
name = "TF-DC01"
|
name = "ovf-dc"
|
||||||
resource_pool_id = data.vsphere_resource_pool.pool.id
|
resource_pool_id = data.vsphere_resource_pool.pool.id
|
||||||
datastore_id = data.vsphere_datastore.vmdatastore.id
|
datastore_id = data.vpshere_datastore.datastore.id
|
||||||
|
host_system_id = data.vsphere_host.host.id
|
||||||
|
|
||||||
|
remote_ovf_url = "https://${var.repo_username}:${var.repo_password}@sn.itch.fyi/Repository/rel/ADDS-appliance.ova"
|
||||||
|
deployment_option = "standalone"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "vsphere_virtual_machine" "vm-dc" {
|
||||||
|
name = "TF-DC01"
|
||||||
|
|
||||||
|
num_cpus = var.vm_numcpu
|
||||||
|
memory = var.vm_memory
|
||||||
|
|
||||||
|
datacenter_id = data.vsphere_datacenter.dc.id
|
||||||
folder = var.vsphere_vmfolder
|
folder = var.vsphere_vmfolder
|
||||||
|
|
||||||
num_cpus = 2
|
guest_id = data.vsphere_ovf_vm_template.ovf-dc.guest_id
|
||||||
memory = 4096
|
resource_pool_id = data.vsphere_ovf_vm_template.ovf-dc.resource_pool_id
|
||||||
|
datastore_id = data.vsphere_ovf_vm_template.ovf-dc.datastore_id
|
||||||
|
host_system_id = data.vsphere_ovf_vm_template.ovf-dc.host_system_id
|
||||||
|
|
||||||
network_interface {
|
network_interface {
|
||||||
network_id = data.vsphere_network.network.id
|
network_id = data.vsphere_network.network.id
|
||||||
@ -18,34 +33,32 @@ resource "vsphere_virtual_machine" "TF-DC01" {
|
|||||||
thin_provisioned = true
|
thin_provisioned = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ovf_deploy {
|
||||||
|
remote_ovf_url = data.vsphere_ovf_vm_template.ovf-dc.remote_ovf_url
|
||||||
|
deployment_option = data.vsphere_ovf_vm_template.ovf-dc.deployment_option
|
||||||
|
}
|
||||||
|
|
||||||
vapp {
|
vapp {
|
||||||
properties = {
|
properties = {
|
||||||
# "deployment.type" = "primary"
|
|
||||||
|
|
||||||
"guestinfo.hostname" = "TF-DC01"
|
"guestinfo.hostname" = "TF-DC01"
|
||||||
"guestinfo.ipaddress" = "10.0.0.21"
|
"guestinfo.ipaddress" = "10.0.0.21"
|
||||||
"guestinfo.prefixlength" = "24"
|
"guestinfo.prefixlength" = "24"
|
||||||
# "guestinfo.dnsserver" = "0.0.0.0"
|
|
||||||
"guestinfo.gateway" = "10.0.0.1"
|
"guestinfo.gateway" = "10.0.0.1"
|
||||||
|
|
||||||
"addsconfig.domainname" = "srv.io"
|
"addsconfig.domainname" = var.adds_domainname
|
||||||
"addsconfig.netbiosname" = "SRV"
|
"addsconfig.netbiosname" = var.adds_netbiosname
|
||||||
"addsconfig.administratorpw" = var.adds_password
|
"addsconfig.administratorpw" = var.adds_password
|
||||||
"addsconfig.safemodepw" = var.adds_password
|
"addsconfig.safemodepw" = var.adds_password
|
||||||
"addsconfig.ntpserver" = "0.pool.ntp.org,1.pool.ntp.org,2.pool.ntp.org"
|
"addsconfig.ntpserver" = var.adds_ntpserver
|
||||||
|
|
||||||
# "dhcpconfig.startip" = "10.0.0.50"
|
"dhcpconfig.startip" = var.dhcp_startip
|
||||||
# "dhcpconfig.endip" = "10.0.0.250"
|
"dhcpconfig.endip" = var.dhcp_endip
|
||||||
# "dhcpconfig.subnetmask" = "255.255.255.0"
|
"dhcpconfig.subnetmask" = var.dhcp_subnetmask
|
||||||
# "dhcpconfig.gateway" = "10.0.0.1"
|
"dhcpconfig.gateway" = var.dhcp_gateway
|
||||||
# "dhcpconfig.leaseduration" = "01:00:00.00"
|
"dhcpconfig.leaseduration" = var.dhcp_leaseduration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clone {
|
|
||||||
template_uuid = vsphere_content_library_item.ADDS.id
|
|
||||||
}
|
|
||||||
|
|
||||||
# # This does not actually achieve protection from destruction, see https://github.com/hashicorp/terraform/issues/17599
|
# # This does not actually achieve protection from destruction, see https://github.com/hashicorp/terraform/issues/17599
|
||||||
# lifecycle {
|
# lifecycle {
|
||||||
# prevent_destroy = true
|
# prevent_destroy = true
|
||||||
|
@ -1,11 +1,26 @@
|
|||||||
resource "vsphere_virtual_machine" "TF-SRV01" {
|
data "vsphere_ovf_vm_template" {
|
||||||
name = "TF-SRV01"
|
name = "ovf-srv"
|
||||||
resource_pool_id = data.vsphere_resource_pool.pool.id
|
resource_pool_id = data.vsphere_resource_pool.pool.id
|
||||||
datastore_id = data.vsphere_datastore.vmdatastore.id
|
datastore_id = data.vpshere_datastore.datastore.id
|
||||||
|
host_system_id = data.vsphere_host.host.id
|
||||||
|
|
||||||
|
remote_ovf_url = "https://${var.repo_username}:${var.repo_password}@sn.itch.fyi/Repository/rel/Windows-Server-2019-LTSC.ova"
|
||||||
|
deployment_option = "domainmember"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "vsphere_virtual_machine" "vm-srv" {
|
||||||
|
name = "TF-SRV01"
|
||||||
|
|
||||||
|
num_cpus = var.vm_numcpu
|
||||||
|
memory = var.vm_memory
|
||||||
|
|
||||||
|
datacenter_id = data.vsphere_datacenter.dc.id
|
||||||
folder = var.vsphere_vmfolder
|
folder = var.vsphere_vmfolder
|
||||||
|
|
||||||
num_cpus = 2
|
guest_id = data.vsphere_ovf_vm_template.ovf-srv.guest_id
|
||||||
memory = 4096
|
resource_pool_id = data.vsphere_ovf_vm_template.ovf-srv.resource_pool_id
|
||||||
|
datastore_id = data.vsphere_ovf_vm_template.ovf-srv.datastore_id
|
||||||
|
host_system_id = data.vsphere_ovf_vm_template.ovf-srv.host_system_id
|
||||||
|
|
||||||
network_interface {
|
network_interface {
|
||||||
network_id = data.vsphere_network.network.id
|
network_id = data.vsphere_network.network.id
|
||||||
@ -24,30 +39,27 @@ resource "vsphere_virtual_machine" "TF-SRV01" {
|
|||||||
thin_provisioned = true
|
thin_provisioned = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ovf_deploy {
|
||||||
|
remote_ovf_url = data.vsphere_ovf_vm_template.ovf-srv.remote_ovf_url
|
||||||
|
deployment_option = data.vsphere_ovf_vm_template.ovf-srv.deployment_option
|
||||||
|
}
|
||||||
|
|
||||||
vapp {
|
vapp {
|
||||||
properties = {
|
properties = {
|
||||||
# "deployment.type" = "standalone"
|
"guestinfo.hostname" = "TF-SRV01"
|
||||||
|
"guestinfo.ipaddress" = "10.0.0.42"
|
||||||
|
"guestinfo.prefixlength" = "24"
|
||||||
|
"guestinfo.dnsserver" = "10.0.0.21"
|
||||||
|
"guestinfo.gateway" = "10.0.0.1"
|
||||||
|
|
||||||
"guestinfo.hostname" = "TF-SRV01"
|
"addsconfig.domainname" = var.adds_domainname
|
||||||
# "guestinfo.administratorpw" = "Secret123!"
|
"addsconfig.username" = var.adds_username
|
||||||
# "guestinfo.ntpserver" = "0.pool.ntp.org,1.pool.ntp.org,2.pool.ntp.org"
|
"addsconfig.password" = var.adds_password
|
||||||
"guestinfo.ipaddress" = "10.0.0.42"
|
|
||||||
"guestinfo.prefixlength" = "24"
|
|
||||||
"guestinfo.dnsserver" = "10.0.0.21"
|
|
||||||
"guestinfo.gateway" = "10.0.0.1"
|
|
||||||
|
|
||||||
"addsconfig.domainname" = "srv.io"
|
|
||||||
"addsconfig.username" = "SRV\\Administrator"
|
|
||||||
"addsconfig.password" = var.adds_password
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clone {
|
|
||||||
template_uuid = vsphere_content_library_item.Server2019.id
|
|
||||||
}
|
|
||||||
|
|
||||||
depends_on = [
|
depends_on = [
|
||||||
vsphere_virtual_machine.TF-DC01
|
vsphere_virtual_machine.vm-dc
|
||||||
]
|
]
|
||||||
|
|
||||||
# # This does not actually achieve protection from destruction, see https://github.com/hashicorp/terraform/issues/17599
|
# # This does not actually achieve protection from destruction, see https://github.com/hashicorp/terraform/issues/17599
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
resource "vsphere_content_library" "library" {
|
|
||||||
name = "OVA appliances"
|
|
||||||
storage_backing = flatten([
|
|
||||||
data.vsphere_datastore.cldatastore.id
|
|
||||||
])
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "vsphere_content_library_item" "Server2019" {
|
|
||||||
name = "Windows-Server-2019-LTSC"
|
|
||||||
library_id = vsphere_content_library.library.id
|
|
||||||
file_url = "https://${var.repo_username}:${var.repo_password}@sn.itch.fyi/Repository/rel/Windows-Server-2019-LTSC.ova"
|
|
||||||
}
|
|
||||||
resource "vsphere_content_library_item" "ADCS" {
|
|
||||||
name = "ADCS-appliance"
|
|
||||||
library_id = vsphere_content_library.library.id
|
|
||||||
file_url = "https://${var.repo_username}:${var.repo_password}@sn.itch.fyi/Repository/rel/ADCS-appliance.ova"
|
|
||||||
}
|
|
||||||
resource "vsphere_content_library_item" "ADDS" {
|
|
||||||
name = "ADDS-appliance"
|
|
||||||
library_id = vsphere_content_library.library.id
|
|
||||||
file_url = "https://${var.repo_username}:${var.repo_password}@sn.itch.fyi/Repository/rel/ADDS-appliance.ova"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "vsphere_content_library_item" "Win10" {
|
|
||||||
name = "Windows 10"
|
|
||||||
library_id = vsphere_content_library.library.id
|
|
||||||
file_url = "https://${var.repo_username}:${var.repo_password}@sn.itch.fyi/Repository/rel/Windows10.ova"
|
|
||||||
}
|
|
@ -4,38 +4,39 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
vsphere = {
|
vsphere = {
|
||||||
source = "hashicorp/vsphere"
|
source = "hashicorp/vsphere"
|
||||||
version = "~> 1.24.3"
|
version = "~> 1.25.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
provider "vsphere" {
|
provider "vsphere" {
|
||||||
vsphere_server = var.vcenter_server
|
vsphere_server = var.hv_fqdn
|
||||||
user = var.vsphere_username
|
user = var.hv_username
|
||||||
password = var.vsphere_password
|
password = var.hv_password
|
||||||
|
|
||||||
allow_unverified_ssl = true
|
allow_unverified_ssl = true
|
||||||
}
|
}
|
||||||
|
|
||||||
data "vsphere_datacenter" "dc" {
|
data "vsphere_datacenter" "dc" {
|
||||||
name = var.vsphere_datacenter
|
name = var.hv_datacenter
|
||||||
}
|
}
|
||||||
|
|
||||||
data "vsphere_resource_pool" "pool" {
|
data "vsphere_resource_pool" "pool" {
|
||||||
name = "/${var.vsphere_datacenter}/host/${var.vsphere_host}/Resources"
|
name = "/${var.hv_datacenter}/host/${var.hv_host}/Resources"
|
||||||
datacenter_id = data.vsphere_datacenter.dc.id
|
datacenter_id = data.vsphere_datacenter.dc.id
|
||||||
}
|
}
|
||||||
|
|
||||||
data "vsphere_datastore" "vmdatastore" {
|
data "vsphere_host" "host" {
|
||||||
name = var.vsphere_vmdatastore
|
name = var.hv_host
|
||||||
datacenter_id = data.vsphere_datacenter.dc.id
|
datacenter = data.vsphere_datacenter.dc.id
|
||||||
}
|
}
|
||||||
data "vsphere_datastore" "cldatastore" {
|
|
||||||
name = var.vsphere_cldatastore
|
data "vsphere_datastore" "datastore" {
|
||||||
|
name = var.hv_datastore
|
||||||
datacenter_id = data.vsphere_datacenter.dc.id
|
datacenter_id = data.vsphere_datacenter.dc.id
|
||||||
}
|
}
|
||||||
|
|
||||||
data "vsphere_network" "network" {
|
data "vsphere_network" "network" {
|
||||||
name = var.vsphere_network
|
name = var.hv_network
|
||||||
datacenter_id = data.vsphere_datacenter.dc.id
|
datacenter_id = data.vsphere_datacenter.dc.id
|
||||||
}
|
}
|
@ -1,17 +1,29 @@
|
|||||||
variable "vcenter_server" {}
|
variable "hv_fqdn" {}
|
||||||
variable "vsphere_username" {}
|
variable "hv_username" {}
|
||||||
variable "vsphere_password" {}
|
variable "hv_password" {}
|
||||||
|
|
||||||
variable "vsphere_datacenter" {}
|
variable "hv_datacenter" {}
|
||||||
variable "vsphere_host" {}
|
variable "hv_host" {}
|
||||||
variable "vsphere_hostip" {}
|
variable "hv_hostip" {}
|
||||||
|
|
||||||
variable "vsphere_vmdatastore" {}
|
variable "hv_datastore" {}
|
||||||
variable "vsphere_cldatastore" {}
|
variable "hv_vmfolder" {}
|
||||||
variable "vsphere_vmfolder" {}
|
variable "hv_network" {}
|
||||||
variable "vsphere_network" {}
|
|
||||||
|
|
||||||
variable "repo_username" {}
|
variable "repo_username" {}
|
||||||
variable "repo_password" {}
|
variable "repo_password" {}
|
||||||
|
|
||||||
variable "adds_password" {}
|
variable "vm_numcpu" {}
|
||||||
|
variable "vm_memory" {}
|
||||||
|
|
||||||
|
variable "adds_domainname" {}
|
||||||
|
variable "adds_netbiosname" {}
|
||||||
|
variable "adds_username" {}
|
||||||
|
variable "adds_password" {}
|
||||||
|
variable "adds_ntpserver" {}
|
||||||
|
|
||||||
|
variable "dhcp_startip" {}
|
||||||
|
variable "dhcp_endip" {}
|
||||||
|
variable "dhcp_subnetmask" {}
|
||||||
|
variable "dhcp_gateway" {}
|
||||||
|
variable "dhcp_leaseduration" {}
|
13
terraform/vm.tfvars
Normal file
13
terraform/vm.tfvars
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
vm_numcpu = 2
|
||||||
|
vm_memory = 4096
|
||||||
|
|
||||||
|
adds_domainname = "srv.io"
|
||||||
|
adds_netbiosname = "SRV"
|
||||||
|
adds_username = "SRV\\Administrator"
|
||||||
|
adds_ntpserver = "0.pool.ntp.org,1.pool.ntp.org,2.pool.ntp.org"
|
||||||
|
|
||||||
|
dhcp_startip = "10.0.0.50"
|
||||||
|
dhcp_endip = "10.0.0.250"
|
||||||
|
dhcp_subnetmask = "255.255.255.0"
|
||||||
|
dhcp_gateway = "10.0.0.1"
|
||||||
|
dhcp_leaseduration = "01:00:00.00"
|
@ -1,9 +1,9 @@
|
|||||||
vcenter_server = "bv11-vc01.bessems.lan"
|
hv_server = "bv11-vc01.bessems.lan"
|
||||||
vsphere_username = "administrator@vsphere.local"
|
hv_username = "administrator@vsphere.local"
|
||||||
vsphere_datacenter = "DeSchakel"
|
hv_datacenter = "DeSchakel"
|
||||||
vsphere_host = "bv11-esx.bessems.eu"
|
hv_host = "bv11-esx.bessems.eu"
|
||||||
vsphere_hostip = "192.168.11.200"
|
hv_hostip = "192.168.11.200"
|
||||||
vsphere_vmdatastore = "Datastore02.SSD"
|
hv_vmdatastore = "Datastore02.SSD"
|
||||||
vsphere_cldatastore = "Datastore01.NAS"
|
hv_cldatastore = "Datastore01.NAS"
|
||||||
vsphere_vmfolder = "/Terraform"
|
hv_vmfolder = "/Terraform"
|
||||||
vsphere_network = "Isolated"
|
hv_network = "Isolated"
|
||||||
|
Loading…
Reference in New Issue
Block a user