Skip to content
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

[wip] vSphere - Use extra_config inplace of vApp; use terraform file for ign #2479

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions upi/vsphere/machine/ignition.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,13 @@ EOF
}
}

data "ignition_systemd_unit" "restart" {
count = "${var.instance_count}"

name = "restart.service"

content = <<EOF
[Unit]
ConditionFirstBoot=yes
[Service]
Type=idle
ExecStart=/sbin/reboot
[Install]
WantedBy=multi-user.target
EOF
}

data "ignition_config" "ign" {
count = "${var.instance_count}"

append {
source = "${var.ignition_url != "" ? var.ignition_url : local.ignition_encoded}"
source = "${local.ignition_encoded}"
}

systemd = [
"${data.ignition_systemd_unit.restart.*.id[count.index]}",
]

files = [
"${data.ignition_file.hostname.*.id[count.index]}",
"${data.ignition_file.static_ip.*.id[count.index]}",
Expand Down
5 changes: 1 addition & 4 deletions upi/vsphere/machine/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ resource "vsphere_virtual_machine" "vm" {
clone {
template_uuid = "${data.vsphere_virtual_machine.template.id}"
}

vapp {
properties {
extra_config {
"guestinfo.ignition.config.data" = "${base64encode(data.ignition_config.ign.*.rendered[count.index])}"
"guestinfo.ignition.config.data.encoding" = "base64"
}
}
}
5 changes: 0 additions & 5 deletions upi/vsphere/machine/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ variable "ignition" {
default = ""
}

variable "ignition_url" {
type = "string"
default = ""
}

variable "resource_pool_id" {
type = "string"
}
Expand Down
6 changes: 3 additions & 3 deletions upi/vsphere/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module "bootstrap" {

name = "bootstrap"
instance_count = "${var.bootstrap_complete ? 0 : 1}"
ignition_url = "${var.bootstrap_ignition_url}"
ignition = "${file("${var.bootstrap_ignition_path}")}"
resource_pool_id = "${module.resource_pool.pool_id}"
datastore = "${var.vsphere_datastore}"
folder = "${module.folder.path}"
Expand All @@ -50,7 +50,7 @@ module "control_plane" {

name = "control-plane"
instance_count = "${var.control_plane_count}"
ignition = "${var.control_plane_ignition}"
ignition = "${file("${var.control_plane_ignition_path}")}"
resource_pool_id = "${module.resource_pool.pool_id}"
folder = "${module.folder.path}"
datastore = "${var.vsphere_datastore}"
Expand All @@ -71,7 +71,7 @@ module "compute" {

name = "compute"
instance_count = "${var.compute_count}"
ignition = "${var.compute_ignition}"
ignition = "${file("${var.compute_ignition_path}")}"
resource_pool_id = "${module.resource_pool.pool_id}"
folder = "${module.folder.path}"
datastore = "${var.vsphere_datastore}"
Expand Down
26 changes: 10 additions & 16 deletions upi/vsphere/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,24 @@ vsphere_datastore = "nvme-ds1"
vm_template = "rhcos-latest"

// The machine_cidr where IP addresses will be assigned for cluster nodes.
// Additionally, IPAM will assign IPs based on the network ID.
// Additionally, IPAM will assign IPs based on the network ID.
machine_cidr = "10.0.0.0/24"

// Path to the bootstrap ignition file
bootstrap_ignition_path = "${path.module}/bootstrap.ign"

// Path to the master/control plane ignition file
control_plane_ignition_path = "${path.module}/master.ign"

// Path to the compute/worker ignition file
compute_ignition_path = "${path.module}/compute.ign"

// The number of control plane VMs to create. Default is 3.
control_plane_count = 3

// The number of compute VMs to create. Default is 3.
compute_count = 3

// URL of the bootstrap ignition. This needs to be publicly accessible so that the bootstrap machine can pull the ignition.
bootstrap_ignition_url = "URL_FOR_YOUR_BOOTSTRAP_IGNITION"

// Ignition config for the control plane machines. You should copy the contents of the master.ign generated by the installer.
control_plane_ignition = <<END_OF_MASTER_IGNITION
Copy the master ignition generated by the installer here.
END_OF_MASTER_IGNITION

// Ignition config for the compute machines. You should copy the contents of the worker.ign generated by the installer.
compute_ignition = <<END_OF_WORKER_IGNITION
Copy the worker ignition generated by the installer here.
END_OF_WORKER_IGNITION


// Set ipam and ipam_token if you want to use the IPAM server to reserve IP
// addresses for the VMs.

Expand All @@ -61,7 +56,6 @@ ipam = "139.178.89.254"
// Token to use to authenticate with the IPAM server.
ipam_token = "TOKEN_FOR_THE_IPAM_SERVER"


// Set bootstrap_ip, control_plane_ip, and compute_ip if you want to use static
// IPs reserved someone else, rather than the IPAM server.

Expand Down
24 changes: 12 additions & 12 deletions upi/vsphere/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ variable "machine_cidr" {
// Bootstrap machine variables
/////////

variable "bootstrap_complete" {
variable "bootstrap_ignition_path" {
type = "string"
default = "false"
}

variable "bootstrap_ignition_url" {
type = "string"
variable "bootstrap_complete" {
type = "string"
default = "false"
}

variable "bootstrap_ip" {
Expand All @@ -100,13 +100,13 @@ variable "bootstrap_ip" {
// Control Plane machine variables
///////////

variable "control_plane_count" {
variable "control_plane_ignition_path" {
type = "string"
default = "3"
}

variable "control_plane_ignition" {
type = "string"
variable "control_plane_count" {
type = "string"
default = "3"
}

variable "control_plane_ips" {
Expand All @@ -118,15 +118,15 @@ variable "control_plane_ips" {
// Compute machine variables
//////////

variable "compute_ignition_path" {
type = "string"
}

variable "compute_count" {
type = "string"
default = "3"
}

variable "compute_ignition" {
type = "string"
}

variable "compute_ips" {
type = "list"
default = []
Expand Down