MAAS CLI-only machine creation

The whole point of MAAS configuration is to get machines deployed. If you read the previous post in this series, you know how to install MAAS and do basic configuration using only the MAAS Command-Line Interface (CLI). So far, so good, but now we need to enable networking and create some machines.

Enabling DHCP

The next step in any MAAS install is to get DHCP working on a MAAS VLAN. Usually, we choose the default, untagged VLAN. In the UI, that’s easy to find by inspection, but how do we find it using only the CLI? Well, we need to know two things besides the VLAN name (“untagged”): the the fabric ID and the primary rack controller name.

stormrider@wintermute:~$ maas admin subnet read 192.168.123.0/24 | grep fabric_id "fabric_id": 2,
stormrider@wintermute:~$ maas admin rack-controllers read | grep hostname | cut -d '"' -f 4 wintermute
stormrider@wintermute:~$ maas admin vlan update 2 untagged dhcp_on=True primary_rack=wintermute {"dhcp_on": ["dhcp can only be turned on when a dynamic IP range is defined."]}
stormrider@wintermute:~$ maas admin ipranges create type=dynamic start_ip=192.168.123.190 end_ip=192.168.123.253 Success.
Machine-readable output follows:
{ "subnet": { "name": "192.168.123.0/24", "description": "", "vlan": { "vid": 0, "mtu": 1500, "dhcp_on": false, "external_dhcp": null, "relay_vlan": null, "fabric": "fabric-2", "primary_rack": null, "name": "untagged", "id": 5003, "space": "undefined", "secondary_rack": null, "fabric_id": 2, "resource_uri": "/MAAS/api/2.0/vlans/5003/" }, "cidr": "192.168.123.0/24", "rdns_mode": 2, "gateway_ip": null, "dns_servers": [], "allow_dns": true, "allow_proxy": true, "active_discovery": false, "managed": true, "id": 4, "space": "undefined", "resource_uri": "/MAAS/api/2.0/subnets/4/" }, "type": "dynamic", "start_ip": "192.168.123.190", "end_ip": "192.168.123.253", "user": { "is_superuser": true, "username": "admin", "email": "admin@admin.com", "is_local": true, "resource_uri": "/MAAS/api/2.0/users/admin/" }, "comment": "", "id": 1, "resource_uri": "/MAAS/api/2.0/ipranges/1/"
}
stormrider@wintermute:~$ maas admin vlan update 2 untagged dhcp_on=True primary_rack=wintermute Success.
Machine-readable output follows:
{ "vid": 0, "mtu": 1500, "dhcp_on": true, "external_dhcp": null, "relay_vlan": null, "fabric": "fabric-2", "space": "undefined", "primary_rack": "8dwnne", "secondary_rack": null, "name": "untagged", "fabric_id": 2, "id": 5003, "resource_uri": "/MAAS/api/2.0/vlans/5003/"
}

Creating machines

In order to deploy machines, we’ll have to create some. It’s a relatively simple operation with the UI, but for this exercise, we’re only using the CLI. Since MAAS uses the “collections” idea, creating a machine is considered adding to the collection, so the object (“machines”) is plural, producing a command like this on our MAAS host, wintermute:

stormrider@wintermute:~$ maas admin machines create architecture=amd64 mac_addresses=52:54:00:15:36:f2 power_type=virsh power_parameters_power_id=f677a842-571c-4e65-adc9-11e2cf92d363 power_parameters_power_address=qemu+ssh://stormrider@192.168.123.1/system power_parameters_power_pass=xxxxxxxx Success.
Machine-readable output follows:
{ "storage": 0.0, "tag_names": [], "special_filesystems": [], "memory": 0, "boot_disk": null, "virtualblockdevice_set": [], "hardware_info": { "system_vendor": "Unknown", "system_product": "Unknown", "system_family": "Unknown", "system_version": "Unknown", "system_sku": "Unknown", "system_serial": "Unknown", "cpu_model": "Unknown", "mainboard_vendor": "Unknown", "mainboard_product": "Unknown", "mainboard_serial": "Unknown", "mainboard_version": "Unknown", "mainboard_firmware_vendor": "Unknown", "mainboard_firmware_date": "Unknown", "mainboard_firmware_version": "Unknown", "chassis_vendor": "Unknown", "chassis_type": "Unknown", "chassis_serial": "Unknown", "chassis_version": "Unknown" }, "address_ttl": null, "memory_test_status": -1, "other_test_status_name": "Unknown", "osystem": "", "status_message": "Commissioning", "netboot": true, "physicalblockdevice_set": [], "node_type": 0, "cpu_test_status": -1, "memory_test_status_name": "Unknown", "bcaches": [], "storage_test_status": 0, "system_id": "bhxws3", "status": 1, "commissioning_status": 0, "power_type": "virsh", "locked": false, "numanode_set": [ { "index": 0, "memory": 0, "cores": [] } ], "bios_boot_method": null, "fqdn": "ace-swan.maas", "node_type_name": "Machine", "hostname": "ace-swan", "volume_groups": [], "testing_status": 0, "network_test_status": -1, "other_test_status": -1, "interface_test_status": -1, "hwe_kernel": null, "blockdevice_set": [], "testing_status_name": "Pending", "power_state": "unknown", "min_hwe_kernel": "", "owner": "admin", "distro_series": "", "storage_test_status_name": "Pending", "cpu_speed": 0, "swap_size": null, "cpu_test_status_name": "Unknown", "hardware_uuid": null, "architecture": "amd64/generic", "pool": { "name": "default", "description": "Default pool", "id": 0, "resource_uri": "/MAAS/api/2.0/resourcepool/0/" }, "cache_sets": [], "pod": null, "iscsiblockdevice_set": [], "disable_ipv4": false, "status_action": "", "boot_interface": { "name": "eth0", "id": 10, "product": null, "system_id": "bhxws3", "effective_mtu": 1500, "children": [], "link_connected": true, "enabled": true, "interface_speed": 0, "numa_node": 0, "firmware_version": null, "parents": [], "discovered": null, "params": "", "links": [], "sriov_max_vf": 0, "tags": [], "type": "physical", "vlan": null, "vendor": null, "link_speed": 0, "mac_address": "52:54:00:15:36:f2", "resource_uri": "/MAAS/api/2.0/nodes/bhxws3/interfaces/10/" }, "cpu_count": 0, "domain": { "authoritative": true, "ttl": null, "resource_record_count": 0, "name": "maas", "is_default": true, "id": 0, "resource_uri": "/MAAS/api/2.0/domains/0/" }, "current_testing_result_id": 7, "default_gateways": { "ipv4": { "gateway_ip": null, "link_id": null }, "ipv6": { "gateway_ip": null, "link_id": null } }, "interface_set": [ { "name": "eth0", "id": 10, "product": null, "system_id": "bhxws3", "effective_mtu": 1500, "children": [], "link_connected": true, "enabled": true, "interface_speed": 0, "numa_node": 0, "firmware_version": null, "parents": [], "discovered": null, "params": "", "links": [], "sriov_max_vf": 0, "tags": [], "type": "physical", "vlan": null, "vendor": null, "link_speed": 0, "mac_address": "52:54:00:15:36:f2", "resource_uri": "/MAAS/api/2.0/nodes/bhxws3/interfaces/10/" } ], "status_name": "Commissioning", "commissioning_status_name": "Pending", "owner_data": {}, "ip_addresses": [], "raids": [], "network_test_status_name": "Unknown", "description": "", "current_commissioning_result_id": 6, "interface_test_status_name": "Unknown", "current_installation_result_id": null, "zone": { "name": "default", "description": "", "id": 1, "resource_uri": "/MAAS/api/2.0/zones/default/" }, "resource_uri": "/MAAS/api/2.0/machines/bhxws3/"
}

Commissioning by CLI

When commissioning finishes, we’ll have a machine in the “Ready” state. At that point, let’s take a minute to get familiar with the CLI commands to commission a machine. All that’s really needed is the system ID, which is the text between the last pair of slashes in the last JSON key, “resource_uri” above. Just for practice, though, let’s go ahead and retrieve the system ID using the CLI — which will be simple to recognize, since there’s only one machine right now:

stormrider@wintermute:~$ maas admin machines read | jq '.[] | .hostname, .system_id' "ace-swan" "bhxws3"
stormrider@wintermute:~$ maas admin machine commission bhxws3 Success.
Machine-readable output follows:
{ "storage_test_status_name": "Pending", "bcaches": [], "cpu_count": 1, "interface_set": [ { "params": "", "numa_node": 0, "tags": [], "id": 10, "mac_address": "52:54:00:15:36:f2", "vendor": "Red Hat, Inc.", "children": [], "effective_mtu": 1500, "discovered": [], "links": [], "link_speed": 0, "link_connected": true, "system_id": "bhxws3", "enabled": true, "interface_speed": 0, "firmware_version": null, "name": "ens3", "sriov_max_vf": 0, "product": null, "vlan": { "vid": 0, "mtu": 1500, "dhcp_on": true, "external_dhcp": null, "relay_vlan": null, "fabric": "fabric-2", "primary_rack": "8dwnne", "name": "untagged", "id": 5003, "space": "undefined", "secondary_rack": null, "fabric_id": 2, "resource_uri": "/MAAS/api/2.0/vlans/5003/" }, "parents": [], "type": "physical", "resource_uri": "/MAAS/api/2.0/nodes/bhxws3/interfaces/10/" } ], "network_test_status_name": "Unknown", "numanode_set": [ { "index": 0, "memory": 985, "cores": [ 0 ] } ], "locked": false, "hardware_uuid": "F677A842-571C-4E65-ADC9-11E2CF92D363", "default_gateways": { "ipv4": { "gateway_ip": null, "link_id": null }, "ipv6": { "gateway_ip": null, "link_id": null } }, "status_action": "", "status_message": "Commissioning", "cpu_test_status_name": "Unknown", "memory_test_status": -1, "virtualblockdevice_set": [], "pool": { "name": "default", "description": "Default pool", "id": 0, "resource_uri": "/MAAS/api/2.0/resourcepool/0/" }, "current_testing_result_id": 9, "current_installation_result_id": null, "netboot": true, "description": "", "special_filesystems": [], "testing_status": 0, "memory": 1024, "current_commissioning_result_id": 8, "storage": 5368.70912, "commissioning_status": 0, "cpu_test_status": -1, "tag_names": [ "virtual" ], "memory_test_status_name": "Unknown", "swap_size": null, "status_name": "Commissioning", "other_test_status": -1, "pod": null, "storage_test_status": 0, "blockdevice_set": [ { "id_path": "/dev/disk/by-id/ata-QEMU_HARDDISK_QM00001", "size": 5368709120, "block_size": 512, "tags": [ "ssd" ], "serial": "QM00001", "uuid": null, "numa_node": 0, "available_size": 5368709120, "id": 3, "partition_table_type": null, "model": "QEMU HARDDISK", "path": "/dev/disk/by-dname/sda", "storage_pool": null, "used_for": "Unused", "filesystem": null, "system_id": "bhxws3", "used_size": 0, "partitions": [], "name": "sda", "type": "physical", "resource_uri": "/MAAS/api/2.0/nodes/bhxws3/blockdevices/3/" } ], "other_test_status_name": "Unknown", "distro_series": "", "testing_status_name": "Pending", "ip_addresses": [], "address_ttl": null, "system_id": "bhxws3", "physicalblockdevice_set": [ { "firmware_version": "2.5+", "serial": "QM00001", "uuid": null, "numa_node": 0, "available_size": 5368709120, "size": 5368709120, "tags": [ "ssd" ], "id": 3, "partition_table_type": null, "id_path": "/dev/disk/by-id/ata-QEMU_HARDDISK_QM00001", "model": "QEMU HARDDISK", "path": "/dev/disk/by-dname/sda", "storage_pool": null, "used_for": "Unused", "filesystem": null, "system_id": "bhxws3", "used_size": 0, "partitions": [], "name": "sda", "block_size": 512, "type": "physical", "resource_uri": "/MAAS/api/2.0/nodes/bhxws3/blockdevices/3/" } ], "fqdn": "ace-swan.maas", "osystem": "", "domain": { "authoritative": true, "ttl": null, "resource_record_count": 0, "name": "maas", "id": 0, "is_default": true, "resource_uri": "/MAAS/api/2.0/domains/0/" }, "boot_interface": { "params": "", "numa_node": 0, "tags": [], "id": 10, "mac_address": "52:54:00:15:36:f2", "vendor": "Red Hat, Inc.", "children": [], "effective_mtu": 1500, "discovered": [], "links": [], "link_speed": 0, "link_connected": true, "system_id": "bhxws3", "enabled": true, "interface_speed": 0, "firmware_version": null, "name": "ens3", "sriov_max_vf": 0, "product": null, "vlan": { "vid": 0, "mtu": 1500, "dhcp_on": true, "external_dhcp": null, "relay_vlan": null, "fabric": "fabric-2", "primary_rack": "8dwnne", "name": "untagged", "id": 5003, "space": "undefined", "secondary_rack": null, "fabric_id": 2, "resource_uri": "/MAAS/api/2.0/vlans/5003/" }, "parents": [], "type": "physical", "resource_uri": "/MAAS/api/2.0/nodes/bhxws3/interfaces/10/" }, "hostname": "ace-swan", "network_test_status": -1, "min_hwe_kernel": "", "power_state": "off", "interface_test_status_name": "Unknown", "owner_data": {}, "volume_groups": [], "power_type": "virsh", "node_type": 0, "owner": "admin", "cache_sets": [], "architecture": "amd64/generic", "hwe_kernel": null, "zone": { "name": "default", "description": "", "id": 1, "resource_uri": "/MAAS/api/2.0/zones/default/" }, "disable_ipv4": false, "boot_disk": { "firmware_version": "2.5+", "serial": "QM00001", "uuid": null, "numa_node": 0, "available_size": 5368709120, "size": 5368709120, "tags": [ "ssd" ], "id": 3, "partition_table_type": null, "id_path": "/dev/disk/by-id/ata-QEMU_HARDDISK_QM00001", "model": "QEMU HARDDISK", "path": "/dev/disk/by-dname/sda", "storage_pool": null, "used_for": "Unused", "filesystem": null, "system_id": "bhxws3", "used_size": 0, "partitions": [], "name": "sda", "block_size": 512, "type": "physical", "resource_uri": "/MAAS/api/2.0/nodes/bhxws3/blockdevices/3/" }, "status": 1, "iscsiblockdevice_set": [], "raids": [], "node_type_name": "Machine", "hardware_info": { "system_vendor": "QEMU", "system_product": "Standard PC (i440FX + PIIX, 1996)", "system_family": "Unknown", "system_version": "pc-i440fx-focal", "system_sku": "Unknown", "system_serial": "Unknown", "cpu_model": "Intel Core Processor (Skylake, IBRS)", "mainboard_vendor": "Unknown", "mainboard_product": "Unknown", "mainboard_serial": "Unknown", "mainboard_version": "Unknown", "mainboard_firmware_vendor": "SeaBIOS", "mainboard_firmware_date": "04/01/2014", "mainboard_firmware_version": "1.13.0-1ubuntu1", "chassis_vendor": "QEMU", "chassis_type": "Other", "chassis_serial": "Unknown", "chassis_version": "pc-i440fx-focal" }, "commissioning_status_name": "Pending", "bios_boot_method": "pxe", "interface_test_status": -1, "cpu_speed": 0, "resource_uri": "/MAAS/api/2.0/machines/bhxws3/"
}