Hello,
I’m trying to create a infra to run k8s cluster on top of my metal.
The hardware is virtualized/hosted on vSphare. The OS has been provisioned to the ubuntu VM/hosts using Maas ( GUI )
What I want to do is to have the Maschines in terraform to be able to provision rke2 cluster nodes using Rancher. Rancher is able to interact with Terraform but I’m not sure how the resources should be defined in Terraform ( provider ) to be visible as a resources in the code for futhure to be able to manage the infra by Terraform provsioned by MAAS.
As I have machine:
maas admin machines read hostname=worker3
Success.
Machine-readable output follows:
[
{
"blockdevice_set": [
{
"firmware_version": "2.0",
"partitions": [
{
"uuid": "7f057f3f-eb00-42d7-959a-5ba3798bcf97",
"size": 214739976192,
"bootable": false,
"tags": [],
"id": 2,
"used_for": "ext4 formatted filesystem mounted at /",
"type": "partition",
"device_id": 3,
"path": "/dev/disk/by-dname/sda-part2",
"system_id": "ny7qpr",
"filesystem": {
"fstype": "ext4",
"label": "root",
"uuid": "bb51fe18-4092-4600-a4a6-3c09bcec1236",
"mount_point": "/",
"mount_options": null
},
"resource_uri": "/MAAS/api/2.0/nodes/ny7qpr/blockdevices/3/partition/2"
}
],
"type": "physical",
"model": "Virtual disk",
"id": 3,
"id_path": "/dev/sda",
"used_for": "GPT partitioned with 1 partition",
"tags": [
"ssd"
],
"filesystem": null,
"storage_pool": null,
"available_size": 0,
"path": "/dev/disk/by-dname/sda",
"uuid": null,
"serial": "",
"partition_table_type": "GPT",
"size": 214748364800,
"used_size": 214746267648,
"block_size": 512,
"numa_node": 0,
"system_id": "ny7qpr",
"name": "sda",
"resource_uri": "/MAAS/api/2.0/nodes/ny7qpr/blockdevices/3/"
}
],
"cpu_test_status": -1,
"other_test_status_name": "Unknown",
"boot_disk": {
"firmware_version": "2.0",
"partitions": [
{
"uuid": "7f057f3f-eb00-42d7-959a-5ba3798bcf97",
"size": 214739976192,
"bootable": false,
"tags": [],
"id": 2,
"used_for": "ext4 formatted filesystem mounted at /",
"type": "partition",
"device_id": 3,
"path": "/dev/disk/by-dname/sda-part2",
"system_id": "ny7qpr",
"filesystem": {
"fstype": "ext4",
"label": "root",
"uuid": "bb51fe18-4092-4600-a4a6-3c09bcec1236",
"mount_point": "/",
"mount_options": null
},
"resource_uri": "/MAAS/api/2.0/nodes/ny7qpr/blockdevices/3/partition/2"
}
],
"type": "physical",
"model": "Virtual disk",
"id": 3,
"id_path": "/dev/sda",
"used_for": "GPT partitioned with 1 partition",
"tags": [
"ssd"
],
"filesystem": null,
"storage_pool": null,
"available_size": 0,
"path": "/dev/disk/by-dname/sda",
"uuid": null,
"serial": "",
"partition_table_type": "GPT",
"size": 214748364800,
"used_size": 214746267648,
"block_size": 512,
"numa_node": 0,
"system_id": "ny7qpr",
"name": "sda",
"resource_uri": "/MAAS/api/2.0/nodes/ny7qpr/blockdevices/3/"
},
"bios_boot_method": "pxe",
"status": 6,
"zone": {
"name": "default",
"description": "",
"id": 1,
"resource_uri": "/MAAS/api/2.0/zones/default/"
},
"memory_test_status_name": "Unknown",
"storage_test_status": -1,
"netboot": false,
"min_hwe_kernel": "hwe-20.04",
"owner_data": {},
"domain": {
"authoritative": true,
"ttl": null,
"is_default": true,
"id": 0,
"resource_record_count": 1,
"name": "maas",
"resource_uri": "/MAAS/api/2.0/domains/0/"
},
"current_commissioning_result_id": 28,
"hostname": "worker3",
"commissioning_status": 2,
"ephemeral_deploy": false,
"default_gateways": {
"ipv4": {
"gateway_ip": "10.100.131.1",
"link_id": null
},
"ipv6": {
"gateway_ip": null,
"link_id": null
}
},
"memory": 16384,
"power_state": "unknown",
"network_test_status": -1,
"node_type_name": "Machine",
"storage_test_status_name": "Unknown",
"next_sync": null,
"power_type": "manual",
"interface_test_status_name": "Unknown",
"interface_set": [
{
"product": null,
"type": "physical",
"firmware_version": null,
"interface_speed": 0,
"id": 15,
"params": {},
"link_connected": false,
"tags": [],
"vlan": {
"vid": 0,
"mtu": 1500,
"dhcp_on": true,
"external_dhcp": null,
"relay_vlan": null,
"fabric_id": 0,
"id": 1,
"secondary_rack": null,
"space": "undefined",
"fabric": "fabric-0",
"name": "untagged",
"primary_rack": "gppxcx",
"resource_uri": "/MAAS/api/2.0/vlans/1/"
},
"links": [
{
"id": 23,
"mode": "static",
"ip_address": "10.100.131.15",
"subnet": {
"name": "oc-test",
"description": "",
"vlan": {
"vid": 0,
"mtu": 1500,
"dhcp_on": true,
"external_dhcp": null,
"relay_vlan": null,
"fabric_id": 0,
"id": 1,
"secondary_rack": null,
"space": "undefined",
"fabric": "fabric-0",
"name": "untagged",
"primary_rack": "gppxcx",
"resource_uri": "/MAAS/api/2.0/vlans/1/"
},
"cidr": "10.100.131.0/24",
"rdns_mode": 2,
"gateway_ip": "10.100.131.1",
"dns_servers": [],
"allow_dns": true,
"allow_proxy": true,
"active_discovery": true,
"managed": true,
"disabled_boot_architectures": [],
"id": 1,
"space": "undefined",
"resource_uri": "/MAAS/api/2.0/subnets/1/"
}
}
],
"enabled": true,
"link_speed": 0,
"vendor": null,
"mac_address": "00:50:56:a5:0f:62",
"children": [],
"parents": [],
"numa_node": 0,
"effective_mtu": 1500,
"discovered": null,
"system_id": "ny7qpr",
"sriov_max_vf": 0,
"name": "eth0",
"resource_uri": "/MAAS/api/2.0/nodes/ny7qpr/interfaces/15/"
}
],
"description": "",
"boot_interface": {
"product": null,
"type": "physical",
"firmware_version": null,
"interface_speed": 0,
"id": 15,
"params": {},
"link_connected": false,
"tags": [],
"vlan": {
"vid": 0,
"mtu": 1500,
"dhcp_on": true,
"external_dhcp": null,
"relay_vlan": null,
"fabric_id": 0,
"id": 1,
"secondary_rack": null,
"space": "undefined",
"fabric": "fabric-0",
"name": "untagged",
"primary_rack": "gppxcx",
"resource_uri": "/MAAS/api/2.0/vlans/1/"
},
"links": [
{
"id": 23,
"mode": "static",
"ip_address": "10.100.131.15",
"subnet": {
"name": "oc-test",
"description": "",
"vlan": {
"vid": 0,
"mtu": 1500,
"dhcp_on": true,
"external_dhcp": null,
"relay_vlan": null,
"fabric_id": 0,
"id": 1,
"secondary_rack": null,
"space": "undefined",
"fabric": "fabric-0",
"name": "untagged",
"primary_rack": "gppxcx",
"resource_uri": "/MAAS/api/2.0/vlans/1/"
},
"cidr": "10.100.131.0/24",
"rdns_mode": 2,
"gateway_ip": "10.100.131.1",
"dns_servers": [],
"allow_dns": true,
"allow_proxy": true,
"active_discovery": true,
"managed": true,
"disabled_boot_architectures": [],
"id": 1,
"space": "undefined",
"resource_uri": "/MAAS/api/2.0/subnets/1/"
}
}
],
"enabled": true,
"link_speed": 0,
"vendor": null,
"mac_address": "00:50:56:a5:0f:62",
"children": [],
"parents": [],
"numa_node": 0,
"effective_mtu": 1500,
"discovered": null,
"system_id": "ny7qpr",
"sriov_max_vf": 0,
"name": "eth0",
"resource_uri": "/MAAS/api/2.0/nodes/ny7qpr/interfaces/15/"
},
"parent": null,
"cpu_test_status_name": "Unknown",
"commissioning_status_name": "Passed",
"hardware_uuid": "82142542-5453-c2e8-df3a-0db0715380d1",
"numanode_set": [
{
"index": 0,
"memory": 16384,
"cores": [
0,
1,
2,
3
],
"hugepages_set": []
}
],
"node_type": 0,
"testing_status_name": "Unknown",
"raids": [],
"locked": false,
"virtualmachine_id": null,
"hwe_kernel": "hwe-20.04",
"address_ttl": null,
"virtualblockdevice_set": [],
"bcaches": [],
"status_name": "Deployed",
"current_testing_result_id": 27,
"last_sync": null,
"physicalblockdevice_set": [
{
"firmware_version": "2.0",
"partitions": [
{
"uuid": "7f057f3f-eb00-42d7-959a-5ba3798bcf97",
"size": 214739976192,
"bootable": false,
"tags": [],
"id": 2,
"used_for": "ext4 formatted filesystem mounted at /",
"type": "partition",
"device_id": 3,
"path": "/dev/disk/by-dname/sda-part2",
"system_id": "ny7qpr",
"filesystem": {
"fstype": "ext4",
"label": "root",
"uuid": "bb51fe18-4092-4600-a4a6-3c09bcec1236",
"mount_point": "/",
"mount_options": null
},
"resource_uri": "/MAAS/api/2.0/nodes/ny7qpr/blockdevices/3/partition/2"
}
],
"type": "physical",
"model": "Virtual disk",
"id": 3,
"id_path": "/dev/sda",
"used_for": "GPT partitioned with 1 partition",
"tags": [
"ssd"
],
"filesystem": null,
"storage_pool": null,
"available_size": 0,
"path": "/dev/disk/by-dname/sda",
"uuid": null,
"serial": "",
"partition_table_type": "GPT",
"size": 214748364800,
"used_size": 214746267648,
"block_size": 512,
"numa_node": 0,
"system_id": "ny7qpr",
"name": "sda",
"resource_uri": "/MAAS/api/2.0/nodes/ny7qpr/blockdevices/3/"
}
],
"cache_sets": [],
"storage": 214748.3648,
"cpu_count": 4,
"workload_annotations": {},
"tag_names": [
"virtual"
],
"architecture": "amd64/generic",
"status_message": "Deployed",
"interface_test_status": -1,
"current_installation_result_id": 35,
"osystem": "ubuntu",
"owner": "maasadmin",
"ip_addresses": [
"10.100.131.15"
],
"disable_ipv4": false,
"fqdn": "worker3.maas",
"pool": {
"name": "default",
"description": "Default pool",
"id": 0,
"resource_uri": "/MAAS/api/2.0/resourcepool/0/"
},
"other_test_status": -1,
"memory_test_status": -1,
"network_test_status_name": "Unknown",
"swap_size": null,
"pod": null,
"status_action": "",
"distro_series": "focal",
"error_description": "",
"cpu_speed": 2400,
"testing_status": -1,
"hardware_info": {
"system_vendor": "VMware, Inc.",
"system_product": "VMware Virtual Platform",
"system_family": "Unknown",
"system_version": "Unknown",
"system_sku": "Unknown",
"system_serial": "VMware-42 25 14 82 53 54 e8 c2-df 3a 0d b0 71 53 80 d1",
"cpu_model": "Intel(R) Xeon(R) Platinum 8260 CPU",
"mainboard_vendor": "Intel Corporation",
"mainboard_product": "440BX Desktop Reference Platform",
"mainboard_serial": "Unknown",
"mainboard_version": "Unknown",
"mainboard_firmware_vendor": "Phoenix Technologies LTD",
"mainboard_firmware_date": "11/12/2020",
"mainboard_firmware_version": "6.00",
"chassis_vendor": "No Enclosure",
"chassis_type": "Other",
"chassis_serial": "Unknown",
"chassis_version": "N/A"
},
"sync_interval": null,
"special_filesystems": [],
"system_id": "ny7qpr",
"enable_hw_sync": false,
"volume_groups": [],
"resource_uri": "/MAAS/api/2.0/machines/ny7qpr/"
}
]
What is the proper definition for the resource ?
terraform {
required_providers {
maas = {
source = “maas/maas”
version = “~>1.0”
# source = “registry.terraform.io/ionutbalutoiu/maas”
}
}
}
provider “maas” {
api_version = “2.0”
api_url= “http//10.10.10.10:5240/MAAS”
api_key= “myapikey”
}
resource “maas_instance” “worker3” {
}
As I understand the Terraform take any VM from Maas which is siutable for some parameter like min_cpu=value etc. ?
Can I take a VM as a resource using name=value ? like mac_address": “00:50:56:a5:0f:62”
The reference documentation of terraform and maas don’t seems to be clear for me. Any guidelines will be appriciate !
Cheers