### Configure and Start Grafana Agent (Snap Installation) Source: https://github.com/canonical/maas/blob/master/docs/how-to-guides/monitor-maas.md Set up directories for agent data, copy the example configuration, and start the agent using systemd-run with appropriate environment variables. Adjust MAAS_LOGS to your snap installation path. ```bash mkdir -p /var/lib/grafana-agent/positions \ /var/lib/grafana-agent/wal cp /snap/maas/current/usr/share/maas/grafana_agent/agent.yaml.example /opt/agent/agent.yml systemd-run -u telemetry \ -E HOSTNAME="$(hostname)" \ -E AGENT_WAL_DIR="/var/lib/grafana-agent/wal" \ -E AGENT_POS_DIR="/var/lib/grafana-agent/positions" \ -E PROMETHEUS_REMOTE_WRITE_URL="http://${O11y_IP}:9090/api/v1/write" \ -E LOKI_API_URL="http://${O11y_IP}:3100/loki/api/v1/push" \ -E MAAS_LOGS="/var/snap/maas/common/log/" \ -E MAAS_IS_REGION="true" \ -E MAAS_IS_RACK="true" \ -E MAAS_AZ="default" \ /opt/agent/agent-linux-amd64 \ -config.expand-env \ -config.file=/opt/agent/agent.yml ``` -------------------------------- ### Database Server Setup Template with cloud-init Source: https://github.com/canonical/maas/blob/master/docs/reference/configuration-guides/cloud-init.md Installs MySQL server and client, then enables and starts the MySQL service. Use this template for quick database server setup. ```yaml #cloud-config packages: - mysql-server - mysql-client runcmd: - systemctl enable mysql - systemctl start mysql ``` -------------------------------- ### Configure Custom Bcache Setup Source: https://github.com/canonical/maas/blob/master/docs/reference/configuration-guides/storage.md Example of a custom bcache setup defining data partitions and their mounts. ```json { "layout": { "data1": { "type": "bcache", "cache-device": "sda", "backing-device": "sdb", "cache-mode": "writeback", "fs": "ext4" }, "data2": { "type": "bcache", "cache-device": "sda", "backing-device": "sdc", "fs": "btrfs" } }, "mounts": { "/data1": { "device": "data1" }, "/data2": { "device": "data2" } } } ``` -------------------------------- ### Example Cloud-Init Configuration for DOCA Source: https://github.com/canonical/maas/blob/master/docs/how-to-guides/deploy-dpus.md Example cloud-init configuration to install and enable DOCA runtime packages and Open vSwitch. This is used for post-deployment customization. ```yaml #cloud-config packages: - mlnx-ofed-kernel-modules - doca-runtime runcmd: - systemctl enable openvswitch-switch - systemctl start openvswitch-switch ``` -------------------------------- ### Install Node.js and Nginx with cloud-init Source: https://github.com/canonical/maas/blob/master/docs/reference/configuration-guides/cloud-init.md Installs Nginx, Node.js, and npm. Enables and starts the Nginx service. Use this to set up a server for web applications. ```yaml #cloud-config packages: - nginx - nodejs - npm runcmd: - systemctl enable nginx - systemctl start nginx ``` -------------------------------- ### Install Docker using Cloud-init Source: https://github.com/canonical/maas/blob/master/docs/reference/configuration-guides/cloud-init.md Automate the installation of Docker and ensure the service is enabled and started on boot. ```yaml #cloud-config packages: - docker.io runcmd: - systemctl enable docker - systemctl start docker ``` -------------------------------- ### Install and Configure ELK Stack with cloud-init Source: https://github.com/canonical/maas/blob/master/docs/reference/configuration-guides/cloud-init.md Installs Elasticsearch, Logstash, and Kibana, then enables and starts all services. Use this for centralized logging, storage, and visualization. ```yaml #cloud-config packages: - elasticsearch - logstash - kibana runcmd: - systemctl enable elasticsearch - systemctl start elasticsearch - systemctl enable logstash - systemctl start logstash - systemctl enable kibana - systemctl start kibana ``` -------------------------------- ### Web Server Deployment Template with cloud-init Source: https://github.com/canonical/maas/blob/master/docs/reference/configuration-guides/cloud-init.md Installs Apache2 and PHP, then enables and starts the Apache2 service. Use this template for quick web server deployment. ```yaml #cloud-config packages: - apache2 - php runcmd: - systemctl enable apache2 - systemctl start apache2 ``` -------------------------------- ### Pre-defined LVM Example Source: https://github.com/canonical/maas/blob/master/docs/reference/configuration-guides/storage.md Configures a Logical Volume Manager (LVM) setup with specified member disks and pre-defined volumes, each with a size and filesystem type. Mount points are then assigned. ```json { "layout": { "storage": { "type": "lvm", "members": [ "sda", "sdb", "sdc", "sdd" ], "volumes": [ { "name": "data1", "size": "1T", "fs": "ext4" }, { "name": "data2", "size": "2.5T", "fs": "btrfs" } ] } }, "mounts": { "/data1": { "device": "data1" }, "/data2": { "device": "data2" } } } ``` -------------------------------- ### Load Balancer Configuration with HAProxy using cloud-init Source: https://github.com/canonical/maas/blob/master/docs/reference/configuration-guides/cloud-init.md Installs HAProxy and configures its settings, then enables and starts the HAProxy service. Use this for load balancing. ```yaml #cloud-config packages: - haproxy write_files: - path: /etc/haproxy/haproxy.cfg content: | global log /dev/log local0 log /dev/log local1 notice chroot /var/lib/haproxy stats socket /run/haproxy/admin.sock mode 660 level admin stats timeout 30s user haproxy group haproxy daemon defaults log global mode http option httplog option dontlognull timeout connect 5000 timeout client 50000 timeout server 50000 runcmd: - systemctl enable haproxy - systemctl start haproxy ``` -------------------------------- ### Vendor-Specific Configuration Example (Bash) Source: https://github.com/canonical/maas/blob/master/docs/explanation/commissioning-scripts.md This Bash script demonstrates interacting with vendor-specific tools to configure hardware during commissioning. It uses 'hprest' to get embedded SATA information and saves the output to the MAAS result path. ```bash #!/bin/bash -ex # Metadata block here output=$(sudo hprest get EmbeddedSata --selector HpBios) echo "$output" > $RESULT_PATH ``` -------------------------------- ### Install MAAS 3.3 via Snap Source: https://github.com/canonical/maas/blob/master/docs/uncategorized/maas-3-3-release-notes.md Use this command for a fresh installation of MAAS 3.3. Ensure you have sudo privileges. ```none sudo snap install --channel=3.3 maas ``` -------------------------------- ### Enable and Start Grafana Server Source: https://github.com/canonical/maas/blob/master/docs/how-to-guides/monitor-maas.md Enable the Grafana server to start on boot and then start the service. Grafana is accessible via a web browser. ```text systemctl enable grafana-server systemctl start grafana-server ``` -------------------------------- ### Install Go for Temporal Development Source: https://github.com/canonical/maas/blob/master/HACKING.rst Installs the Go programming language, a prerequisite for Temporal development and using tools like tctl. ```bash sudo apt update sudo apt install golang-go ``` -------------------------------- ### Install MAAS 3.2 via Snap Source: https://github.com/canonical/maas/blob/master/docs/uncategorized/maas-3-2-release-notes.md Installs MAAS 3.2 fresh using the snap package manager. Recommended for new installations. ```text sudo snap install --channel=3.2 maas ``` -------------------------------- ### Install MAAS 2.7 cleanly Source: https://github.com/canonical/maas/blob/master/docs/uncategorized/maas-2-7-release-notes.md Install MAAS 2.7 as a clean installation, avoiding devmode. ```text snap install --channel=2.7 maas ``` -------------------------------- ### Install Git Source: https://github.com/canonical/maas/blob/master/HACKING.rst Install Git to manage MAAS source code. This is a prerequisite for cloning the repository. ```bash $ sudo apt install git ``` -------------------------------- ### Complete Storage Configuration Example Source: https://github.com/canonical/maas/blob/master/docs/uncategorized/create-custom-storage.md A complete example of the JSON structure for MAAS storage configuration, including layouts and mounts. ```json { "layouts": { "sda": { ... }, "raid0": { ... }, ... }, "mounts": { "/": { ... }, ... } } ``` -------------------------------- ### Install HAProxy Source: https://github.com/canonical/maas/blob/master/docs/how-to-guides/manage-high-availability.md Install HAProxy on your system using the package manager. ```shell sudo apt install haproxy ``` -------------------------------- ### Install MAAS 3.0 via Snap Source: https://github.com/canonical/maas/blob/master/docs/uncategorized/maas-3-0-release-notes.md Use this command to perform a fresh installation of MAAS 3.0 using snap. ```text sudo snap install --channel=3.0/stable maas ``` -------------------------------- ### Install and use maas-test-db for initialization Source: https://github.com/canonical/maas/blob/master/docs/reference/cli-reference/init.md When installing region or rack+region modes, MAAS requires a PostgreSQL database. Install the 'maas-test-db' snap for non-production deployments before running 'maas init'. ```bash sudo snap install maas-test-db ``` ```bash sudo maas init region+rack --database-uri maas-test-db:/// ``` -------------------------------- ### Install MAAS Snap using snap try Source: https://github.com/canonical/maas/blob/master/HACKING.rst Install the MAAS snap using 'snap try' for development purposes. This command is used instead of 'snap install' when working with an unpacked snap. ```bash $ sudo snap try dev-snap/tree ``` -------------------------------- ### Add MAAS 3.0 PPA and Install Source: https://github.com/canonical/maas/blob/master/docs/uncategorized/maas-3-0-release-notes.md Add the MAAS 3.0 PPA to your system and install MAAS using apt. ```text sudo add-apt-repository ppa:maas/3.0 sudo apt update sudo apt install maas ``` -------------------------------- ### Install Juju Source: https://github.com/canonical/maas/blob/master/docs/how-to-guides/monitor-maas.md Install the Juju client using snap. This is a prerequisite for deploying Prometheus and Grafana. ```bash sudo snap install --classic juju ``` -------------------------------- ### Install SimpleStreams Source: https://github.com/canonical/maas/blob/master/docs/how-to-guides/manage-images.md Installs the SimpleStreams package, which is required for setting up and managing local image mirrors. ```bash sudo apt install simplestreams ``` -------------------------------- ### Select boot sources for download Source: https://github.com/canonical/maas/blob/master/docs/how-to-guides/manage-images.md Selects specific OS, release, and architecture combinations to be downloaded. Use '*' for labels to select all available. ```bash maas $PROFILE boot-sources read # list boot sources maas $PROFILE boot-source-selections create $SOURCE_ID os="ubuntu" release="$SERIES" arches="$ARCH" subarches="$KERNEL" labels="*" # select boot sources ``` -------------------------------- ### Set up Grafana Server with cloud-init Source: https://github.com/canonical/maas/blob/master/docs/reference/configuration-guides/cloud-init.md Installs Grafana and enables/starts the Grafana server service. Use this to create visual dashboards for monitoring. ```yaml #cloud-config packages: - grafana runcmd: - systemctl enable grafana-server - systemctl start grafana-server ``` -------------------------------- ### Install LAMP Stack using Cloud-init Source: https://github.com/canonical/maas/blob/master/docs/reference/configuration-guides/cloud-init.md Set up a LAMP (Linux, Apache, MySQL, PHP) stack by installing necessary packages and enabling their services. ```yaml #cloud-config packages: - apache2 - mysql-server - php runcmd: - systemctl enable apache2 - systemctl start apache2 - systemctl enable mysql - systemctl start mysql ``` -------------------------------- ### Naming Conventions: Avoiding Redundant Prefixes Source: https://github.com/canonical/maas/blob/master/go-style-guide.md Avoid prefixes like 'Get' or 'get' for function and method names unless the concept inherently involves 'get' (e.g., HTTP GET). Prefer starting names with the noun directly for clarity. ```go widget.NewWidget widget.NewWidgetWithName db.LoadFromDatabase ``` ```go widget.New widget.NewWithName db.Load ``` -------------------------------- ### Install MAAS Rack Controller (Snap) Source: https://github.com/canonical/maas/blob/master/docs/how-to-guides/manage-high-availability.md Installs the MAAS snap and initializes a rack controller. Ensure the MAAS_URL and SECRET environment variables are set. ```shell sudo snap install maas sudo maas init rack --maas-url $MAAS_URL --secret $SECRET ``` -------------------------------- ### Set up LXD for VM Provisioning Source: https://github.com/canonical/maas/blob/master/docs/how-to-guides/manage-machines.md Prepare your system for provisioning LXD VMs by purging old versions, installing LXD, initializing it, and configuring network settings to disable DHCP and DNS. ```bash sudo apt-get purge -y *lxd* *lxc* sudo apt-get autoremove -y sudo snap install lxd sudo lxd init lxc network set lxdbr0 dns.mode=none lxc network set lxdbr0 ipv4.dhcp=false lxc network set lxdbr0 ipv6.dhcp=false ``` -------------------------------- ### GET /MAAS/api/2.0/devices/{system_id}/op-details Source: https://github.com/canonical/maas/blob/master/docs/reference/api-reference/api-v2-generated.md Returns system details - for example, LLDP and `lshw` XML dumps. ```APIDOC ## GET /MAAS/api/2.0/devices/{system_id}/op-details ### Description Returns system details - for example, LLDP and `lshw` XML dumps. Returns a `{detail_type: xml, .}` map, where `detail_type` is something like “lldp” or “lshw”. Note that this is returned as BSON and not JSON. This is for efficiency, but mainly because JSON can’t do binary content without applying additional encoding like base-64. The example output below is represented in ASCII using `bsondump example.bson` and is for demonstrative purposes. ### Method GET ### Endpoint /MAAS/api/2.0/devices/{system_id}/op-details ### Parameters #### Path Parameters - **{system_id}** (string) - Required - The node’s system_id. ### Responses #### Success Response (200) - A BSON object represented here in ASCII using `bsondump example.bson`. #### Error Response (403) - **FORBIDDEN**: The user does not have permission to see the node details. #### Error Response (404) - **NOT FOUND**: The requested node is not found. ``` -------------------------------- ### Ruby API Authentication Example Source: https://github.com/canonical/maas/blob/master/docs/reference/api-reference/api-login.md Shows how to perform an authenticated GET request to the MAAS API using Ruby with the `oauth` gem. ```APIDOC ## Ruby API Authentication ### Description This function `perform_API_request` sets up an OAuth consumer and access token to make authenticated requests to the MAAS API. ### Method GET ### Endpoint `/nodes/` ### Parameters #### Query Parameters - **op** (string) - Required - Specifies the operation, e.g., `list`. ### Request Example ```ruby require 'oauth' require 'oauth/signature/plaintext' def perform_API_request(site, uri, key, secret, consumer_key) consumer = OAuth::Consumer.new(consumer_key, "", { :site => site, :scheme => :header, :signature_method => "PLAINTEXT"}) access_token = OAuth::AccessToken.new(consumer, key, secret) return access_token.request(:get, uri) end response = perform_API_request("http://server:5240/MAAS/api/2.0", "/nodes/?op=list", "", "", "consumer_key") ``` ### Response #### Success Response (200) - **(Object)** - The response from the API request. ``` -------------------------------- ### Configure Network with Netplan Source: https://github.com/canonical/maas/blob/master/docs/reference/configuration-guides/troubleshooting.md This example shows a basic netplan configuration for enabling DHCP and specifying DNS servers. Apply changes using 'sudo netplan apply'. ```yaml network: version: 2 ethernets: enp1s0: dhcp4: true nameservers: addresses: - 8.8.8.8 - 8.8.4.4 ``` -------------------------------- ### Create User and Install Packages with Cloud-init Source: https://github.com/canonical/maas/blob/master/docs/reference/configuration-guides/cloud-init.md Use this script to create a new user, add an SSH key for access, and install basic packages like git and htop. ```yaml #cloud-config users: - name: maas_user ssh_authorized_keys: - ssh-rsa AAAAB3Nz... user@domain sudo: "ALL=(ALL) NOPASSWD:ALL" groups: sudo shell: /bin/bash packages: - git - htop ``` -------------------------------- ### Python API Authentication Example Source: https://github.com/canonical/maas/blob/master/docs/reference/api-reference/api-login.md Demonstrates how to make an authenticated GET request to the MAAS API using Python with the `requests_oauthlib` library. ```APIDOC ## Python API Authentication ### Description This example uses the `fades` library, but you can also use `requests_oauthlib` and `oauthlib`. Replace `` and `` with your own values. ### Method GET ### Endpoint `/api/2.0/machines/` ### Parameters #### Query Parameters - **op** (string) - Required - Specifies the operation, e.g., `list_allocated`. ### Request Example ```python from oauthlib.oauth1 import SIGNATURE_PLAINTEXT from requests_oauthlib import OAuth1Session MAAS_HOST = "http://:5240/MAAS" CONSUMER_KEY, CONSUMER_TOKEN, SECRET = "".split(":") maas = OAuth1Session(CONSUMER_KEY, resource_owner_key=CONSUMER_TOKEN, resource_owner_secret=SECRET, signature_method=SIGNATURE_PLAINTEXT) nodes = maas.get(f"{MAAS_HOST}/api/2.0/machines/", params={"op": "list_allocated"}) nodes.raise_for_status() print(nodes.json()) ``` ### Response #### Success Response (200) - **(JSON object)** - A JSON object containing information about the machines. ``` -------------------------------- ### Set up Firewall with UFW using cloud-init Source: https://github.com/canonical/maas/blob/master/docs/reference/configuration-guides/cloud-init.md Installs UFW, allows SSH connections, and enables the firewall. Use this to secure your server immediately after deployment. ```yaml #cloud-config package_update: true packages: - ufw runcmd: - ufw allow ssh - ufw enable ``` -------------------------------- ### POST /MAAS/api/2.0/boot-sources/ Source: https://github.com/canonical/maas/blob/master/docs/reference/api-reference/api-v2-generated.md Creates a new boot source in the MAAS system. Requires a URL and either keyring data or a keyring filename. ```APIDOC ## POST /MAAS/api/2.0/boot-sources/ ### Description Create a new boot source. ### Method POST ### Endpoint /MAAS/api/2.0/boot-sources/ ### Request Body - **`url`** (string) - Required - The URL of the BootSource. - **`name`** (string) - Optional - The name of the BootSource. - **`keyring_filename`** (string) - Optional - The path to the keyring file for this BootSource. - **`keyring_data`** (string) - Optional - The GPG keyring for this BootSource, base64-encoded. - **`priority`** (integer) - Optional - The priority for this BootSource. - **`enabled`** (boolean) - Optional - Whether this BootSource is enabled or not. - **`skip_keyring_verification`** (boolean) - Optional - If true, keyring signature verification will be skipped. ### Response #### Success Response (200) A JSON object containing the new boot source. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Sequence Diagram in MyST Markdown Source: https://github.com/canonical/maas/blob/master/docs/reuse/mermaid.txt Embed a sequence diagram using the Mermaid directive in MyST Markdown. This example shows a typical snap installation process. ```markdown ```{mermaid} sequenceDiagram participant User participant Snap as snapd (Client) participant Store as Snap Store participant System User->>Snap: snap install hello Snap->>Store: Request snap info and download Store-->>Snap: Return snap package Snap->>System: Install and mount snap System-->>Snap: Installation result Snap-->>User: Confirm snap is installed ``` ``` -------------------------------- ### Install MAAS 3.1 using snap Source: https://github.com/canonical/maas/blob/master/docs/uncategorized/maas-3-1-release-notes.md Recommended method for a fresh installation of MAAS 3.1. Ensure you are using the correct channel for the desired version. ```text sudo snap install --channel=3.1 maas ``` -------------------------------- ### Example of a Legitimate MAAS Regiond Login Source: https://github.com/canonical/maas/blob/master/docs/reference/configuration-guides/logging.md This log entry shows a successful GET request to the MAAS login endpoint, indicating a normal user login. ```text 2020-03-31 21:17:56 regiond: [info] 10.132.172.1 GET /MAAS/accounts/login/ HTTP/1.1 --> 200 OK ``` -------------------------------- ### HTTPie + fish shell MAAS API Authentication Source: https://github.com/canonical/maas/blob/master/docs/reference/api-reference/api-login.md Authenticate and make a GET request to the MAAS API using HTTPie and the fish shell. This example splits the API key into components and constructs the Authorization header similarly to the cURL example. Ensure the MAAS_URL and API_KEY variables are set. ```text set API_KEY (string split : $API_KEY) http $MAAS_URL/api/2.0/users/ Authorization:"OAuth oauth_version=1.0, oauth_signature_method=PLAINTEXT, oauth_consumer_key=$API_KEY[1], oauth_token=$API_KEY[2], oauth_signature=&$API_KEY[3], oauth_nonce=$(uuidgen), oauth_timestamp=$(date +%s)" ``` -------------------------------- ### Install MAAS CLI and Log In Source: https://github.com/canonical/maas/blob/master/docs/how-to-guides/deploy-dpus-without-bmc.md Installs the MAAS CLI and logs into a MAAS instance using an admin profile. Ensure you have your MAAS URL and API token. ```shell sudo snap install maas maas login admin $maas_url $api_token ``` -------------------------------- ### Disk Configuration Example Source: https://github.com/canonical/maas/blob/master/docs/uncategorized/create-custom-storage.md Defines a physical disk with a partition table, boot flag, and partitions. ```json "sda": { "type": "disk", "ptable": "gpt", "boot": true, "partitions": [ { "name": "sda1", "fs": "vfat", "size": "100M" "bootable": true, } ] } ``` -------------------------------- ### Export Telemetry Data with Grafana Agent Source: https://github.com/canonical/maas/blob/master/docs/how-to-guides/monitor-maas.md Install the Grafana Agent by downloading, unzipping, and making it executable. Set environment variables for IP addresses and paths before starting the agent. ```text export O11y_IP= export GRAFANA_AGENT_PKG=https://github.com/grafana/agent/releases/download/v0.44.2/grafana-agent-linux-amd64.zip wget -q "${GRAFANA_AGENT_PKG}" -O /tmp/agent.zip unzip /tmp/agent.zip -d /opt/agent chmod a+x /opt/agent/grafana-agent-linux-amd64 ``` ```text mkdir -p /var/lib/grafana-agent/positions \ /var/lib/grafana-agent/wal # for snap cp /snap/maas/current/usr/share/maas/grafana_agent/agent-example-snap.yaml /opt/agent/agent.yaml # for deb cp /usr/share/maas/grafana_agent/agent-example-deb.yaml /opt/agent/agent.yaml systemd-run -u telemetry \ -E HOSTNAME="$(hostname)" \ -E AGENT_WAL_DIR="/var/lib/grafana-agent/wal" \ -E AGENT_POS_DIR="/var/lib/grafana-agent/positions" \ -E PROMETHEUS_REMOTE_WRITE_URL="http://${O11y_IP}:9090/api/v1/write" \ -E LOKI_API_URL="http://${O11y_IP}:3100/loki/api/v1/push" \ -E MAAS_IS_REGION="true" \ -E MAAS_IS_RACK="true" \ -E MAAS_AZ="default" \ /opt/agent/grafana-agent-linux-amd64 \ -config.expand-env \ -config.file=/opt/agent/agent.yaml ``` -------------------------------- ### Packer Command Not Found Error Source: https://github.com/canonical/maas/blob/master/docs/reference/configuration-guides/troubleshooting.md This error message indicates that the 'packer' command is not installed or not found in the system's PATH. Refer to the custom image building guide for resolution. ```text stormrider@neuromancer:~$ packer Command 'packer' not found... ``` -------------------------------- ### Setup MAAS Project Dependencies Source: https://github.com/canonical/maas/blob/master/HACKING.rst Fetch all required dependencies and set up useful commands in the bin/ directory for MAAS development. ```bash $ make ``` -------------------------------- ### Verify uploaded NOS images Source: https://github.com/canonical/maas/blob/master/docs/how-to-guides/manage-switches.md List all custom images uploaded to MAAS that start with the 'onie/' prefix. This is useful for confirming that your NOS installer images have been successfully uploaded and are available for use. ```bash curl -X GET "http://:5248/MAAS/a/v3/custom_images" \ -H "Authorization: Bearer " | jq '.items[] | select(.name | startswith("onie/"))' ``` -------------------------------- ### Write Custom Logs with Cloud-init Source: https://github.com/canonical/maas/blob/master/docs/reference/configuration-guides/cloud-init.md Use the `runcmd` directive in cloud-init to create custom log files for debugging purposes. This example logs the start of a custom log and the output of a command. ```yaml #cloud-config runcmd: - echo "Starting custom log" >> /var/log/custom-init.log - some-command >> /var/log/custom-init.log 2>&1 ``` -------------------------------- ### POST /MAAS/api/2.0/boot-resources/ Source: https://github.com/canonical/maas/blob/master/docs/reference/api-reference/api-v2-generated.md Creates a new boot resource. File uploads for this resource should be done in chunks. ```APIDOC ## POST /MAAS/api/2.0/boot-resources/ ### Description Creates a new boot resource. The file upload must be done in chunk, see Boot resource file upload. ### Method POST ### Endpoint /MAAS/api/2.0/boot-resources/ ### Parameters #### Request Body - **`name`** (string) - Required - Name of the boot resource. - **`architecture`** (string) - Required - Architecture the boot resource supports. - **`sha256`** (string) - Required - The `sha256` hash of the resource. - **`size`** (string) - Required - The size of the resource in bytes. - **`title`** (string) - Optional - Title for the boot resource. - **`filetype`** (string) - Optional - Filetype for uploaded content. (Default: `tgz`. Supported: `tgz`, `tbz`, `txz`, `ddtgz`, `ddtbz`, `ddtxz`, `ddtar`, `ddbz2`, `ddgz`, `ddxz`, `ddraw`) - **`base_image`** (string) - Optional - The Base OS image a custom image is built on top of. Only required for custom image. ### Responses #### Success Response (200) - A JSON object containing information about the uploaded resource. Content type: application/json ``` -------------------------------- ### Resolve 'No rule to make target ...OVMF_VARS.fd' Source: https://github.com/canonical/maas/blob/master/docs/reference/configuration-guides/troubleshooting.md This error means a required dependency for building is missing. Install the necessary packages as detailed in the custom image build guide. ```text make: *** No rule to make target '/usr/share/OVMF/OVMF_VARS.fd'... ``` -------------------------------- ### Python MAAS API Authentication Source: https://github.com/canonical/maas/blob/master/docs/reference/api-reference/api-login.md Authenticate and make a GET request to the MAAS API using the `requests_oauthlib` library. Ensure you have the `fades` library installed. Replace placeholders with your MAAS server IP and API key. ```text from oauthlib.oauth1 import SIGNATURE_PLAINTEXT from requests_oauthlib import OAuth1Session MAAS_HOST = "http://:5240/MAAS" CONSUMER_KEY, CONSUMER_TOKEN, SECRET = "".split(":") maas = OAuth1Session(CONSUMER_KEY, resource_owner_key=CONSUMER_TOKEN, resource_owner_secret=SECRET, signature_method=SIGNATURE_PLAINTEXT) nodes = maas.get(f"{MAAS_HOST}/api/2.0/machines/", params={"op": "list_allocated"}) nodes.raise_for_status() print(nodes.json()) ``` -------------------------------- ### Start New PostgreSQL Server and Verify Version Source: https://github.com/canonical/maas/blob/master/docs/uncategorized/upgrade-to-postgresql-v14.md Start the PostgreSQL service and then connect to the database to verify that the upgrade has resulted in PostgreSQL v14. ```bash sudo systemctl start postgresql.service sudo -u postgres psql -c "SELECT version();" ``` -------------------------------- ### Example Mounts Configuration Source: https://github.com/canonical/maas/blob/master/docs/uncategorized/create-custom-storage.md Defines filesystem mount points and their associated devices and options. ```text "mounts": { "/": { "device": "sda2", "options": "noatime" }, "/boot/efi": { "device": "sda1" }, "/data": { "device": "raid0" } } ``` -------------------------------- ### cURL MAAS API Authentication Source: https://github.com/canonical/maas/blob/master/docs/reference/api-reference/api-login.md Make an authenticated GET request to the MAAS API using cURL. This example demonstrates how to construct the Authorization header with OAuth parameters, including signature, nonce, and timestamp. Ensure the API_KEY environment variable is set and properly formatted. ```text curl --header "Authorization: OAuth oauth_version=1.0, oauth_signature_method=PLAINTEXT, oauth_consumer_key=$API_KEY[1], oauth_token=$API_KEY[2], oauth_signature=&$API_KEY[3], oauth_nonce=$(uuidgen), oauth_timestamp=$(date +%s)" $MAAS_URL/MAAS/api/2.0/users/ ``` -------------------------------- ### Create Setup Script for Bluefield Packages Source: https://github.com/canonical/maas/blob/master/docs/how-to-guides/deploy-dpus-without-bmc.md Generates a shell script to install the necessary Bluefield-specific kernel, headers, tools, and DOCA runtime packages on an Ubuntu system. This script configures apt sources and holds specific package versions to prevent unwanted upgrades. ```shell #!/bin/bash export DEBIAN_FRONTEND=noninteractive wget -qO - https://linux.mellanox.com/public/repo/doca/1.3.0/ubuntu20.04/aarch64/GPG-KEY-Mellanox.pub | apt-key add - echo "deb [trusted=yes] https://linux.mellanox.com/public/repo/doca/1.3.0/ubuntu20.04/\ $(ARCH) ./ " | tee /etc/apt/sources.list.d/doca.list apt-get update apt-get install -y -f \ linux-bluefield=5.4.0.1035.36 \ linux-bluefield-headers-5.4.0-1035=5.4.0-1035.38 \ linux-bluefield-tools-5.4.0-1035=5.4.0-1035.38 \ linux-headers-5.4.0-1035-bluefield=5.4.0-1035.38 \ linux-headers-bluefield=5.4.0.1035.36 \ linux-image-5.4.0-1035-bluefield=5.4.0-1035.38 \ linux-image-bluefield=5.4.0.1035.36 \ linux-modules-5.4.0-1035-bluefield=5.4.0-1035.38 \ linux-tools-5.4.0-1035-bluefield=5.4.0-1035.38 \ linux-tools-bluefield=5.4.0.1035.36 \ linux-libc-dev:arm64 \ linux-tools-common \ mlnx-ofed-kernel-modules \ doca-libs \ doca-runtime apt-mark hold linux-tools-bluefield linux-image-bluefield linux-bluefield \ linux-headers-bluefield linux-image-bluefield linux-libc-dev \ linux-tools-common mlnx-ofed-kernel-modules doca-libs doca-runtime mkdir -p /curtin echo -n "linux-bluefield=5.4.0.1035.36" > /curtin/CUSTOM_KERNEL ``` -------------------------------- ### Start New PostgreSQL Server and Verify Version Source: https://github.com/canonical/maas/blob/master/docs/uncategorized/upgrade-to-postgresql-v16.md Start the PostgreSQL service and verify that it is running the expected PostgreSQL v16 version using the psql client. ```bash sudo systemctl start postgresql sudo -u postgres psql -c "SELECT version();" ``` -------------------------------- ### Display MAAS init help message Source: https://github.com/canonical/maas/blob/master/docs/uncategorized/maas-3-3-release-notes.md Use the --help flag with 'maas init' to view available run modes and arguments for initializing MAAS. ```none sudo maas init --help ``` -------------------------------- ### Install MAAS 3.3 from PPA Source: https://github.com/canonical/maas/blob/master/docs/uncategorized/maas-3-3-release-notes.md Installs MAAS 3.3 on Ubuntu 22.04 LTS by adding the official MAAS PPA and then installing the MAAS package. This command initiates the package installation process. ```bash sudo apt-add-repository ppa:maas/3.3 sudo apt update sudo apt-get -y install maas ``` -------------------------------- ### MAAS CLI Help for Machine Details Source: https://github.com/canonical/maas/blob/master/docs/uncategorized/maas-3-0-release-notes.md Demonstrates how MAAS CLI provides contextual help when required arguments are missing, guiding users through command discovery. ```text $ PROFILE=foo $ maas login $PROFILE http://$MY_MAAS:5240/MAAS/ $APIKEY $ maas $PROFILE usage: maas $PROFILE [-h] COMMAND ... Issue commands to the MAAS region controller at http://$MY_MAAS:5240/MAAS/api/2.0/. optional arguments: -h, --help show this help message and exit drill down: COMMAND account Manage the current logged-in user. bcache-cache-set Manage bcache cache set on a machine. bcache-cache-sets Manage bcache cache sets on a machine. ✂️--cut for brevity--✂️ machine Manage an individual machine. machines Manage the collection of all the machines in the MAAS. node Manage an individual Node. nodes Manage the collection of all the nodes in the MAAS. ✂️--cut for brevity--✂️ too few arguments $ maas $PROFILE node usage: maas $PROFILE node [-h] COMMAND ... Manage an individual Node. optional arguments: -h, --help show this help message and exit drill down: COMMAND details Get system details power-parameters Get power parameters read Read a node delete Delete a node The Node is identified by its system_id. too few arguments $ maas $PROFILE node read usage: maas $PROFILE node read [--help] [-d] [-k] system_id [data [data ...]] Read a node positional arguments: system_id data optional arguments: --help, -h Show this help message and exit. -d, --debug Display more information about API responses. -k, --insecure Disable SSL certificate check Reads a node with the given system_id. the following arguments are required: system_id, data $ maas $PROFILE node read $SYSTEM_ID { "system_id": "$SYSTEM_ID", "domain": { "authoritative": true, "ttl": null, "is_default": true, "id": 0, "name": "maas", "resource_record_count": 200, "resource_uri": "/MAAS/api/2.0/domains/0/" ✂️--cut for brevity--✂️ ``` -------------------------------- ### Install Packer Dependencies for Ubuntu Images Source: https://github.com/canonical/maas/blob/master/docs/explanation/images.md Installs necessary packages for building Ubuntu images using Packer with MAAS. Ensure these are installed on your build machine. ```bash sudo apt install qemu-utils qemu-system ovmf cloud-image-utils ``` -------------------------------- ### Enlist Deployed Machine via Helper Script Source: https://github.com/canonical/maas/blob/master/docs/uncategorized/maas-3-1-release-notes.md Recommended for machines running Ubuntu, this method involves downloading and running a helper script from MAAS to register a deployed machine. This script helps in enlisting the machine without initial hardware information. ```bash $ wget http://$MAAS_IP:5240/MAAS/maas-run-scripts $ chmod 755 maas-run-scripts $ ./maas-run-scripts register-machine --hostname mymachine \ > http://$MAAS_IP:5240/MAAS $MAAS_API_TOKEN ``` -------------------------------- ### Install Prometheus Client and Restart MAAS Services Source: https://github.com/canonical/maas/blob/master/docs/how-to-guides/monitor-maas.md For Debian-based MAAS installations, install the python3-prometheus-client library and restart the rack and region services to expose Prometheus metrics. ```bash sudo apt install python3-prometheus-client sudo systemctl restart maas-rackd sudo systemctl restart maas-regiond ``` -------------------------------- ### Install MAAS test database snap Source: https://github.com/canonical/maas/blob/master/docs/uncategorized/maas-3-3-release-notes.md Install the 'maas-test-db' snap to set up a PostgreSQL database for testing and evaluating MAAS in a non-production environment. ```none sudo snap install maas-test-db ``` -------------------------------- ### GET /MAAS/api/2.0/subnets/{id}/ Source: https://github.com/canonical/maas/blob/master/docs/reference/api-reference/api-v2-generated.md Get information about a subnet with the given ID. ```APIDOC ## GET /MAAS/api/2.0/subnets/{id}/ ### Description Get information about a subnet with the given ID. ### Method GET ### Endpoint /MAAS/api/2.0/subnets/{id}/ ### Parameters #### Path Parameters - **{id}** (string, Required): - **{id}** (integer, Required): A subnet ID. ### Response #### Success Response (200) A JSON object containing information about the subnet. #### Response Example (No example provided in source) ``` -------------------------------- ### GET /MAAS/api/2.0/static-routes/{id}/ Source: https://github.com/canonical/maas/blob/master/docs/reference/api-reference/api-v2-generated.md Gets a static route with the given ID. ```APIDOC ## GET /MAAS/api/2.0/static-routes/{id}/ ### Description Gets a static route with the given ID. ### Method GET ### Endpoint /MAAS/api/2.0/static-routes/{id}/ ### Parameters #### Path Parameters - **{id}** (string, Required): - **{id}** (integer, Required): A static-route ID. ### Response #### Success Response (200) A JSON object containing information about the requested static route. #### Response Example (No example provided in source) ``` -------------------------------- ### Install MAAS 3.1 using apt PPA Source: https://github.com/canonical/maas/blob/master/docs/uncategorized/maas-3-1-release-notes.md Install MAAS 3.1 by adding the official PPA and then installing the package. This method is suitable for systems that prefer package management. ```text sudo add-apt-repository ppa:maas/3.1 sudo apt update sudo apt install maas ``` -------------------------------- ### Install LXD and ZFS for Containerization Source: https://github.com/canonical/maas/blob/master/INSTALL.txt Installs LXD and ZFS utilities, loads the ZFS module, and initializes LXD. These are prerequisites for running MAAS within an LXC container. ```bash $ sudo apt-get install lxd zfsutils-linux ``` ```bash $ sudo modprobe zfs ``` ```bash $ sudo lxd init ``` -------------------------------- ### Install SNMP MIBs on MAAS Server Source: https://github.com/canonical/maas/blob/master/docs/reference/configuration-guides/troubleshooting.md Install necessary MIBs to resolve 'Cannot find module' errors. This requires downloading and installing the snmp-mibs-downloader package and then running the download-mibs command. ```bash sudo apt-get install snmp-mibs-downloader sudo download-mibs ``` -------------------------------- ### Import MAAS Boot Resources via CLI Source: https://github.com/canonical/maas/blob/master/INSTALL.txt Initiates the download of boot images using the MAAS command-line client. Ensure you are logged into the MAAS API first. ```bash $ maas my-maas-session boot-resources import ``` -------------------------------- ### GET /MAAS/api/2.0/devices/{system_id}/op-power_parameters Source: https://github.com/canonical/maas/blob/master/docs/reference/api-reference/api-v2-generated.md Gets power parameters for a given system_id, if any. ```APIDOC ## GET /MAAS/api/2.0/devices/{system_id}/op-power_parameters ### Description Gets power parameters for a given system_id, if any. For some types of power control this will include private information such as passwords and secret keys. Note that this method is reserved for admin users and returns a 403 if the user is not one. ### Method GET ### Endpoint /MAAS/api/2.0/devices/{system_id}/op-power_parameters ### Parameters #### Path Parameters - **{system_id}** (string) - Required - ### Responses #### Success Response (200) - **200** #### Error Response (403) - **FORBIDDEN**: The user does not have permission to see the power parameters. #### Error Response (404) - **NOT FOUND**: The requested node is not found. ``` -------------------------------- ### Set PXE Boot and Power On Host Source: https://github.com/canonical/maas/blob/master/docs/how-to-guides/deploy-dpus-without-bmc.md Use ipmitool to configure the host to PXE boot and then power it on. This is typically done before enlisting the host into MAAS. ```shell ipmitool -H $bmc_ip -I lanplus -U $bmc_user -P $bmc_pass chassis bootdev pxe ipmitool -H $bmc_ip -I lanplus -U $bmc_user -P $bmc_pass chassis power on ```