Created
March 12, 2018 15:29
-
-
Save ryanwalder/311e9139d45f091a1d767276990b3cb8 to your computer and use it in GitHub Desktop.
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 "consul_machine_name" { default = "mgtcfgconl" } | |
resource "vsphere_virtual_machine" "consul" { | |
count = "3" | |
name = "${format("%v%02d%v", var.consul_machine_name, count.index + 1, var.environment)}" | |
num_cpus = "2" | |
memory = "1024" | |
guest_id = "${var.guest_id}" | |
datastore_id = "${data.vsphere_datastore.datastore.id}" | |
resource_pool_id = "${data.vsphere_resource_pool.pool.id}" | |
folder = "${var.vm_folder}" | |
network_interface { | |
network_id = "${data.vsphere_network.cpt-mgt-cfg-con.id}" | |
adapter_type = "vmxnet3" | |
} | |
scsi_type = "${data.vsphere_virtual_machine.template.scsi_type}" | |
disk { | |
label = "disk0" | |
size = "8" | |
} | |
clone { | |
template_uuid = "${data.vsphere_virtual_machine.template.id}" | |
customize { | |
linux_options { | |
host_name = "${format("%v%02d%v", var.consul_machine_name, count.index + 1, var.environment)}" | |
domain = "${var.domain}" | |
time_zone = "${var.timezone}" | |
} | |
dns_server_list = "${var.dns_servers}" | |
dns_suffix_list = "${var.dns_search}" | |
network_interface {} | |
} | |
} | |
connection { | |
type = "ssh" | |
user = "${var.ssh_user}" | |
password = "${var.ssh_pass}" | |
} | |
provisioner "file" { | |
content = "${data.template_file.minion.rendered}" | |
destination = "/root/bootstrap.sh" | |
} | |
provisioner "remote-exec" { | |
inline = [ | |
"chmod 744 /root/bootstrap.sh", | |
"/root/bootstrap.sh", | |
"rm -rf /root/bootstrap.sh" | |
] | |
} | |
depends_on = [ | |
"vsphere_virtual_machine.saltmaster" | |
] | |
} |
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 "jenkinsmaster_machine_name" { default = "infjenmasl" } | |
resource "vsphere_virtual_machine" "jenkinsmaster" { | |
count = "1" | |
name = "${format("%v%02d%v", var.jenkinsmaster_machine_name, count.index + 1, var.environment)}" | |
num_cpus = "2" | |
memory = "4096" | |
guest_id = "${var.guest_id}" | |
datastore_id = "${data.vsphere_datastore.datastore.id}" | |
resource_pool_id = "${data.vsphere_resource_pool.pool.id}" | |
folder = "${var.vm_folder}" | |
network_interface { | |
network_id = "${data.vsphere_network.cpt-inf-tst-rya.id}" | |
adapter_type = "vmxnet3" | |
} | |
scsi_type = "${data.vsphere_virtual_machine.template.scsi_type}" | |
disk { | |
label = "disk0" | |
size = "8" | |
} | |
clone { | |
template_uuid = "${data.vsphere_virtual_machine.template.id}" | |
customize { | |
linux_options { | |
host_name = "${format("%v%02d%v", var.consul_machine_name, count.index + 1, var.environment)}" | |
domain = "${var.domain}" | |
time_zone = "${var.timezone}" | |
} | |
dns_server_list = "${var.dns_servers}" | |
dns_suffix_list = "${var.dns_search}" | |
network_interface {} | |
} | |
} | |
connection { | |
type = "ssh" | |
user = "${var.ssh_user}" | |
password = "${var.ssh_pass}" | |
} | |
provisioner "file" { | |
content = "${data.template_file.minion.rendered}" | |
destination = "/root/bootstrap.sh" | |
} | |
provisioner "remote-exec" { | |
inline = [ | |
"chmod 744 /root/bootstrap.sh", | |
"/root/bootstrap.sh", | |
"rm -rf /root/bootstrap.sh" | |
] | |
} | |
depends_on = [ | |
"vsphere_virtual_machine.saltmaster", | |
"vsphere_virtual_machine.consul" | |
] | |
} | |
variable "jenkinsslave_machine_name" { default = "infjenslal" } | |
data "consul_keys" "jenkinsslave" { | |
key { | |
name = "count" | |
path = "terraform/jenkinsslave/count" | |
default = "2" | |
} | |
depends_on = [ | |
"vsphere_virtual_machine.consul" | |
] | |
} | |
resource "vsphere_virtual_machine" "jenkinsslave" { | |
count = "${data.consul_keys.jenkinsslave.var.count}" | |
name = "${format("%v%02d%v", var.jenkinsslave_machine_name, count.index + 1, var.environment)}" | |
num_cpus = "4" | |
memory = "8192" | |
guest_id = "${var.guest_id}" | |
datastore_id = "${data.vsphere_datastore.datastore.id}" | |
resource_pool_id = "${data.vsphere_resource_pool.pool.id}" | |
folder = "${var.vm_folder}" | |
network_interface { | |
network_id = "${data.vsphere_network.cpt-inf-tst-rya.id}" | |
adapter_type = "vmxnet3" | |
} | |
scsi_type = "${data.vsphere_virtual_machine.template.scsi_type}" | |
disk { | |
label = "disk0" | |
size = "8" | |
} | |
clone { | |
template_uuid = "${data.vsphere_virtual_machine.template.id}" | |
customize { | |
linux_options { | |
host_name = "${format("%v%02d%v", var.consul_machine_name, count.index + 1, var.environment)}" | |
domain = "${var.domain}" | |
time_zone = "${var.timezone}" | |
} | |
dns_server_list = "${var.dns_servers}" | |
dns_suffix_list = "${var.dns_search}" | |
network_interface {} | |
} | |
} | |
connection { | |
type = "ssh" | |
user = "${var.ssh_user}" | |
password = "${var.ssh_pass}" | |
} | |
provisioner "file" { | |
content = "${data.template_file.minion.rendered}" | |
destination = "/root/bootstrap.sh" | |
} | |
provisioner "remote-exec" { | |
inline = [ | |
"chmod 744 /root/bootstrap.sh", | |
"/root/bootstrap.sh", | |
"rm -rf /root/bootstrap.sh" | |
] | |
} | |
depends_on = [ | |
"vsphere_virtual_machine.jenkinsmaster", | |
"data.consul_keys.jenkinsslave" | |
] | |
} |
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 "consul" { | |
address = "10.120.0.12:8500" | |
datacenter = "dc1" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment