Terraform MAAS2.0.0 - Deploy enlisted machine

How can i get the ipmi power_parameters after a system has been enlisted? I need that to populate the Terraform “maas_machine” resource.

Hi mk4uhma,

What version of MAAS are you using?

You can directly get information using the MAAS API and CLI.

Could you check the following endpoints?
/MAAS/api/2.0/machines/op-power_parameters
/MAAS/api/2.0/devices/{system_id}/op-power_parameters

I’m using 3.2.9 right now.

let me check that endpoint. thanks!

I had to use machines but the endpoint is unknown.

Unknown API endpoint: /MAAS/api/2.0/machines/op-power_parameters.

my bare metal isn’t a Device so i couldn’t use the system_id from it.

this endpoint works

http://maas.gqma.net/MAAS/api/2.0/machines/ppnm7y/

Sorry, the correct endpoint actually is:

MAAS/api/2.0/machines/<system_id>/?op=power_parameters

that worked, thanks.

This document doesn’t reflect your update.

https://maas.io/docs/api

@mk4umha both /MAAS/api/2.0/machines/<system_id>/op-power_parameters (from the docs) and /MAAS/api/2.0/machines/<system_id>/?op=power_parameters work fine

I actually have one question on how to use Terraform MAAS provider to setup a “new” system.
MAAS discovered and setup a new system.

I already have TF resources networks, subnets defined.

For this particular server I also defined the phyisical interfaces and vlans, drives, etc.

I created Terraform for it but i’m getting.

Error: ServerError: 400 Bad Request ({"mac_addresses": ["MAC address xx:xx:xx:xx:xx already in use on up-locust."]})

It seems that the MAC address is already in use by some other node in the system.

Could you provide your terraform configuration?

resource "maas_machine" "dell_7920r1" {
  power_type = "ipmi"
  power_parameters = jsonencode({
    power_address = "192.168.142.31"
    power_user = "xxxx"
    power_pass = "xxxxxxxxxx"
  })
  pxe_mac_address = "xx:xx:xx:xx:xx"
}

If you want to setup a new system, I would suggest to first commissioning the machine using maas_machine as you did, and then create a new instance using maas_instance:

resource "maas_instance" "up-locust" {
  allocate_params {
    min_cpu_count = 1
    min_memory = 2048
  }
  deploy_params {
    distro_series = "jammy"
  }
}

It’s not commission via terraform because the address is already in use. So I’m not sure how to commission it.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.

Hi @mk4umha,

I think what you need is the implementation of this feature: https://github.com/maas/terraform-provider-maas/issues/151.

Your case is first list item inside the issue description. At the moment, the provider cannot support the use case of New machines. However, you can subscribe to the issue and get notified when it will be implemented. Thank you for raising it :slight_smile:

I think that what @javier-fs wanted to suggest, is to first commission it yourself outside terraform (https://maas.io/docs/try-out-the-maas-cli#manage-nodes-3 - Commission a node) and then use maas_instance resource to deploy it with Terraform.

1 Like