maas_machine.machine1: Creating…
╷
│ Error: invalid character ‘<’ looking for beginning of value
│
│ with maas_machine.machine1,
│ on mass_deploy_machine.tf line 22, in resource “maas_machine” “machine1”:
│ 22: resource “maas_machine” “machine1” {
│
Can you please provide resource definition for the machine that you are trying to deploy?
Which version of terraform provider are you using?
terraform {
required_providers {
maas = {
source = “maas/maas”
version = “1.2.0”
}
}
}
provider “maas” {
api_version = “~>1.2.0”
api_key = “”
api_url = “[http://192.168.97.72:5240/MAAS”]
#skip_tls = true
}
resource “maas_machine” “example_machine” {
hostname = “maas-machine” # Replace with desired hostname
domain = “maas” # Replace with desired domain
pxe_mac_address = “00:50:56:b2:63:ae”
#tags = [“web-server”, “production”] # Replace or remove as needed
power_type = “manual”
architecture = “amd64” # Replace with desired architecture (e.g., amd64, arm64)
power_parameters = {
mac_address = “00:50:56:b2:63:ae” # Replace with MAC address of desired interface
subnet = “192.168.97.0/24” # Replace with desired subnet
ip_address = “192.168.97.75” # Replace with desired IP address
}
}
And the terraform version is
C:\Terraform\maas>terraform version
Terraform v1.3.7
on windows_amd64
- provider registry.terraform.io/maas/maas v1.2.0
please let me know if you need more details…
Thanks
Vinod
provider “maas” {
api_version = “1.2”
api_key = “vtYEMsDTcpERWPXUHL:aeYaWxJarP2zecJJBD:bbrN5VUdwyxAx4854UvsvsE5DXG6Kj7v”
#api_url = “http://192.168.97.72:5240/MAAS/api/2.0”
api_url = “http://192.168.97.72:5240/MAAS”
It seems that you are providing incorrect power_parameters
object.
-
power_parameters
(Map of String, Sensitive) A map with the parameters specific to thepower_type
. See Power types section for a list of the available power parameters for each power type.
You’ve specified power_type
as manual
and according to the doc it doesn’t have any parameters. Also I don’t see any power_type
that would accept mac_address
, subnet
and ip_address
as power_parameters
.
Not sure what you are trying to achieve with your tf, but maybe documentation will help?
Also do you really want this constraint api_version = “~>1.2.0”
to be like this? It seems that you have 2.0 (which is valid for your selector tho)
Thanks, let me go through documentation
I tried below code for creating my 1st mass instance using terraform -
terraform version -
Maas version -
Terraform v1.4.6
on windows_386
- provider registry.terraform.io/maas/maas v1.2.0
==========================
terraform {
required_providers {
maas = {
source = “maas/maas”
version = “1.2”
}
}
}
provider “maas” {
api_version = “1.2”
api_key = “vtYEMsDTcpERWPXUHL:aeYaWxJarP2zecJJBD:bbrN5VUdwyxAx4854UvsvsE5DXG6Kj7v”
api_url = “http://192.168.97.72:5240/MAAS/#/machines”
}
resource “maas_instance” “first_mass_instance” {
count = 1
allocate_params {
min_cpu_count = 1
min_memory = 2048
}
deploy_params {
distro_series = “focal”
}
}
Again facing same error while running terraform apply -
maas_instance.first_mass_instance[0]: Creating…
╷
│ Error: invalid character ‘<’ looking for beginning of value
│
│ with maas_instance.first_mass_instance[0],
│ on mass_instance.tf line 14, in resource “maas_instance” “first_mass_instance”:
│ 14: resource “maas_instance” “first_mass_instance” {
│
Please consider reading the documentation covering how to properly init the provider.
provider "maas" {
api_version = "2.0"
api_key = "<YOUR API KEY>"
api_url = "http://127.0.0.1:5240/MAAS"
}
In your example you have incorrect api_version
and api_url
.
Here is how you should use it for your case:
terraform {
required_providers {
maas = {
source = "maas/maas"
version = "1.2"
}
}
}
provider "maas" {
api_version = "2.0"
api_key = "vtYEMsDTcpERWPXUHL:aeYaWxJarP2zecJJBD:bbrN5VUdwyxAx4854UvsvsE5DXG6Kj7v"
api_url = "http://192.168.97.72:5240/MAAS"
}
resource "maas_instance" "first_mass_instance" {
count = 1
allocate_params {
min_cpu_count = 1
min_memory = 2048
}
deploy_params {
distro_series = "focal"
}
}
P.S. providing formatted config (terraform fmt) and using pre-formatted text block in Discourse text editor makes it much more readable for others.
Hi @troyanov
I have tried the same code to deploy the machine and I m facing the below issue
ubuntu@ubuntu:~/terraform$ terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
- create
Terraform will perform the following actions:
maas_instance.first_mass_instance[0] will be created
- resource “maas_instance” “first_mass_instance” {
-
cpu_count = (known after apply)
-
fqdn = (known after apply)
-
hostname = (known after apply)
-
id = (known after apply)
-
ip_addresses = (known after apply)
-
memory = (known after apply)
-
pool = (known after apply)
-
tags = (known after apply)
-
zone = (known after apply)
-
allocate_params {
- min_cpu_count = 1
- min_memory = 2048
- tags = []
}
-
deploy_params {
- distro_series = “focal”
}
}
- distro_series = “focal”
-
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only ‘yes’ will be accepted to approve.
Enter a value: yes
maas_instance.first_mass_instance[0]: Creating…
╷
│ Error: ServerError: 409 Conflict (No available machine matches constraints: [(‘cpu_count’, [‘1’]), (‘mem’, [‘2048’])] (resolved to “cpu_count=1.0 mem=2048.0”))
│
│ with maas_instance.first_mass_instance[0],
│ on main.tf line 16, in resource “maas_instance” “first_mass_instance”:
│ 16: resource “maas_instance” “first_mass_instance” {
Yes, I am also facing above error, even if I remove min_cpu_count, min_memory as it is optional, I am still getting Error: ServerError: 409 Conflict
@sudhirnigam @vinodsiraparapu the error you have is self explaining. You are requesting machine with certain parameters, but there are no machines that MAAS can provide for deployment.
- A maas_instance provides a resource to deploy and release machines already configured in MAAS, based on the specified parameters. If no parameters are given, a random machine will be allocated and deployed using the defaults.
Do you have required machines under MAAS?
Can you check if you can achieve desired result using MAAS CLI/UI?
Please follow the documentation that describes the process.
Can you provide output of maas $PROFILE machines read
?
Hi @troyanov
ubuntu@ubuntu:~/terraform$ maas $PROFILE machines read
usage: maas [-h] COMMAND …
optional arguments:
-h, --help show this help message and exit
drill down:
COMMAND
login Log in to a remote API, and remember its description and
credentials.
logout Log out of a remote API, purging any stored credentials.
list List remote APIs that have been logged-in to.
refresh Refresh the API descriptions of all profiles.
init Initialize controller.
config View or change controller configuration.
status Status of controller services.
migrate Perform migrations on connected database.
apikey Used to manage a user’s API keys. Shows existing keys unless
–generate or --delete is passed.
configauth Configure external authentication.
createadmin Create a MAAS administrator account.
changepassword
Change a MAAS user’s password.
argument COMMAND: invalid choice: ‘machines’ (choose from ‘login’, ‘logout’, ‘list’, ‘refresh’, ‘init’, ‘config’, ‘status’, ‘migrate’, ‘apikey’, ‘configauth’, ‘createadmin’, ‘changepassword’)
ubuntu@ubuntu:~/terraform$ echo $PROFILE
ubuntu@ubuntu:~/terraform$ maas $PROFILE
Error: no arguments given.
Run /snap/maas/8724/bin/maas --help for usage details.
What is $PROFILE value… please let us know.
Thanks
Vinod
Hi @troyanov,
Meanwhile we also tried to deploy machine from mass UI, but its failing, pls see attached screenshot.
It failed in “commissioning” state.
@vinodsiraparapu I do strongly recommend to go through documentation and to get familiar with maas
CLI usage.
$PROFILE
in my example was referring your profile name used during maas login
@sudhirnigam I would recommend you to check the errors that happened during commissioning and also check MAAS logs
Hi @troyanov
Thank you so much for your help.
As discussed, I am trying with MAAS cli and failed with commissioning and allocate … please find the logs and suggest to successfully deployed the machine on MAAS.
Please find the logs: I have observed the machine do not find any resources allocated like RAM, CPU.
ubuntu@ubuntu:~$ maas admin machine commission cqbp36
Success.
Machine-readable output follows:
{
“domain”: {
“authoritative”: true,
“ttl”: null,
“is_default”: true,
“resource_record_count”: 0,
“id”: 0,
“name”: “maas”,
“resource_uri”: “/MAAS/api/2.0/domains/0/”
},
“architecture”: “amd64/generic”,
“virtualblockdevice_set”: [],
“system_id”: “cqbp36”,
“fqdn”: “clean-hornet.maas”,
“raids”: [],
“tag_names”: [],
“status_message”: “Commissioning”,
“status_action”: “”,
“cpu_test_status_name”: “Unknown”,
“commissioning_status_name”: “Pending”,
“memory_test_status”: -1,
“bcaches”: [],
“netboot”: true,
“current_testing_result_id”: 76,
“storage_test_status_name”: “Pending”,
“boot_interface”: {
“system_id”: “cqbp36”,
“vendor”: null,
“links”: [],
“type”: “physical”,
“discovered”: null,
“id”: 23,
“firmware_version”: null,
“link_connected”: true,
“link_speed”: 0,
“params”: “”,
“product”: null,
“parents”: [],
“mac_address”: “52:54:00:18:36:f5”,
“sriov_max_vf”: 0,
“vlan”: null,
“tags”: [],
“interface_speed”: 0,
“numa_node”: 0,
“effective_mtu”: 1500,
“enabled”: true,
“children”: [],
“name”: “eth0”,
“resource_uri”: “/MAAS/api/2.0/nodes/cqbp36/interfaces/23/”
},
“ip_addresses”: [],
“hostname”: “clean-hornet”,
“testing_status_name”: “Pending”,
“interface_test_status”: -1,
“min_hwe_kernel”: “ga-18.04”,
“locked”: false,
“storage_test_status”: 0,
“testing_status”: 0,
“address_ttl”: null,
“interface_test_status_name”: “Unknown”,
“other_test_status_name”: “Unknown”,
“swap_size”: null,
“owner”: “admin”,
“node_type”: 0,
“node_type_name”: “Machine”,
“zone”: {
“name”: “default”,
“description”: “”,
“id”: 1,
“resource_uri”: “/MAAS/api/2.0/zones/default/”
},
“physicalblockdevice_set”: [],
“status”: 1,
“cpu_speed”: 0,
“current_commissioning_result_id”: 75,
“pod”: null,
“other_test_status”: -1,
“power_state”: “error”,
“memory”: 0,
“osystem”: “”,
“volume_groups”: [],
“distro_series”: “”,
“bios_boot_method”: null,
“special_filesystems”: [],
“hardware_info”: {
“system_vendor”: “Unknown”,
“system_product”: “Unknown”,
“system_version”: “Unknown”,
“system_serial”: “Unknown”,
“cpu_model”: “Unknown”,
“mainboard_vendor”: “Unknown”,
“mainboard_product”: “Unknown”,
“mainboard_firmware_version”: “Unknown”,
“mainboard_firmware_date”: “Unknown”
},
“hardware_uuid”: null,
“power_type”: “vmware”,
“blockdevice_set”: [],
“owner_data”: {},
“network_test_status_name”: “Unknown”,
“interface_set”: [
{
“system_id”: “cqbp36”,
“vendor”: null,
“links”: [],
“type”: “physical”,
“discovered”: null,
“id”: 23,
“firmware_version”: null,
“link_connected”: true,
“link_speed”: 0,
“params”: “”,
“product”: null,
“parents”: [],
“mac_address”: “52:54:00:18:36:f5”,
“sriov_max_vf”: 0,
“vlan”: null,
“tags”: [],
“interface_speed”: 0,
“numa_node”: 0,
“effective_mtu”: 1500,
“enabled”: true,
“children”: [],
“name”: “eth0”,
“resource_uri”: “/MAAS/api/2.0/nodes/cqbp36/interfaces/23/”
}
],
“status_name”: “Commissioning”,
“disable_ipv4”: false,
“description”: “”,
“network_test_status”: -1,
“boot_disk”: null,
“iscsiblockdevice_set”: [],
“commissioning_status”: 0,
“cpu_test_status”: -1,
“memory_test_status_name”: “Unknown”,
“cache_sets”: [],
“storage”: 0.0,
“numanode_set”: [
{
“index”: 0,
“memory”: 0,
“cores”: []
}
],
“default_gateways”: {
“ipv4”: {
“gateway_ip”: null,
“link_id”: null
},
“ipv6”: {
“gateway_ip”: null,
“link_id”: null
}
},
“pool”: {
“name”: “default”,
“description”: “Default pool”,
“id”: 0,
“resource_uri”: “/MAAS/api/2.0/resourcepool/0/”
},
“hwe_kernel”: null,
“current_installation_result_id”: null,
“cpu_count”: 0,
“resource_uri”: “/MAAS/api/2.0/machines/cqbp36/”
}
ubuntu@ubuntu:~$ maas admin machines allocate system_id=cqbp36
No available machine matches constraints: [(‘system_id’, [‘cqbp36’])] (resolved to “system_id=cqbp36”)
Based on the description you provided, it appears that you are trying to allocate machine that is not in the required state.
Some suggestions to troubleshoot the issue further:
Did you follow this How to allocate machines guide? It mentions that node should be in state Ready
before you can allocate it.
To allocate a node, it must have a status of ‘Ready’.
You have to wait for the Commission process to complete. If there are any errors, you can navigate to machine details and check the status of Commission steps and view logs to analyze failures (if there are any)
We also have a collection How to troubleshoot MAAS that might help you to identify your issue.
Hello @vinodsiraparapu @sudhirnigam
I am wondering if you were able to solve your Terraform issue? And maybe you can share back with the community how you solved it?