Reputation: 1
currently I am trying to completely automate a VMware virtualization environment. This includes multiple ESXi server and one central vCenter to manage everything. Therefore I want to deploy the following this in order:
Therefore I wrote a dedicated module for the creation of all VM's according to an separate list in json.
My thought is, to deploy everything in one step. I already implemented the 'depends_on' dependencies to every resource which depends on the other resources but some I always get the error "there must be at least one disk specified".
This are my related files:
datasources.tf:
########### General ###########
data "vsphere_datacenter" "dc" {
name = "DATACENTER"
}
########### Network ###########
data "vsphere_distributed_virtual_switch" "vds" {
name = var.project_vds
datacenter_id = data.vsphere_datacenter.dc.id
}
########## Datastore ##########
data "vsphere_host" "host" {
name = "esx1"
datacenter_id = data.vsphere_datacenter.dc.id
}
data "vsphere_vmfs_disks" "available" {
host_system_id = data.vsphere_host.host.id
rescan = true
filter = "eui.a"
}
data "vsphere_folder" "folder_datastore" {
path = "/${data.vsphere_datacenter.dc.name}/datastore/Projects_Vvols/${var.project_country}"
}
data "vsphere_datastore" "datastore" {
name = vsphere_vmfs_datastore.datastore.name
datacenter_id = data.vsphere_datacenter.dc.id
}
datastore.tf:
resource "vsphere_vmfs_datastore" "datastore" {
name = "PRO-${var.project_year}-${var.project_country_iso3}-${var.project_type}"
host_system_id = "${data.vsphere_host.host.id}"
folder = data.vsphere_folder.folder_datastore.path
disks = data.vsphere_vmfs_disks.available.disks
depends_on = [ data.vsphere_vmfs_disks.available ]
}
In my main.tf is the module included. Here are the most important values:
datastore = local.project_datastore
vmfolder = local.project_vmfolder_root
depends_on = [
vsphere_distributed_port_group.pg,
data.vsphere_folder.folder_datastore,
vsphere_vmfs_datastore.datastore,
vsphere_folder.folder_vm,
data.vsphere_vmfs_disks.available ]
I would appreciate a lot of help Thank you in advance.
I already tried to change the dependencies. But unfortunately nothing worked for me. The only thing which worked, was to use an existing VMFS datastore or to deploy the virtual machines with the -target function when I previously deploy the infrastructure.
Upvotes: 0
Views: 78