Skip to content

Comments

Add MAAS dynamic inventory script#1337

Merged
dholt merged 4 commits intoNVIDIA:masterfrom
dholt:feature/maas-dynamic-inventory
Feb 20, 2026
Merged

Add MAAS dynamic inventory script#1337
dholt merged 4 commits intoNVIDIA:masterfrom
dholt:feature/maas-dynamic-inventory

Conversation

@dholt
Copy link
Contributor

@dholt dholt commented Feb 19, 2026

Summary

  • Adds a Python script (scripts/maas_inventory.py) that queries the MAAS REST API to auto-discover deployed machines and map MAAS tags to Ansible groups
  • Tag a VM slurm-master in MAAS and it appears in the [slurm-master] group — no manual inventory editing needed
  • Config follows existing DeepOps convention: example in config.example/maas-inventory.yml, private config in config/maas-inventory.yml (gitignored)
  • Zero external dependencies (Python stdlib only)
  • Documentation added to docs/pxe/maas.md

Features

  • OAuth1 authentication against MAAS REST API v2.0
  • Maps MAAS tags directly to Ansible groups
  • Auto-creates DeepOps parent group hierarchy (slurm-cluster, k8s-cluster, etc.)
  • Exposes MAAS metadata as host variables (OS, distro, CPUs, memory, architecture, zone, pool)
  • Optional SSH bastion/ProxyJump for private networks
  • Optional network prefix filtering for multi-homed machines
  • Config via YAML file or environment variables

Test plan

  • Verified --list returns correct JSON inventory from live MAAS server
  • Verified ansible all -m ping succeeds through dynamic inventory
  • Verified ansible-playbook --check ngc-ready-server.yml completes (63 ok, 0 failed)
  • Tested tag-based group assignment (slurm-master on vm01, slurm-node on vm02+vm03)
  • Tested switching from Slurm to K8s tags (kube-master+etcd on vm01, kube-node on vm02+vm03) — slurm groups correctly emptied, k8s groups populated

🤖 Generated with Claude Code

Adds a Python script that queries the MAAS REST API to auto-discover
deployed machines and map MAAS tags to Ansible groups. Tag a VM with
slurm-master in MAAS and it appears in the [slurm-master] group.

- scripts/maas_inventory.py: inventory script (Python stdlib only)
- config.example/maas-inventory.yml: example configuration
- docs/pxe/maas.md: added Dynamic Inventory section

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Douglas Holt <dholt@nvidia.com>
@dholt dholt force-pushed the feature/maas-dynamic-inventory branch from 206657e to a9e4b02 Compare February 19, 2026 00:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a Python-based dynamic inventory script for MAAS (Metal as a Service) integration with DeepOps. The script queries the MAAS REST API to auto-discover deployed machines and maps MAAS tags to Ansible groups, eliminating the need to manually edit inventory files when machines are provisioned or reassigned.

Changes:

  • New dynamic inventory script with OAuth1 authentication and zero external dependencies
  • Comprehensive documentation for MAAS integration including setup, configuration, and usage examples
  • Example configuration file following DeepOps conventions

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
scripts/maas_inventory.py Dynamic inventory script that queries MAAS API and generates Ansible inventory based on machine tags
docs/MAAS.md Documentation for MAAS dynamic inventory including prerequisites, setup instructions, tag-based group assignment, configuration reference, and host variables
config.example/maas-inventory.yml Example configuration file with MAAS API settings, SSH options, and network preferences

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

… CodeQL alert

- Remove hardcoded StrictHostKeyChecking=no from SSH args (security)
- Return empty dict for --host since _meta provides all hostvars (perf)
- Remove URL from error message to avoid CodeQL sensitive data alert

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Douglas Holt <dholt@nvidia.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

dholt and others added 2 commits February 19, 2026 08:10
etcd is a separate group in the static inventory, not a child of
kube-master. Users should tag etcd nodes explicitly rather than having
all kube-master nodes implicitly join etcd.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Douglas Holt <dholt@nvidia.com>
…C entry

- Update pre-requisites from Ubuntu 18.04 to 22.04/24.04
- Note MAAS 2.8 is original version, current is 3.x
- Update maas_repo PPA from 2.8 to 3.5
- Add Dynamic Inventory section to table of contents

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Douglas Holt <dholt@nvidia.com>
@dholt dholt requested a review from michael-balint February 19, 2026 20:56
@dholt dholt merged commit d462d56 into NVIDIA:master Feb 20, 2026
2 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants