No description
Find a file
2025-10-16 13:35:43 +02:00
swagspace_cloud_init updated GraphQL for Netbox 4.4 2025-10-16 13:35:43 +02:00
.gitignore added ssh_keys directory to gitignore 2025-07-21 14:24:51 +02:00
poetry.lock added code 2025-07-13 14:23:13 +02:00
pyproject.toml added hostname setting 2025-07-21 15:03:58 +02:00
README.md added dependencies 2025-07-13 14:46:35 +02:00

Swagspace Cloud Init

This script builds VMs for the Swagspace infrastructure.

It takes gets the name of a VM, collect further data (CPUs, memory, IP addresses) from NetBox via GraphQL and creates a VM using virt-install and cloud-init.

It asks for a password for the user.

usage: build-vm [-h] [--instance INSTANCE] [--config CONFIG] [--url URL] [--token TOKEN] [--graphql-url GRAPHQL_URL] [--base_image BASE_IMAGE] [--image_dir IMAGE_DIR] [--network-bridge NETWORK_BRIDGE] [--dry-run] [--overwrite] [--username USERNAME] vm_name

positional arguments:
  vm_name               The name of the VM to build

options:
  -h, --help            show this help message and exit
  --instance INSTANCE   the name of the instance to use
  --config CONFIG       the config file to use
  --url URL             the URL of the NetBox API endpoint
  --token TOKEN         the token for the NetBox REST API
  --graphql-url GRAPHQL_URL
                        The URL for the GraphQL endpoint
  --base_image BASE_IMAGE
                        The path to the cloud-init image to use. Default: 'debian13-cloud-init.qcow2'
  --image_dir IMAGE_DIR
                        The location where the image should be stored.
  --network-bridge NETWORK_BRIDGE
                        Name of the bridge the VM should be attached to
  --dry-run             Query NetBox, build the cloud-init files but don't actually build the image
  --overwrite           overwrite the image, if it exists
  --username USERNAME   name of the user, Default: jo

Dependencies

  • virt-install
  • qemu-img
  • mkpasswd (whois package)