forked from openshift-metal3/kni-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite terraform to support dynamic number of nodes
Change the data structure to accept data of nodes using maps. This will allow to add a variable number of masters (1,3) in the future. Added a new dependency on rodaine/hclencoder, to render terraform data in HCL instead of JSON, to avoid a bug in JSON parsing: hashicorp/terraform#15549
- Loading branch information
Showing
32 changed files
with
799 additions
and
229 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,31 @@ | ||
# FIXME: This Terraform HCL file defines the 3 master nodes. It uses the original ironic_nodes.json format, | ||
# flattened because Terraform v0.11 does not support nested data structures. Maps may only be key/value | ||
# pairs. We could use terraform's resource `count` provider to have just one resource declaration, but | ||
# the data would have to be structured differently. | ||
|
||
resource "ironic_node_v1" "openshift-master-0" { | ||
name = "${var.master_0["name"]}" | ||
resource "ironic_node_v1" "openshift-master" { | ||
count = "${length(keys(var.master_nodes))}" | ||
name = "${lookup(var.master_nodes[format("openshift-master-%d", count.index)], "name")}" | ||
|
||
target_provision_state = "active" | ||
user_data = "${var.ignition}" | ||
root_device = "${var.root_device_0}" | ||
driver = "${var.master_0["driver"]}" | ||
driver_info = "${var.driver_info_0}" | ||
|
||
ports = [ | ||
{ | ||
address = "${var.master_0["port_address"]}" | ||
pxe_enabled = "true" | ||
}, | ||
] | ||
|
||
properties = "${var.properties_0}" | ||
|
||
instance_info = { | ||
image_source = "${var.image_source}" | ||
image_checksum = "${var.image_checksum}" | ||
root_gb = "${var.root_gb}" | ||
} | ||
|
||
management_interface = "${var.master_0["management_interface"]}" | ||
power_interface = "${var.master_0["power_interface"]}" | ||
vendor_interface = "${var.master_0["vendor_interface"]}" | ||
} | ||
|
||
resource "ironic_node_v1" "openshift-master-1" { | ||
name = "${var.master_1["name"]}" | ||
|
||
target_provision_state = "active" | ||
user_data = "${var.ignition}" | ||
root_device = "${var.root_device_1}" | ||
driver = "${var.master_1["driver"]}" | ||
driver_info = "${var.driver_info_1}" | ||
root_device = "${var.root_devices[format("openshift-master-%d", count.index)]}" | ||
driver = "${lookup(var.master_nodes[format("openshift-master-%d", count.index)], "driver")}" | ||
driver_info = "${var.driver_infos[format("openshift-master-%d", count.index)]}" | ||
|
||
ports = [ | ||
{ | ||
address = "${var.master_1["port_address"]}" | ||
address = "${lookup(var.master_nodes[format("openshift-master-%d", count.index)], "port_address")}" | ||
pxe_enabled = "true" | ||
}, | ||
] | ||
|
||
properties = "${var.properties_1}" | ||
properties = "${var.properties[format("openshift-master-%d", count.index)]}" | ||
|
||
instance_info = { | ||
image_source = "${var.image_source}" | ||
image_checksum = "${var.image_checksum}" | ||
root_gb = "${var.root_gb}" | ||
} | ||
|
||
management_interface = "${var.master_1["management_interface"]}" | ||
power_interface = "${var.master_1["power_interface"]}" | ||
vendor_interface = "${var.master_1["vendor_interface"]}" | ||
} | ||
|
||
resource "ironic_node_v1" "openshift-master-2" { | ||
name = "${var.master_2["name"]}" | ||
|
||
target_provision_state = "active" | ||
user_data = "${var.ignition}" | ||
root_device = "${var.root_device_2}" | ||
driver = "${var.master_2["driver"]}" | ||
driver_info = "${var.driver_info_2}" | ||
|
||
ports = [ | ||
{ | ||
address = "${var.master_2["port_address"]}" | ||
pxe_enabled = "true" | ||
}, | ||
] | ||
|
||
properties = "${var.properties_2}" | ||
|
||
instance_info = { | ||
image_source = "${var.image_source}" | ||
image_checksum = "${var.image_checksum}" | ||
root_gb = "${var.root_gb}" | ||
} | ||
management_interface = "${lookup(var.master_nodes[format("openshift-master-%d", count.index)], "management_interface")}" | ||
power_interface = "${lookup(var.master_nodes[format("openshift-master-%d", count.index)], "power_interface")}" | ||
vendor_interface = "${lookup(var.master_nodes[format("openshift-master-%d", count.index)], "vendor_interface")}" | ||
|
||
management_interface = "${var.master_2["management_interface"]}" | ||
power_interface = "${var.master_2["power_interface"]}" | ||
vendor_interface = "${var.master_2["vendor_interface"]}" | ||
} |
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
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
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.