Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cat vcenter.tf
- terraform {
- required_version = "> 0.8.7"
- }
- # ============================================
- # Authentication to vCenter server
- provider "vsphere" {
- user = "${var.vsphere_user}"
- password = "${var.vsphere_pass}"
- vsphere_server = "${var.vsphere_server}"
- allow_unverified_ssl = true
- }
- # ============================================
- # VM config
- resource "vsphere_virtual_machine" "tes_dev" {
- count = "${var.num_nodes}"
- name = "${var.devuser}-vm-${count.index + 1}"
- time_zone = "America/Los_Angeles"
- folder = "${var.folder_name}"
- # specify the vm, not template if you use linked_clone
- linked_clone = true
- vcpu = "${var.cpus}"
- memory = "${var.mem}"
- datacenter = "${var.this_datacenter}"
- cluster = "${var.this_cluster}"
- # specify the template to use, and where to put it.
- disk {
- template = "${var.disk_template}"
- datastore = "${var.datastore_name}"
- }
- domain = "lab-2.test"
- dns_suffixes = ["lab-2.test","test.com"]
- dns_servers = [""]
- # control network interface,
- # if you don't specify the address/netmask/gateway, dhcp is assumed
- # net1 interface (CONTROL)
- network_interface {
- label = "${var.control_network_name}"
- # ipv4_address = "${var.control_network_ip[count.index]}"
- # ipv4_prefix_length = "${var.control_network_netmask}"
- # ipv4_gateway = "${var.control_network_gateway}"
- }
- # net2 interface (DATA)
- network_interface {
- label = "${var.net2_network}"
- }
- provisioner "file" {
- source = "settings"
- destination = "/home/admin"
- connection {
- type = "ssh"
- user = ""
- timeout = "30s"
- password = ""
- bastion_host = ""
- bastion_user = "test"
- }
- }
- provisioner "remote-exec" {
- inline = [
- "chmod +x /home/admin/settings/*sh",
- # "/home/admin/settings/post_terraform_deploy.sh"
- ]
- connection {
- type = "ssh"
- user = ""
- timeout = "30s"
- password = ""
- bastion_host = ""
- bastion_user = "test"
- }
- }
- }
- # ============================================
- # vsphere parameters
- ## not sure if we need folder name
- variable "this_datacenter" {
- default = "Lab1"
- }
- variable "this_cluster" {
- default = "ClusterOne"
- }
- variable "datastore_name" {
- default = "VMdatastore4"
- }
- # VM Template name
- variable "disk_template" {
- # use this if not creating linked clones
- default = "VMgroup/contiv-vm-clone"
- }
- # ============================================
- # Output section
- output "lab2_ip_addresses" {
- value = ["${vsphere_virtual_machine.contiv_dev.*.network_interface.0.ipv4_address}"]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement