GithubHelp home page GithubHelp logo

iurygregory / terraform-provider-ironic Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openshift-metal3/terraform-provider-ironic

0.0 1.0 0.0 43.84 MB

Terraform provider for Ironic

License: Apache License 2.0

Makefile 0.85% Go 98.48% Shell 0.66%

terraform-provider-ironic's Introduction

Build Status License GitHub release

Terraform provider for Ironic

This is a terraform provider that lets you provision baremetal servers managed by Ironic.

Provider

Currently the provider only supports standalone noauth Ironic. At a minimum, the Ironic endpoint URL must be specified. The user may also optionally specify an API microversion.

If you are using Ironic inspector, you may also specify the inspector URL if you'd like to use the introspection data source.

The timeout option sets the number of seconds that the provider will wait for the Ironic or Inspector API's to become available. This is useful in cases where another terraform provider is responsible for bringing up the Ironic infrastructure.

provider "ironic" {
  url          = "http://localhost:6385/v1"
  inspector    = "http://localhost:5050/v1"
  microversion = "1.52"
  timeout      = 900
}

Resources

This provider currently implements a number of native Ironic resources, described below.

Nodes

A node describes a hardware resource. A limited subset of provision states are supported, you may specify manage = true or available = true. You may also instruct Ironic to inspect (inspect = true) or clean (clean = true) the node. To bring a node to the active state, i.e. deploy the node - use a deployment resource instead.

resource "ironic_node_v1" "openshift-master-0" {
  name = "openshift-master-0"

  inspect   = true # Perform inspection
  clean     = true # Clean the node
  available = true # Make the node 'available'

  ports = [
    {
      "address"     = "00:bb:4a:d0:5e:38"
      "pxe_enabled" = "true"
    },
  ]

  properties = {
    "local_gb" = "50"
    "cpu_arch" = "x86_64"
  }

  driver = "ipmi"
  driver_info = {
    "ipmi_port"      = "6230"
    "ipmi_username"  = "admin"
    "ipmi_password"  = "password"
    "ipmi_address"   = "192.168.111.1"
    "deploy_kernel"  = "http://172.22.0.1/images/ironic-python-agent.kernel"
    "deploy_ramdisk" = "http://172.22.0.1/images/ironic-python-agent.initramfs"
  }
}

Ports

Ports may be specified as part of the node resource, or as a separate ironic_port_v1 declaration.

resource "ironic_port_v1" "openshift-master-0-port-0" {
  node_uuid   = ironic_node_v1.openshift-master-0.id
  pxe_enabled = true
  address     = "00:bb:4a:d0:5e:38"
}

Allocation

The Allocation resource represents a request to find and allocate a Node for deployment. The microversion must be 1.52 or later.

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

  resource_class = "baremetal"

  candidate_nodes = [
    ironic_node_v1.openshift-master-0.id,
    ironic_node_v1.openshift-master-1.id,
    ironic_node_v1.openshift-master-2.id,
  ]

  traits = [
    "CUSTOM_FOO",
  ]
}

Deployment

A deployment will provision a baremetal node, using the information given in the resource. The count metaparameter can be used to deploy multiple nodes. Terraform will drive the Ironic state machine to bring the node to an active state. The separation of deployment from the baremetal node defintion allows a user to manage their hardware outside of the provider if desired. Destruction of a deployment brings the baremetal node back to the available state.

Users may specify a node_uuid directly, or make use of the allocation resource to dynamically pick a node.

resource "ironic_deployment" "masters" {
  count     = 3
  node_uuid = "${element(ironic_allocation_v1.openshift-master-allocation.*.node_uuid, count.index)}"

  instance_info = {
    image_source   = "http://172.22.0.1/images/redhat-coreos-maipo-latest.qcow2"
    image_checksum = "26c53f3beca4e0b02e09d335257826fd"
  }

  user_data    = var.user_data
  network_data = var.network_data
  metadata     = var.metadata
}

Data Sources

Introspection

When using Ironic inspector, you can use this data source to gather selected information such as network interface information, number of CPU's and architecture, and memory.

data "ironic_introspection" "openshift-master-0" {
  uuid = ironic_node_v1.openshift-master-0.id
}

Available data points are:

  • cpu_count
  • cpu_arch
  • memory_mb
  • interfaces, which include:
    • name
    • ip
    • mac

Development

Running acceptance tests locally

To run the acceptance tests locally, it's necessary to have a local instance of ironic and ironic-inspector running. A similar configuration to that used in CI can be achieved by running hack/local_ironic.sh

License

Apache 2.0, See LICENSE file

terraform-provider-ironic's People

Contributors

asalkeld avatar dhellmann avatar iurygregory avatar kirankt avatar lorbuschris avatar russellb avatar stbenjam avatar vrutkovs avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.