Created
January 3, 2019 05:23
-
-
Save zpratt/0ad7bcf382b321501bd92e958bf9f8a9 to your computer and use it in GitHub Desktop.
vcsim attempt (and fail)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vsphere_user="user" | |
vsphere_password="pass" | |
vsphere_host = "127.0.0.1:8989" | |
datacenter = "DC0" | |
cluster = "DC0_H0" | |
datastore = "datastore/LocalDS_0" | |
clustered_datastore = "" | |
network = "network/VM Network" | |
gateway = "192.168.1.1" | |
vm_folder = "vcsim-test-folder" | |
vm_name = "vcsim-test" | |
subnet_mask = "24" | |
ips = [ | |
"10.134.3.162", | |
"10.134.3.163" | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "vsphere_folder" "inventory_folder" { | |
path = "${var.vm_folder}" | |
type = "vm" | |
datacenter_id = "${data.vsphere_datacenter.datacenter.id}" | |
} | |
resource "vsphere_virtual_machine" "test-node" { | |
count = "${length(var.ips)}" | |
name = "${var.vm_name}-master-${count.index}" | |
resource_pool_id = "${data.vsphere_resource_pool.pool.id}" | |
datastore_id = "${data.vsphere_datastore.datastore.id}" | |
num_cpus = 2 | |
memory = 8192 | |
folder = "${vsphere_folder.inventory_folder.path}" | |
network_interface { | |
network_id = "${data.vsphere_network.network.id}" | |
adapter_type = "vmxnet3" | |
} | |
disk { | |
label = "${var.vm_name}-master-${count.index}-disk" | |
size = "20" | |
thin_provisioned = true | |
unit_number = 0 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "vsphere_user" { | |
type = "string" | |
} | |
variable "vsphere_password" { | |
type = "string" | |
} | |
variable "vsphere_host" { | |
type = "string" | |
} | |
variable "datacenter" { | |
type = "string" | |
} | |
variable "cluster" { | |
type = "string" | |
} | |
variable "datastore" { | |
type = "string" | |
} | |
variable "network" { | |
type = "string" | |
} | |
variable "vm_name" { | |
type = "string" | |
} | |
variable "vm_folder" { | |
type = "string" | |
} | |
variable "clustered_datastore" { | |
type = "string" | |
} | |
variable "gateway" { | |
type = "string" | |
} | |
variable "ips" { | |
type = "list" | |
} | |
variable "subnet_mask" { | |
default = "" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider "vsphere" { | |
user = "${var.vsphere_user}" | |
password = "${var.vsphere_password}" | |
vsphere_server = "${var.vsphere_host}" | |
allow_unverified_ssl = true | |
version = "~> 1.9" | |
} | |
data "vsphere_datacenter" "datacenter" { | |
name = "${var.datacenter}" | |
} | |
data "vsphere_datastore" "datastore" { | |
name = "${var.datastore}" | |
datacenter_id = "${data.vsphere_datacenter.datacenter.id}" | |
} | |
data "vsphere_network" "network" { | |
name = "${var.network}" | |
datacenter_id = "${data.vsphere_datacenter.datacenter.id}" | |
} | |
data "vsphere_resource_pool" "pool" { | |
name = "${var.cluster}/Resources" | |
datacenter_id = "${data.vsphere_datacenter.datacenter.id}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment