### Install MAAS via Snap Source: https://maas.io/docs/how-to-install-maas Installs the MAAS snap package. This method offers simplified installation, updates, and isolation. Replace `$VERSION` with the target MAAS release. ```Shell sudo snap install --channel=$VERSION maas ``` -------------------------------- ### Initialize MAAS Region and Rack Controller Source: https://maas.io/docs/how-to-install-maas Initializes the MAAS installation as a combined region and rack controller, connecting it to the previously configured PostgreSQL database using the provided URI. ```Shell sudo maas init region+rack --database-uri "postgres://$DBUSER:$DBPASS@$HOSTNAME/$DBNAME" ``` -------------------------------- ### Configure PostgreSQL for MAAS Production Database Source: https://maas.io/docs/how-to-install-maas Installs PostgreSQL and sets up a dedicated user and database for MAAS. This is a prerequisite for running MAAS in a production environment. ```Shell sudo apt install -y postgresql sudo -i -u postgres psql -c "CREATE USER \"$DBUSER\" WITH ENCRYPTED PASSWORD '$DBPASS'" sudo -i -u postgres createdb -O "$DBUSER" "$DBNAME" ``` -------------------------------- ### Verify MAAS Installation and Ubuntu Version Source: https://maas.io/docs/how-to-install-maas These commands are used to verify the current Ubuntu operating system version and the installed MAAS version after an upgrade or installation. This helps confirm that the system meets requirements and the MAAS upgrade was successful. ```bash lsb_release -a ``` ```bash maas --version ``` -------------------------------- ### Install MAAS using Snap Source: https://maas.io/docs/how-to-get-maas-up-and-running Installs MAAS using the snap package manager. Replace `$VERSION` with the desired MAAS version for installation. ```bash sudo snap install --channel=$VERSION maas ``` -------------------------------- ### Install MAAS via Debian Packages Source: https://maas.io/docs/how-to-install-maas Installs MAAS using traditional Debian packages from the official MAAS PPA. This involves adding the repository, updating package lists, and installing the `maas` package. ```Shell sudo apt-add-repository ppa:maas/ sudo apt update sudo apt-get -y install maas ``` -------------------------------- ### Configure PostgreSQL for MAAS Production Database Source: https://maas.io/docs/how-to-get-maas-up-and-running Installs PostgreSQL, creates a new user with an encrypted password, and then creates a database owned by that user. These steps prepare PostgreSQL to serve as the backend database for a MAAS production deployment. ```bash sudo apt install -y postgresql sudo -i -u postgres psql -c "CREATE USER \"$DBUSER\" WITH ENCRYPTED PASSWORD '$DBPASS'" sudo -i -u postgres createdb -O "$DBUSER" "$DBNAME" ``` -------------------------------- ### Create Initial MAAS Admin User Source: https://maas.io/docs/how-to-install-maas Creates the first administrative user for MAAS, which is necessary for logging into the MAAS web UI or using the MAAS CLI. Replace `$PROFILE` and `$EMAIL_ADDRESS` with desired values. ```Shell sudo maas create admin --username=$PROFILE --email=$EMAIL_ADDRESS ``` -------------------------------- ### Prepare and Initialize LXD for MAAS Integration Source: https://maas.io/docs/about-lxd These commands guide you through the process of setting up LXD as a VM host for MAAS. It includes steps to remove any old LXD installations, install and initialize the latest LXD snap package, and configure the LXD bridge to disable DHCP, ensuring MAAS can manage IP assignments. ```bash sudo apt-get purge -y *lxd* *lxc* sudo apt-get autoremove -y ``` ```bash sudo snap install lxd sudo snap refresh sudo lxd init ``` ```bash lxc network set lxdbr0 dns.mode=none lxc network set lxdbr0 ipv4.dhcp=false lxc network set lxdbr0 ipv6.dhcp=false ``` -------------------------------- ### Install MAAS using Debian Packages Source: https://maas.io/docs/how-to-get-maas-up-and-running Installs MAAS using traditional Debian packages from a PPA. This involves adding the MAAS repository, updating package lists, and then installing the `maas` package. ```bash sudo apt-add-repository ppa:maas/ sudo apt update sudo apt-get -y install maas ``` -------------------------------- ### Authenticate MAAS CLI Session Source: https://maas.io/docs/how-to-install-maas Logs into the MAAS command-line interface using a specified profile, the MAAS API URL, and an API key read from a file. This establishes an authenticated session for subsequent CLI commands. ```Shell maas login $PROFILE $MAAS_URL $(cat api-key-file) ``` -------------------------------- ### Install MAAS Test Database and Initialize Source: https://maas.io/docs/init Demonstrates the process of installing the `maas-test-db` snap, which provides a PostgreSQL database suitable for non-production MAAS deployments, and subsequently initializing MAAS in `region+rack` mode using this test database. ```bash sudo snap install maas-test-db sudo maas init region+rack --database-uri maas-test-db:/// ``` -------------------------------- ### Install and Initialize MAAS Rack Controller (Snap) Source: https://maas.io/docs/how-to-manage-high-availability Installs the MAAS rack controller using snap and initializes it with the MAAS URL and secret, automatically enabling high availability for rack services. ```bash sudo snap install maas sudo maas init rack --maas-url $MAAS_URL --secret $SECRET ``` -------------------------------- ### Check MAAS Service Status Source: https://maas.io/docs/how-to-install-maas Displays the operational status of all MAAS-related services, indicating whether they are running, stopped, or in other states. Useful for quick health checks. ```Shell sudo maas status ``` -------------------------------- ### Install MAAS Region API for PostgreSQL HA Setup Source: https://maas.io/docs/how-to-manage-high-availability Installs the `maas-region-api` package on a host designated to be a secondary region controller, as part of setting up highly available PostgreSQL for MAAS. ```bash sudo apt install maas-region-api ``` -------------------------------- ### Configure LXD for MAAS VM Provisioning Source: https://maas.io/docs/how-to-manage-machines Step-by-step guide to prepare an LXD environment for use with MAAS. This includes removing old LXD versions, installing and initializing LXD, and configuring the LXD bridge to disable DHCP, ensuring proper MAAS integration for VM provisioning. ```Bash sudo apt-get purge -y *lxd* *lxc* sudo apt-get autoremove -y ``` ```Bash sudo snap install lxd sudo snap refresh sudo lxd init Configuration prompts: * Clustering: `no` * Storage: `dir` * MAAS Connection: `no` * Existing Bridge: `yes` (`br0`) * Trust Password: Provide a password ``` ```Bash lxc network set lxdbr0 dns.mode=none lxc network set lxdbr0 ipv4.dhcp=false lxc network set lxdbr0 ipv6.dhcp=false ``` -------------------------------- ### Install Core Image Building Dependencies Source: https://maas.io/docs/how-to-build-custom-images This command installs `qemu-utils`, a utility package required for various image building operations, particularly for virtual machine image manipulation. ```bash sudo apt install qemu-utils ``` -------------------------------- ### Upgrade MAAS to Version 3.5 (Snap and Package) Source: https://maas.io/docs/how-to-install-maas This snippet provides commands to upgrade MAAS to version 3.5 using both snap and PPA-based package management. For PPA upgrades, ensure the correct repository is added and then perform a system update and upgrade. ```bash sudo snap refresh maas --channel=3.5/stable ``` ```bash sudo apt-add-repository ppa:maas/3.5 sudo apt update && sudo apt upgrade maas ``` -------------------------------- ### Configure DHCP and Gateway for MAAS VLANs via CLI Source: https://maas.io/docs/how-to-install-maas These commands enable DHCP on a specified MAAS VLAN and set the default gateway for a subnet. Ensure MAAS variables like $PROFILE, $FABRIC_ID, $PRIMARY_RACK_CONTROLLER, $SUBNET_CIDR, and $MY_GATEWAY are correctly defined before execution. ```bash maas $PROFILE vlan update $FABRIC_ID untagged dhcp_on=True \ primary_rack=$PRIMARY_RACK_CONTROLLER ``` ```bash maas $PROFILE subnet update $SUBNET_CIDR gateway_ip=$MY_GATEWAY ``` -------------------------------- ### Upgrade MAAS to Version 3.3 (Snap and Package) Source: https://maas.io/docs/how-to-install-maas This snippet provides commands to upgrade MAAS to version 3.3 using both snap and PPA-based package management. For PPA upgrades, ensure the correct repository is added and then perform a system update and upgrade. ```bash sudo snap refresh maas --channel=3.3/stable ``` ```bash sudo apt-add-repository ppa:maas/3.3 sudo apt update && sudo apt upgrade maas ``` -------------------------------- ### Install MAAS Rack Controller via Snap Source: https://maas.io/docs/how-to-enable-high-availability Installs the MAAS snap and initializes a rack controller, enabling high availability. This method is for snap-based MAAS installations and requires the MAAS URL and a secret for registration. ```bash sudo snap install maas sudo maas init rack --maas-url $MAAS_URL --secret $SECRET ``` -------------------------------- ### Log in to MAAS CLI Source: https://maas.io/docs/how-to-get-maas-up-and-running Authenticates the MAAS CLI client. This command requires a profile name, the MAAS API URL, and an API key read from a file to establish a session. ```bash maas login $PROFILE $MAAS_URL $(cat api-key-file) ``` -------------------------------- ### Install and Initialize MAAS Rack Controller (Snap) Source: https://maas.io/docs/how-to-manage-controllers Installs the MAAS snap package and initializes a rack controller. This command is used to set up a new rack controller instance, contributing to MAAS high availability. Requires the MAAS URL and a secret for registration. ```bash sudo snap install maas sudo maas init rack --maas-url $MAAS_URL --secret $SECRET ``` -------------------------------- ### Upgrade MAAS to Version 3.6 (Snap and Package) Source: https://maas.io/docs/how-to-install-maas This snippet provides commands to upgrade MAAS to version 3.6 using both snap and PPA-based package management. For PPA upgrades, ensure the correct repository is added and then perform a system update and upgrade. ```bash sudo snap refresh maas --channel=3.6/stable ``` ```bash sudo apt-add-repository ppa:maas/3.6 sudo apt update && sudo apt upgrade maas ``` -------------------------------- ### Install SimpleStreams for local MAAS mirror Source: https://maas.io/docs/how-to-manage-images This command installs the `simplestreams` package, which is a prerequisite for setting up and managing a local image mirror for MAAS. It provides the necessary tools for synchronizing image data. ```bash sudo apt install simplestreams ``` -------------------------------- ### Upgrade MAAS to 3.5 via PPA Source: https://maas.io/docs/how-to-get-maas-up-and-running These commands upgrade MAAS to version 3.5 for PPA-based installations. First, the MAAS 3.5 PPA is added, then the package lists are updated, and finally, the 'maas' package is upgraded. This requires root privileges and an active internet connection. ```bash sudo apt-add-repository ppa:maas/3.5 ``` ```bash sudo apt update && sudo apt upgrade maas ``` -------------------------------- ### Verify MAAS and Ubuntu Versions Post-Upgrade Source: https://maas.io/docs/how-to-get-maas-up-and-running These commands are used to verify the system's state after a MAAS upgrade. `lsb_release -a` displays the Ubuntu distribution information, ensuring the correct OS version. `maas --version` confirms the installed MAAS version, validating the upgrade's success. ```bash lsb_release -a ``` ```bash maas --version ``` -------------------------------- ### Upgrade MAAS 2.9-3.3 to 3.5 with Prerequisites Source: https://maas.io/docs/how-to-get-maas-up-and-running This sequence of commands facilitates upgrading MAAS from versions 2.9-3.3 to 3.5, including checks for Ubuntu version and an optional Ubuntu upgrade. It adds the MAAS 3.5 PPA, performs the upgrade, and verifies the MAAS installation. PostgreSQL 14 is a prerequisite. ```bash lsb_release -a ``` ```bash sudo do-release-upgrade --allow-third-party ``` ```bash sudo apt-add-repository ppa:maas/3.5 ``` ```bash sudo apt update && sudo apt upgrade maas ``` ```bash maas --version ``` -------------------------------- ### Install MAAS Region API for Secondary Controller Source: https://maas.io/docs/how-to-manage-high-availability Installs the `maas-region-api` package on a secondary host, preparing it to function as an additional MAAS region controller for high availability. ```bash sudo apt install maas-region-api ``` -------------------------------- ### Real-world Example: Intel C610/X99 HPA Controller Configuration Source: https://maas.io/docs/reference-commissioning-scripts This is a real-world Bash script example for configuring an Intel C610/X99 HPA controller on HP systems. The `-ex` option ensures that the script exits immediately if a command exits with a non-zero status and prints commands and their arguments as they are executed, aiding in debugging and ensuring robust execution. ```Bash #!/bin/bash -ex ``` -------------------------------- ### Create MAAS Admin User Source: https://maas.io/docs/how-to-get-maas-up-and-running Creates an administrative user for MAAS with a specified username and email address. This user will be used to log into the MAAS UI and CLI. ```bash sudo maas create admin --username=$PROFILE --email=$EMAIL_ADDRESS ``` -------------------------------- ### Example Router Configuration for MAAS Subnets Source: https://maas.io/docs/maas-troubleshooting-guide This example illustrates how network devices like routers should be configured to facilitate communication between the MAAS server's subnet and a routed subnet. It includes setting up DHCP relay and defining IP routes. ```Network Configuration Router Configuration: - DHCP relay pointing to 10.10.10.2 - IP routes allowing traffic between 10.20.20.0/24 and 10.10.10.0/24 ``` -------------------------------- ### Upgrade MAAS to 3.3 via PPA Source: https://maas.io/docs/how-to-get-maas-up-and-running These commands upgrade MAAS to version 3.3 for PPA-based installations. First, the MAAS 3.3 PPA is added, then the package lists are updated, and finally, the 'maas' package is upgraded. This requires root privileges and an active internet connection. ```bash sudo apt-add-repository ppa:maas/3.3 ``` ```bash sudo apt update && sudo apt upgrade maas ``` -------------------------------- ### Install and Register MAAS Rack Controller (Package) Source: https://maas.io/docs/how-to-manage-high-availability Installs the MAAS rack controller via apt for package-based systems, then registers it with the MAAS URL and secret, enabling high availability. ```bash sudo apt install maas-rack-controller sudo maas-rack register --url $MAAS_URL --secret $SECRET ``` -------------------------------- ### Install Additional Dependencies for Oracle Linux and VMware ESXi Images Source: https://maas.io/docs/how-to-build-custom-images These commands install specific dependencies like `libnbd-bin`, `nbdkit`, `fuse2fs`, and `qemu-utils` which are required when building images for Oracle Linux 8/9 and VMware ESXi. ```bash sudo apt install libnbd-bin nbdkit fuse2fs qemu-utils ``` -------------------------------- ### Upgrade MAAS to 3.6 via PPA Source: https://maas.io/docs/how-to-get-maas-up-and-running These commands upgrade MAAS to version 3.6 for PPA-based installations. First, the MAAS 3.6 PPA is added, then the package lists are updated, and finally, the 'maas' package is upgraded. This requires root privileges and an active internet connection. ```bash sudo apt-add-repository ppa:maas/3.6 ``` ```bash sudo apt update && sudo apt upgrade maas ``` -------------------------------- ### Verify lldpd Package Availability and Installation Source: https://maas.io/docs/maas-troubleshooting-guide These commands are used on a test machine to update the package lists from the configured repositories and then attempt to install the `lldpd` package. This step verifies that the local mirror is correctly configured and that the `lldpd` package is indeed available and installable, confirming the resolution of the commissioning issue. ```Shell sudo apt-get update sudo apt-get install lldpd ``` -------------------------------- ### MAAS Machine Deployment CLI Commands Source: https://maas.io/docs/how-to-manage-machines Commands for allocating and deploying machines in MAAS, including options for ephemeral deployment, KVM installation, and custom cloud-init scripts. ```APIDOC maas $PROFILE machines allocate system_id=$SYSTEM_ID - Description: Claims exclusive ownership of a machine to avoid conflicts. - Parameters: - system_id (string): The unique identifier of the machine to allocate. maas $PROFILE machine deploy $SYSTEM_ID - Description: Deploys a machine with its default configuration. - Parameters: - system_id (string): The unique identifier of the machine to deploy. maas $PROFILE machine deploy $SYSTEM_ID ephemeral_deploy=true - Description: Deploys an ephemeral instance into machine RAM, ignoring any disk drives. - Parameters: - system_id (string): The unique identifier of the machine. - ephemeral_deploy (boolean): Set to 'true' for ephemeral deployment. maas $PROFILE machine deploy $SYSTEM_ID install_kvm=True - Description: Deploys a bare-metal machine as a virtual machine host with KVM installed. - Parameters: - system_id (string): The unique identifier of the machine. - install_kvm (boolean): Set to 'True' to install KVM. maas $PROFILE machine deploy $SYSTEM_ID cloud_init_userdata="$(cat cloud-init.yaml)" - Description: Deploys a machine with custom cloud-init scripts for varied use-cases. - Parameters: - system_id (string): The unique identifier of the machine. - cloud_init_userdata (string): The content of the cloud-init script, typically read from a file. ``` -------------------------------- ### MAAS CLI: Login with TLS Example Source: https://maas.io/docs/how-to-enhance-maas-security Example command to log in to the MAAS CLI using an HTTPS URL and a specified port, demonstrating how to connect to a TLS-enabled MAAS API. ```Shell maas login https://mymaas:5443/MAAS ``` -------------------------------- ### Initialize MAAS with Production PostgreSQL Database Source: https://maas.io/docs/how-to-get-maas-up-and-running Initializes MAAS as a combined region and rack controller, connecting it to the specified PostgreSQL database using the provided database URI. This command links MAAS to its persistent data store. ```bash sudo maas init region+rack --database-uri "postgres://$DBUSER:$DBPASS@$HOSTNAME/$DBNAME" ``` -------------------------------- ### DNS SRV Record Format and Example Source: https://maas.io/docs/maas-troubleshooting-guide Defines the standard syntax for DNS Service Location (SRV) records, including fields like service, protocol, name, TTL, class, priority, weight, port, and target. An example demonstrates how to define an SRV record for '_myservice._tcp.test'. ```dns _service._protocol.name. TTL class SRV priority weight port target. _myservice._tcp.test. 30 IN SRV 10 10 1234 t1.test. ``` -------------------------------- ### Disable Conflicting NTP Service for MAAS Source: https://maas.io/docs/how-to-install-maas Disables and stops the `systemd-timesyncd` service to prevent potential time synchronization conflicts when setting up MAAS in a production environment. ```Shell sudo systemctl disable --now systemd-timesyncd ``` -------------------------------- ### Upgrade MAAS 2.8 or Earlier to 3.5 via Packages Source: https://maas.io/docs/how-to-install-maas This command sequence is for upgrading MAAS installations from version 2.8 or earlier to 3.5 using PPA-based packages. It assumes Ubuntu 22.04 is already in place or has been upgraded separately, then adds the MAAS 3.5 PPA and performs the package upgrade. ```bash sudo apt-add-repository ppa:maas/3.5 sudo apt update && sudo apt upgrade maas ``` -------------------------------- ### Disable systemd-timesyncd to Avoid NTP Conflicts Source: https://maas.io/docs/how-to-install-maas This command disables and stops the `systemd-timesyncd` service. It is useful for resolving time synchronization conflicts, especially when another NTP service is preferred or causing issues. ```bash sudo systemctl disable --now systemd-timesyncd ``` -------------------------------- ### MAAS CLI Commands Reference Source: https://maas.io/docs/how-to-deploy-a-real-time-kernel This comprehensive reference lists all available MAAS command-line interface commands, enabling direct management and interaction with MAAS components from the terminal. ```APIDOC account apikey bcache bcache-cache-set block-device boot-resource boot-source-selection boot-source changepassword commissioning-scripts configauth config config-tls config-vault createadmin device dhcp-snippet discovery dnsresource-records dnsresource domain events fabric file init interface ipaddresses iprange license-key list login logout maas machine migrate network node node-device node-result node-script-result node-script notification package-repository partition pod rack-controller raid refresh region-controller resource-pool space sshkey sslkey static-route status subnet tag user version vlan vm-cluster vmfs-datastores vm-host volume-group zone ``` -------------------------------- ### Add SSH Public Key to MAAS via CLI Source: https://maas.io/docs/how-to-install-maas Adds an SSH public key to the MAAS system via the CLI. This key can be used by MAAS to access deployed machines or for user authentication. ```Shell maas $PROFILE sshkeys create "key=$SSH_KEY" ``` -------------------------------- ### Configure MAAS Upstream DNS via CLI Source: https://maas.io/docs/how-to-install-maas Sets the global upstream DNS server for MAAS using the CLI. This ensures MAAS can resolve external hostnames for image downloads or other network operations. ```Shell maas $PROFILE maas set-config name=upstream_dns value="8.8.8.8" ``` -------------------------------- ### MAAS API Reference Source: https://maas.io/docs/how-to-deploy-a-real-time-kernel This section provides references to the MAAS API documentation, covering authentication, user profile management, and general API interactions for programmatic control of MAAS. ```APIDOC API login: Details on authenticating to the MAAS API to obtain access tokens. API profile: Information on managing user profiles, including retrieving and updating user-specific settings via the API. API reference: Comprehensive documentation covering all available MAAS API endpoints, their methods, parameters, and expected responses. ``` -------------------------------- ### Upgrade MAAS 2.9-3.3 to 3.5 via Packages with Ubuntu Check Source: https://maas.io/docs/how-to-install-maas This sequence of commands facilitates upgrading MAAS from versions 2.9-3.3 to 3.5 when installed via packages. It includes steps to check and upgrade the Ubuntu operating system to 22.04 (Jammy) if necessary, add the MAAS 3.5 PPA, and then perform the MAAS package upgrade and verification. ```bash lsb_release -a ``` ```bash sudo do-release-upgrade --allow-third-party ``` ```bash sudo apt-add-repository ppa:maas/3.5 sudo apt update && sudo apt upgrade maas ``` ```bash maas --version ``` -------------------------------- ### Allow MAAS Database Access in PostgreSQL Source: https://maas.io/docs/how-to-install-maas Adds an entry to the PostgreSQL `pg_hba.conf` file to allow the MAAS database user to connect to its dedicated database from any host using MD5 authentication. This enables MAAS to communicate with its backend database. ```PostgreSQL host $MAAS_DBNAME $MAAS_DBUSER 0/0 md5 ``` -------------------------------- ### Upgrade MAAS to Version 3.4 (Snap and Package) Source: https://maas.io/docs/how-to-install-maas This snippet provides commands to upgrade MAAS to version 3.4 using both snap and PPA-based package management. For PPA upgrades, ensure the correct repository is added and then perform a system update and upgrade. ```bash sudo snap refresh maas --channel=3.4/stable ``` ```bash sudo apt-add-repository ppa:maas/3.4 sudo apt update && sudo apt upgrade maas ``` -------------------------------- ### Perform a full MAAS system backup using pg_dumpall and snap Source: https://maas.io/docs/how-to-back-up-maas This procedure outlines the steps to create a complete backup of MAAS, including the PostgreSQL database and snap snapshot, for a clean reset. It involves dumping the database, stopping MAAS services, saving and exporting the snap snapshot, and then restarting services. ```bash sudo systemctl list-units --type=service | grep postgres mkdir -p /$(date +%s) sudo -u postgres pg_dumpall -c > "/$(date +%s)_dump.sql" sudo snap stop maas sudo systemctl stop postgresql.service sudo snap save maas sudo snap export-snapshot /$(date +%s)_snapshot sudo systemctl start postgresql.service sudo snap restart maas ``` -------------------------------- ### MAAS CLI: Initialize MAAS Command Reference Source: https://maas.io/docs/init Documents the `maas init` command, its syntax, available command-line options, and the different run modes for initializing MAAS controllers. This command is crucial for setting up MAAS instances. ```APIDOC maas init [-h] {region+rack,region,rack} ... - Initializes MAAS in the specified run mode. Command-line options: -h, --help: show this help message and exit Run modes: region+rack: Both region and rack controllers region: Region controller only rack: Rack controller only ``` -------------------------------- ### Configure PostgreSQL pg_hba.conf for MAAS Database Access Source: https://maas.io/docs/how-to-get-maas-up-and-running Adds a specific host entry to the PostgreSQL `pg_hba.conf` file, allowing the newly created MAAS database user to connect from any host using MD5 authentication. This line should be appended to `/etc/postgresql/14/main/pg_hba.conf`. ```configuration host $MAAS_DBNAME $MAAS_DBUSER 0/0 md5 ``` -------------------------------- ### Install and Configure Secondary Region Controller for HA PostgreSQL Source: https://maas.io/docs/how-to-manage-controllers Installs the `maas-region-api` package on a secondary host, copies the primary region's configuration, and sets the database host to enable connection to a shared PostgreSQL database. This is a crucial step for highly-available PostgreSQL in a multi-region controller setup. ```bash sudo apt install maas-region-api sudo scp ubuntu@$PRIMARY_API:/etc/maas/regiond.conf /etc/maas/ sudo maas-region local_config_set --database-host $PRIMARY_PG_SERVER sudo systemctl restart bind9 sudo systemctl start maas-regiond ``` -------------------------------- ### Disable systemd-timesyncd for MAAS Production Setup Source: https://maas.io/docs/how-to-get-maas-up-and-running Disables and stops the `systemd-timesyncd` service immediately. This is a crucial step in a MAAS production environment to prevent potential NTP conflicts. ```bash sudo systemctl disable --now systemd-timesyncd ``` -------------------------------- ### Example of 'packer' Command Not Found Error Source: https://maas.io/docs/maas-troubleshooting-guide This snippet illustrates the typical error message displayed in a Unix-like terminal when the 'packer' command is invoked but is not found in the system's executable path. It indicates that Packer is either not installed or not correctly configured in the environment. ```Bash stormrider@neuromancer:~$ packer Command 'packer' not found... ``` -------------------------------- ### Configure Local Ubuntu Mirror for MAAS Source: https://maas.io/docs/maas-troubleshooting-guide This line demonstrates a correct entry for a local Ubuntu mirror in a `sources.list` file, ensuring all essential components like `main`, `universe`, `restricted`, and `multiverse` are included for a specific Ubuntu release (focal in this case). This is crucial for disconnected environments to provide all necessary packages. ```Shell deb http://192.168.1.100/repos/archive.ubuntu.com/ubuntu focal main universe restricted multiverse ``` -------------------------------- ### Upgrade MAAS to 3.4 via PPA Source: https://maas.io/docs/how-to-get-maas-up-and-running These commands upgrade MAAS to version 3.4 for PPA-based installations. First, the MAAS 3.4 PPA is added, then the package lists are updated, and finally, the 'maas' package is upgraded. This requires root privileges and an active internet connection. ```bash sudo apt-add-repository ppa:maas/3.4 ``` ```bash sudo apt update && sudo apt upgrade maas ``` -------------------------------- ### Configure DHCP and Gateway for MAAS VLANs using CLI Source: https://maas.io/docs/how-to-get-maas-up-and-running These commands enable DHCP on a specified MAAS VLAN and set the default gateway for a subnet. They require MAAS CLI access, a configured MAAS profile, fabric ID, primary rack controller, subnet CIDR, and gateway IP. Ensure variables are correctly substituted. ```bash maas $PROFILE vlan update $FABRIC_ID untagged dhcp_on=True \ primary_rack=$PRIMARY_RACK_CONTROLLER ``` ```bash maas $PROFILE subnet update $SUBNET_CIDR gateway_ip=$MY_GATEWAY ``` -------------------------------- ### Open BIND named.conf.options File Source: https://maas.io/docs/maas-troubleshooting-guide Opens the `named.conf.options` file for editing using the nano text editor. This file contains global configuration options for the BIND DNS server, specifically for apt-installed MAAS. ```bash sudo nano /etc/bind/named.conf.options ``` -------------------------------- ### Configure Cloud-init for RT Kernel (cloud-init < 23.4) Source: https://maas.io/docs/how-to-deploy-a-real-time-kernel This cloud-init configuration snippet is for cloud-init versions older than 23.4. It first updates and upgrades packages, then uses `pro attach` to link the Ubuntu Pro token and `pro enable realtime-kernel` to activate the real-time kernel. Replace `` with your valid Ubuntu Pro token. ```YAML #cloud-config package_update: true package_upgrade: true runcmd: - pro attach - yes | pro enable realtime-kernel ``` -------------------------------- ### Define Multiple MAAS Region Controller Endpoints Source: https://maas.io/docs/how-to-enable-high-availability This configuration snippet allows defining multiple MAAS region controller endpoints in `rackd.conf` (for Snap or package installations). This setup enables rack controllers to discover and connect to available region controllers, enhancing the resilience and availability of the MAAS environment. ```YAML maas_url: - http://:/MAAS/ - http://:/MAAS/ ``` -------------------------------- ### Example JSON for Custom Storage Mounts in MAAS Source: https://maas.io/docs/how-to-manage-machines Illustrates the `mounts` section within a custom MAAS storage configuration JSON. This section defines desired filesystem mount points, specifying the device (e.g., partition, LVM volume, RAID) and optional mount options for each. ```json "mounts": { "/": { "device": "sda2", "options": "noatime" }, "/boot/efi": { "device": "sda1" }, "/data": { "device": "raid0" } } ``` -------------------------------- ### Verify MAAS Machine List Source: https://maas.io/docs/about-lxd Instructions for reviewing the list of machines in MAAS to verify settings, available via both UI and CLI. ```APIDOC Verify machine list: Description: Periodically review your machine list to verify settings. UI: Machines > (View list or search) CLI: maas $PROFILE machines read | jq -r '.[].hostname' ``` -------------------------------- ### Perform authenticated MAAS API request with Ruby Source: https://maas.io/docs/how-to-authenticate-to-the-maas-api This Ruby example illustrates how to authenticate and make an API request to MAAS using the `oauth` gem. It defines a helper function `perform_API_request` that sets up an OAuth consumer and access token for a GET request. Placeholders for server, URI, and API key components need to be updated. ```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") ``` -------------------------------- ### Automate MAAS Network and Power Configuration via Preseed Source: https://maas.io/docs/maas-troubleshooting-guide This 'curtin_userdata' preseed configuration block defines 'early_commands' to automate initial machine setup. It configures all network interfaces to use DHCP and sets the MAAS power configuration to 'manual' during the early stages of machine deployment. ```shell early_commands: 10_dhcp: | for nic in $(ls /sys/class/net/ | grep -v lo); do echo "dhclient ${nic}" >> /etc/network/interfaces.d/${nic}; dhclient ${nic} done 20_power: | echo "manual" > /etc/maas/power.conf ``` -------------------------------- ### Authenticate and fetch MAAS nodes using Python Source: https://maas.io/docs/how-to-authenticate-to-the-maas-api This Python example demonstrates 0-legged OAuth authentication to the MAAS API using `requests_oauthlib`. It shows how to construct an `OAuth1Session` and make an authenticated GET request to retrieve a list of allocated machines. Users must replace placeholder values for the MAAS host and API key components. ```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()) ``` -------------------------------- ### MAAS Custom Storage Layout: Bcache Device Configuration Example Source: https://maas.io/docs/about-lxd This JSON snippet demonstrates the configuration for a 'bcache' device within a MAAS custom storage layout. A 'bcache' entry must specify a device to use as cache and one to use as storage, both of which can be either a partition or a disk. Optionally, the 'cache-mode' for the Bcache can be specified. This configuration is used within the 'layouts' section of the custom storage setup. ```JSON "bcache0": { "type": "bcache", "cache-device": "sda", "backing-device": "sdf3", "cache-mode": "writeback", "fs": "ext4" } ``` -------------------------------- ### Install MAAS Rack Controller via Package Source: https://maas.io/docs/how-to-enable-high-availability Installs the MAAS rack controller package and registers it with a MAAS instance. This method is for package-based MAAS installations and requires the MAAS URL and a secret for registration. ```bash sudo apt install maas-rack-controller sudo maas-rack register --url $MAAS_URL --secret $SECRET ``` -------------------------------- ### MAAS Machine Deployment Operations Source: https://maas.io/docs/about-lxd Comprehensive documentation for deploying machines in MAAS, covering allocation, standard deployment, ephemeral deployment, VM host setup, and custom cloud-init configurations via both UI and CLI. ```APIDOC Allocate a machine: Description: Claim exclusive ownership of a machine to avoid conflicts. UI: Machines > [machine(s)] > Take action > Allocate CLI: maas $PROFILE machines allocate system_id=$SYSTEM_ID Deploy a machine: Description: Simultaneously deploy multiple machines, if desired, within resource limits. UI: Machines > [machine(s)] > Take action > Deploy > Deploy machine CLI: maas $PROFILE machine deploy $SYSTEM_ID Deploy to RAM (ephemeral deployment): Description: Deploy an ephemeral instance (into machine RAM, ignoring any disk drives). UI: Machines > [machine(s)] > Take action > Deploy > Deploy in memory > Deploy machine CLI: maas $PROFILE machine deploy $SYSTEM_ID ephemeral_deploy=true Deploy as a VM host: Description: Deploy a bare-metal machine as a virtual machine host. UI: Machines > [machine] > Take action > Deploy > Install KVM CLI: maas $PROFILE machine deploy $SYSTEM_ID install_kvm=True Deploy with custom cloud-init scripts: Description: Use cloud-init to vary machine use-cases and application loads. UI: Machines > [machine] > Take action > Deploy > Configuration options CLI: maas $PROFILE machine deploy $SYSTEM_ID cloud_init_userdata="$(cat cloud-init.yaml)" ``` -------------------------------- ### Install Python Pip for VMware ESXi Image Building Source: https://maas.io/docs/how-to-build-custom-images This command installs `pip`, the Python package installer, which is a prerequisite for building VMware ESXi images, likely for Python-based scripts or tools used in the process. ```bash sudo apt install pip ``` -------------------------------- ### Configure Cloud-init for RT Kernel (cloud-init >= 23.4) Source: https://maas.io/docs/how-to-deploy-a-real-time-kernel This cloud-init configuration snippet is used for cloud-init versions 23.4 and newer. It enables the real-time kernel feature by specifying it under the `ubuntu_advantage` section. Remember to replace `` with your valid Ubuntu Pro token. ```YAML #cloud-config ubuntu_advantage: token: enable: - realtime-kernel ``` -------------------------------- ### Install and Register MAAS Rack Controller (Package) Source: https://maas.io/docs/how-to-manage-controllers Installs the MAAS rack controller via apt and registers it with a MAAS instance. This method is for package-based installations to enable high availability. It requires the MAAS URL and a secret for successful registration. ```bash sudo apt install maas-rack-controller sudo maas-rack register --url $MAAS_URL --secret $SECRET ``` -------------------------------- ### MAAS Custom Storage Layout: Disk Device Configuration Example Source: https://maas.io/docs/about-lxd This JSON snippet demonstrates the configuration for a 'disk' device within a MAAS custom storage layout. It defines a physical disk, allowing specification of the partition table type ('gpt' or 'mbr'), whether it should be selected as the 'boot' disk, and optionally, a list of partitions to create with their size and filesystem type. This configuration is used within the 'layouts' section of the custom storage setup. ```JSON "sda": { "type": "disk", "ptable": "gpt", "boot": true, "partitions": [ { "name": "sda1", "fs": "vfat", "size": "100M", "bootable": true } ] } ``` -------------------------------- ### Verify Build Dependencies for MAAS Image Creation Source: https://maas.io/docs/how-to-build-custom-images This command checks if all necessary dependencies for building MAAS images are installed on the system. It should be run in the template directory to ensure the environment is ready for image creation. ```bash make check-deps ``` -------------------------------- ### Install Certificate with `acme.sh` and Update MAAS TLS Source: https://maas.io/docs/ensuring-security-in-maas Shows how to install a certificate issued by `acme.sh` into MAAS's certificate directory and then update MAAS TLS configuration using the `--reloadcmd` option. This ensures MAAS uses the newly installed certificate. ```bash $> sudo acme.sh --installcert -d maas.internal \ --certpath /var/snap/maas/certs/server.pem \ --keypath /var/snap/maas/certs/server-key.pem \ --capath /var/snap/maas/certs/cacerts.pem \ --reloadcmd "(echo y) | maas config-tls enable /var/snap/maas/certs/server-key.pem /var/snap/maas/certs/server.pem --port 5443" ``` -------------------------------- ### Restore a full MAAS system backup Source: https://maas.io/docs/how-to-back-up-maas This procedure details how to restore a complete MAAS system from a previously created database dump and snap snapshot. It requires stopping and removing the existing MAAS instance, restoring the database, importing and restoring the snap snapshot, and finally restarting services. ```bash sudo snap stop maas && sudo snap remove maas sudo -u postgres psql -f / postgres sudo snap import-snapshot / sudo snap restore sudo systemctl start postgresql.service sudo snap restart maas ``` -------------------------------- ### Install ISC DHCP Server on Ubuntu Source: https://maas.io/docs/maas-troubleshooting-guide This command sequence installs the ISC DHCP server package on an Ubuntu system. It first updates the package lists to ensure the latest information is available, then proceeds with the installation of `isc-dhcp-server`. This is a prerequisite for setting up an external DHCP server to manage IP assignments independently of MAAS. ```bash sudo apt update sudo apt install isc-dhcp-server ``` -------------------------------- ### Install HAProxy on Ubuntu Source: https://maas.io/docs/how-to-enhance-maas-security Commands to update the package lists and install the HAProxy load balancer on an Ubuntu system. This is the first step before configuring HAProxy for MAAS. ```bash sudo apt-get update sudo apt-get install haproxy ```