Skip to content
This repository has been archived by the owner on Jul 23, 2019. It is now read-only.

Commit

Permalink
Updated install config
Browse files Browse the repository at this point in the history
  • Loading branch information
stbenjam committed May 31, 2019
1 parent 7c8f08a commit 48d1750
Show file tree
Hide file tree
Showing 23 changed files with 863 additions and 126 deletions.
18 changes: 18 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,7 @@ required = [
branch = "master"
name = "github.com/metal3-io/cluster-api-provider-baremetal"
source = "github.com/openshift/cluster-api-provider-baremetal/pkg/apis"

[[constraint]]
branch = "master"
name = "github.com/metal3-io/baremetal-operator"
15 changes: 7 additions & 8 deletions data/data/baremetal/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ module "bootstrap" {
module "masters" {
source = "./masters"

ignition = var.ignition_master
image_source = var.master_configuration["image_source"]
image_checksum = var.master_configuration["image_checksum"]
root_gb = var.master_configuration["root_gb"]
master_count = var.master_count
ignition = var.ignition_master

master_nodes = var.master_nodes
properties = var.properties
root_devices = var.root_devices
driver_infos = var.driver_infos
hosts = var.hosts
properties = var.properties
root_devices = var.root_devices
driver_infos = var.driver_infos
instance_infos = var.instance_infos
}

35 changes: 13 additions & 22 deletions data/data/baremetal/masters/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "ironic_node_v1" "openshift-master-node" {
count = length(keys(var.master_nodes))
name = var.master_nodes[format("openshift-master-%d", count.index)]["name"]
resource "ironic_node_v1" "openshift-master-host" {
count = var.master_count
name = var.hosts[count.index]["name"]
resource_class = "baremetal"

inspect = true
Expand All @@ -9,43 +9,34 @@ resource "ironic_node_v1" "openshift-master-node" {

ports = [
{
address = var.master_nodes[format("openshift-master-%d", count.index)]["port_address"]
address = var.hosts[count.index]["port_address"]
pxe_enabled = "true"
},
]

properties = var.properties[format("openshift-master-%d", count.index)]
root_device = var.root_devices[format("openshift-master-%d", count.index)]
properties = var.properties[count.index]
root_device = var.root_devices[count.index]

driver = var.master_nodes[format("openshift-master-%d", count.index)]["driver"]
driver_info = var.driver_infos[format("openshift-master-%d", count.index)]

management_interface = var.master_nodes[format("openshift-master-%d", count.index)]["management_interface"]
power_interface = var.master_nodes[format("openshift-master-%d", count.index)]["power_interface"]
vendor_interface = var.master_nodes[format("openshift-master-%d", count.index)]["vendor_interface"]
driver = var.hosts[count.index]["driver"]
driver_info = var.driver_infos[count.index]
}

resource "ironic_allocation_v1" "openshift-master-allocation" {
name = "master-${count.index}"
count = 3
count = var.master_count
resource_class = "baremetal"

candidate_nodes = ironic_node_v1.openshift-master-node.*.id
candidate_nodes = ironic_node_v1.openshift-master-host.*.id
}

resource "ironic_deployment" "openshift-master-deployment" {
count = 3
count = var.master_count
node_uuid = element(
ironic_allocation_v1.openshift-master-allocation.*.node_uuid,
count.index,
)

instance_info = {
image_source = var.image_source
image_checksum = var.image_checksum
root_gb = var.root_gb
}

user_data = var.ignition
instance_info = var.instance_infos[count.index]
user_data = var.ignition
}

39 changes: 17 additions & 22 deletions data/data/baremetal/masters/variables.tf
Original file line number Diff line number Diff line change
@@ -1,40 +1,35 @@
variable "image_source" {
description = "The URL of the OS disk image"
variable "master_count" {
type = string
description = "Number of masters"
default = 3
}

variable "image_checksum" {
type = string
description = "The URL or checksum value of the image"
}

variable "root_gb" {
type = string
description = "Size of the root disk"
}

variable "ignition" {
type = string
description = "The content of the master ignition file"
}

variable "master_nodes" {
type = map(map(string))
description = "Master bare metal node details"
variable "hosts" {
type = list(map(string))
description = "Hardware details for hosts"
}

variable "properties" {
type = map(map(string))
description = "Master bare metal properties"
type = list(map(string))
description = "Properties for hosts"
}

variable "root_devices" {
type = map(map(string))
description = "Master root device configuration"
type = list(map(string))
description = "Root devices for hosts"
}

variable "driver_infos" {
type = map(map(string))
description = "Master driver info"
type = list(map(string))
description = "BMC information for hosts"
}

variable "instance_infos" {
type = list(map(string))
description = "Instance information for hosts"
}

28 changes: 14 additions & 14 deletions data/data/baremetal/variables-baremetal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,28 @@ variable "provisioning_bridge" {
description = "The name of the provisioning bridge"
}

variable "master_configuration" {
type = map(string)
description = "Configuration information for masters such as image location"
}

variable "master_nodes" {
type = map(map(string))
description = "Master bare metal node details"
variable "hosts" {
type = list(map(string))
description = "Hardware details for hosts"
}

variable "properties" {
type = map(map(string))
description = "Master bare metal properties"
type = list(map(string))
description = "Properties for hosts"
}

variable "root_devices" {
type = map(map(string))
description = "Master root device configurations"
type = list(map(string))
description = "Root devices for hosts"
}

variable "driver_infos" {
type = map(map(string))
description = "Master driver infos"
type = list(map(string))
description = "BMC information for hosts"
}

variable "instance_infos" {
type = list(map(string))
description = "Instance information for hosts"
}

5 changes: 2 additions & 3 deletions pkg/asset/cluster/tfvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,14 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
Data: data,
})
case baremetal.Name:
// FIXME:: baremetal
data, err = baremetaltfvars.TFVars(
installConfig.Config.Platform.BareMetal.LibvirtURI,
installConfig.Config.Platform.BareMetal.IronicURI,
string(*rhcosImage),
"baremetal",
"provisioning",
installConfig.Config.Platform.BareMetal.Nodes,
installConfig.Config.Platform.BareMetal.MasterConfiguration,
installConfig.Config.Platform.BareMetal.Hosts,
installConfig.Config.Platform.BareMetal.Image,
)
if err != nil {
return errors.Wrapf(err, "failed to get %s Terraform variables", platform)
Expand Down
52 changes: 32 additions & 20 deletions pkg/asset/installconfig/baremetal/baremetal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package baremetal

import (
"encoding/json"
"fmt"
"gopkg.in/AlecAivazis/survey.v1"

"github.com/openshift-metalkube/kni-installer/pkg/types/baremetal"
Expand All @@ -12,7 +12,9 @@ import (

// Platform collects bare metal specific configuration.
func Platform() (*baremetal.Platform, error) {
var libvirtURI, ironicURI, externalBridge, provisioningBridge, apiVIP, nodesJSON string
var libvirtURI, ironicURI, externalBridge, provisioningBridge, apiVIP string
var hosts []*baremetal.Host

err := survey.Ask([]*survey.Question{
{
Prompt: &survey.Input{
Expand Down Expand Up @@ -69,23 +71,6 @@ func Platform() (*baremetal.Platform, error) {
return nil, err
}

err = survey.Ask([]*survey.Question{
{
Prompt: &survey.Input{
Message: "Master node definition JSON",
Help: "JSON data containing information about the baremetal nodes for use by Ironic.",
},
},
}, &nodesJSON)
if err != nil {
return nil, err
}

var nodes map[string]interface{}
if err = json.Unmarshal([]byte(nodesJSON), &nodes); err != nil {
return nil, err
}

err = survey.Ask([]*survey.Question{
{
Prompt: &survey.Input{
Expand All @@ -99,13 +84,35 @@ func Platform() (*baremetal.Platform, error) {
return nil, err
}

// Keep prompting for hosts
for {
var host *baremetal.Host
host, err = Host()
host.Role = "master" // FIXME(stbenjam): Support workers

if err != nil {
fmt.Printf("Invalid host - please try again")
continue
}
hosts = append(hosts, host)

more := false
prompt := &survey.Confirm{
Message: "Add another?",
}
survey.AskOne(prompt, &more, nil)
if !more {
break
}
}

return &baremetal.Platform{
LibvirtURI: libvirtURI,
IronicURI: ironicURI,
Nodes: nodes,
ApiVIP: apiVIP,
ExternalBridge: externalBridge,
ProvisioningBridge: provisioningBridge,
Hosts: hosts,
}, nil
}

Expand All @@ -125,3 +132,8 @@ func ipValidator(ans interface{}) error {
func interfaceValidator(ans interface{}) error {
return validate.Interface(ans.(string))
}

// macValidator validates if the answer provided is a valid mac address
func macValidator(ans interface{}) error {
return validate.MAC(ans.(string))
}
Loading

0 comments on commit 48d1750

Please sign in to comment.