-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Adding terraform for vSphere IPI; changes to tfvars to support it #2841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| resource "vsphere_virtual_machine" "vm" { | ||
| name = "${var.cluster_id}-bootstrap" | ||
| resource_pool_id = var.resource_pool | ||
| datastore_id = var.datastore | ||
| num_cpus = 4 | ||
| memory = 16384 | ||
| guest_id = var.guest_id | ||
| folder = var.folder | ||
| enable_disk_uuid = "true" | ||
|
|
||
| wait_for_guest_net_timeout = 0 | ||
| wait_for_guest_net_routable = false | ||
|
|
||
| network_interface { | ||
| network_id = var.network | ||
| } | ||
|
|
||
| disk { | ||
| label = "disk0" | ||
| size = 120 | ||
| } | ||
|
|
||
| clone { | ||
| template_uuid = var.template | ||
| } | ||
|
|
||
| extra_config = { | ||
| "guestinfo.ignition.config.data" = base64encode(var.ignition) | ||
| "guestinfo.ignition.config.data.encoding" = "base64" | ||
| } | ||
| tags = var.tags | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| variable "ignition" { | ||
| type = string | ||
| default = "" | ||
| } | ||
|
|
||
| variable "resource_pool" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "folder" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "datastore" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "network" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "datacenter" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "template" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "guest_id" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "tags" { | ||
| type = list | ||
| } | ||
|
|
||
| variable "cluster_id" { | ||
| type = string | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| provider "vsphere" { | ||
| user = var.vsphere_username | ||
| password = var.vsphere_password | ||
| vsphere_server = var.vsphere_url | ||
| allow_unverified_ssl = false | ||
| } | ||
|
|
||
| data "vsphere_datacenter" "datacenter" { | ||
| name = var.vsphere_datacenter | ||
| } | ||
|
|
||
| data "vsphere_compute_cluster" "cluster" { | ||
| name = var.vsphere_cluster | ||
| datacenter_id = data.vsphere_datacenter.datacenter.id | ||
| } | ||
|
|
||
| data "vsphere_datastore" "datastore" { | ||
| name = var.vsphere_datastore | ||
| datacenter_id = data.vsphere_datacenter.datacenter.id | ||
| } | ||
|
|
||
| data "vsphere_network" "network" { | ||
| name = var.vsphere_network | ||
| datacenter_id = data.vsphere_datacenter.datacenter.id | ||
| } | ||
|
|
||
| data "vsphere_virtual_machine" "template" { | ||
| name = var.vsphere_template | ||
| datacenter_id = data.vsphere_datacenter.datacenter.id | ||
| } | ||
|
|
||
| resource "vsphere_tag_category" "category" { | ||
| name = "openshift-${var.cluster_id}" | ||
| description = "Added by openshift-install do not remove" | ||
| cardinality = "SINGLE" | ||
|
|
||
| associable_types = [ | ||
| "VirtualMachine", | ||
| "ResourcePool", | ||
| "Folder" | ||
| ] | ||
| } | ||
|
|
||
| resource "vsphere_tag" "tag" { | ||
| name = var.cluster_id | ||
| category_id = vsphere_tag_category.category.id | ||
| description = "Added by openshift-install do not remove" | ||
| } | ||
|
|
||
| resource "vsphere_folder" "folder" { | ||
jcpowermac marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| path = var.vsphere_folder | ||
| type = "vm" | ||
| datacenter_id = data.vsphere_datacenter.datacenter.id | ||
| tags = [vsphere_tag.tag.id] | ||
| } | ||
|
|
||
|
|
||
| module "bootstrap" { | ||
| source = "./bootstrap" | ||
|
|
||
| ignition = var.ignition_bootstrap | ||
| resource_pool = data.vsphere_compute_cluster.cluster.resource_pool_id | ||
| datastore = data.vsphere_datastore.datastore.id | ||
| folder = vsphere_folder.folder.path | ||
| network = data.vsphere_network.network.id | ||
| datacenter = data.vsphere_datacenter.datacenter.id | ||
| template = data.vsphere_virtual_machine.template.id | ||
| guest_id = data.vsphere_virtual_machine.template.guest_id | ||
|
|
||
| cluster_id = var.cluster_id | ||
| tags = [vsphere_tag.tag.id] | ||
| } | ||
|
|
||
| module "master" { | ||
| source = "./master" | ||
|
|
||
| // limitation of baremetal-runtimecfg. The hostname must be master | ||
| name = "master" | ||
jcpowermac marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
jcpowermac marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| instance_count = var.master_count | ||
| ignition = var.ignition_master | ||
|
|
||
| resource_pool = data.vsphere_compute_cluster.cluster.resource_pool_id | ||
| datastore = data.vsphere_datastore.datastore.id | ||
| folder = vsphere_folder.folder.path | ||
| network = data.vsphere_network.network.id | ||
| datacenter = data.vsphere_datacenter.datacenter.id | ||
| template = data.vsphere_virtual_machine.template.id | ||
| guest_id = data.vsphere_virtual_machine.template.guest_id | ||
| tags = [vsphere_tag.tag.id] | ||
|
|
||
| cluster_domain = var.cluster_domain | ||
| cluster_id = var.cluster_id | ||
| memory = var.control_plane_memory_mib | ||
| num_cpus = var.control_plane_num_cpus | ||
| disk_size = var.control_plane_disk_gib | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| locals { | ||
| ignition_encoded = "data:text/plain;charset=utf-8;base64,${base64encode(var.ignition)}" | ||
| } | ||
|
|
||
| data "ignition_file" "hostname" { | ||
|
||
| count = var.instance_count | ||
|
|
||
|
||
| filesystem = "root" | ||
| path = "/etc/hostname" | ||
| mode = "420" | ||
|
|
||
| content { | ||
| content = "${var.name}-${count.index}" | ||
jcpowermac marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
jcpowermac marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| data "ignition_config" "ign" { | ||
| count = var.instance_count | ||
|
|
||
| append { | ||
| source = local.ignition_encoded | ||
| } | ||
|
|
||
| files = [ | ||
| data.ignition_file.hostname[count.index].rendered | ||
| ] | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| resource "vsphere_virtual_machine" "vm" { | ||
| count = var.instance_count | ||
|
|
||
| name = "${var.cluster_id}-${var.name}-${count.index}" | ||
| resource_pool_id = var.resource_pool | ||
| datastore_id = var.datastore | ||
| num_cpus = var.num_cpus | ||
| memory = var.memory | ||
| guest_id = var.guest_id | ||
| folder = var.folder | ||
| enable_disk_uuid = "true" | ||
|
|
||
| wait_for_guest_net_timeout = "0" | ||
| wait_for_guest_net_routable = "false" | ||
jcpowermac marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| network_interface { | ||
| network_id = var.network | ||
| } | ||
|
|
||
| disk { | ||
| label = "disk0" | ||
| size = var.disk_size | ||
| } | ||
|
|
||
| clone { | ||
| template_uuid = var.template | ||
| } | ||
|
|
||
| extra_config = { | ||
| "guestinfo.ignition.config.data" = base64encode(data.ignition_config.ign[count.index].rendered) | ||
| "guestinfo.ignition.config.data.encoding" = "base64" | ||
| } | ||
|
|
||
| tags = var.tags | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| variable "name" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "instance_count" { | ||
| type = number | ||
| } | ||
|
|
||
| variable "ignition" { | ||
| type = string | ||
| default = "" | ||
| } | ||
|
|
||
| variable "resource_pool" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "folder" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "datastore" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "network" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "cluster_domain" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "datacenter" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "template" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "guest_id" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "memory" { | ||
| type = number | ||
| } | ||
|
|
||
| variable "num_cpus" { | ||
| type = number | ||
| } | ||
|
|
||
| variable "disk_size" { | ||
| type = number | ||
| } | ||
|
|
||
| variable "tags" { | ||
| type = list | ||
| } | ||
|
|
||
| variable "cluster_id" { | ||
| type = string | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
|
|
||
| terraform { | ||
| required_version = ">= 0.12" | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.