Skip to main content

OSImager

Multi-platform OS image builder using HashiCorp Packer. Build virtual machine images for any operating system -- from RHEL 2.1 (2002) to the latest RHEL 9, CentOS, Debian, Ubuntu, SLES, and Windows Server -- on any supported hypervisor, from a single command.

Quick Install

pip install osimager

Prerequisites

  • Python 3.8+
  • HashiCorp Packer -- https://developer.hashicorp.com/packer/install
  • Ansible -- pip install ansible
  • A hypervisor -- VirtualBox is free and the easiest to start with
  • Packer plugins -- At minimum, the Ansible provisioner and your target platform plugin:
    packer plugins install github.com/hashicorp/ansible
    packer plugins install github.com/hashicorp/virtualbox
    
  • mkisofs (recommended) -- brew install cdrtools (macOS) or apt install genisoimage (Linux)

Getting Started

After installing, run mkosimage with no arguments -- it will tell you exactly what to set up:

$ mkosimage
Usage: mkosimage [OPTIONS] PLATFORM/LOCATION/SPEC [NAME] [IP]

No locations configured.
  Create a location file in ~/.config/osimager/locations/
  ...

1. Create a location

A location defines your build environment -- network settings, DNS, and where ISOs/VMs live.

Copy the quickstart template and edit it:

cp "$(python3 -c "import osimager, os; print(os.path.join(os.path.dirname(osimager.__file__), 'data', 'examples', 'quickstart-location.toml'))")" \
   ~/.config/osimager/locations/local.toml

Edit ~/.config/osimager/locations/local.toml -- set your network, gateway, DNS, and paths:

platforms = ["virtualbox"]

[defs]
domain = "home.local"
gateway = "192.168.1.1"
cidr = "192.168.1.0/24"
vms_path = "/vms"

[defs.dns]
servers = ["192.168.1.1"]

[defs.ntp]
servers = ["pool.ntp.org"]

Locations support both TOML and JSON formats. If both lab.toml and lab.json exist, JSON takes priority.

2. Set up credentials

OS image builds need credentials for SSH/WinRM access and root passwords. OSImager supports two credential sources:

Option A: Local secrets file (simplest)

mkosimage --set credential_source=config

Create ~/.config/osimager/secrets:

images/linux username=root password=YourPassword
images/windows username=Administrator password=YourPassword

Option B: HashiCorp Vault

mkosimage --set vault_addr=http://your-vault:8200
mkosimage --set vault_token=your-token

See the example files shipped with the package for the full secret path reference (including platform credentials for vSphere and Proxmox).

3. Build

# List all available OS specs
mkosimage --list

# Dry run -- generates the Packer config without executing
mkosimage -n virtualbox/local/alma-9.5-x86_64

# Build
mkosimage virtualbox/local/alma-9.5-x86_64

# Build the newest version a spec provides
mkosimage virtualbox/local/alma-latest-x86_64

How It Works

mkosimage <platform>/<location>/<spec>
  • Platform = your hypervisor (ships with package)
  • Location = your environment: network, DNS, storage paths (you create this)
  • Spec = the OS to build (ships with package)

OSImager merges these three configs together, performs template substitution, generates the appropriate answer file (kickstart, preseed, autoyast, or autounattend), produces a Packer build JSON, and executes it.

Features

  • 500+ OS specs spanning 20+ distributions across decades of releases (see Supported OS for the generated catalog)
  • 11 platforms: VirtualBox, VMware, vSphere, Proxmox, QEMU/KVM, Hyper-V, XenServer, Azure, GCP, AWS
  • Automated installation: Kickstart (RHEL/CentOS/Alma/Rocky/OEL), preseed (Debian), cloud-init (Ubuntu 20.04+), AutoYaST (SLES), Autounattend (Windows)
  • Ansible provisioning: Post-install configuration via Ansible playbooks
  • Hierarchical configuration: Platform/location/spec system with deep inheritance and per-version/per-platform overrides
  • Flexible credentials: Local secrets file or optional HashiCorp Vault integration
  • TOML or JSON locations: User-editable location configs in either format

Supported Operating Systems

Distribution Versions Install Method
RHEL 2.1, 3.0, 4.8, 5.x, 6.x, 7.x, 8.x, 9.x, 10.x Kickstart
CentOS 5.0-5.10, 6.0-6.10, 7.0-7.9, 8.0-8.5 Kickstart
AlmaLinux 8.3-8.10, 9.0-9.8, 10.0-10.2 Kickstart
Rocky Linux 8.3-8.10, 9.0-9.8 Kickstart
Oracle Linux 5.0-5.10, 6.0-6.10, 7.0-7.9, 8.0-8.10, 9.0-9.8, 10.0-10.2 Kickstart
Debian 8-13 Preseed / Cloud-Init
Ubuntu 18.04, 20.04, 22.04, 24.04, 26.04 Cloud-Init
SLES 12.1-12.5, 15.0-15.7, 16.0 AutoYaST
VMware ESXi 5.5U3, 6.0U2, 6.5, 7.0U3n, 8.0U2 Kickstart
Windows Server 2016, 2019, 2022, 2025 Autounattend

Supported Platforms

Platform Type Plugin
VirtualBox Local github.com/hashicorp/virtualbox
VMware Workstation/Fusion Local github.com/hashicorp/vmware
vSphere Enterprise github.com/hashicorp/vsphere
Proxmox Enterprise github.com/hashicorp/proxmox
QEMU/KVM Local github.com/hashicorp/qemu
Hyper-V Local Built-in
XenServer Local github.com/ddelnano/xenserver
Azure Cloud github.com/hashicorp/azure
GCP Cloud github.com/hashicorp/googlecompute
AWS Cloud github.com/hashicorp/amazon

Configuration

All user configuration lives in ~/.config/osimager/:

File Purpose
locations/*.toml or *.json Build environments (you create these)
secrets Credentials when using credential_source=config
config.json Persistent settings (managed via --set)

Settings are configured with --set:

mkosimage --set credential_source=config    # use local secrets file
mkosimage --set vault_addr=http://vault:8200 # vault server address
mkosimage --set local_only=True              # only use local ISOs
mkosimage --set packer_cache_dir=/var/cache  # ISO download cache

CLI Reference

mkosimage [OPTIONS] PLATFORM/LOCATION/SPEC [NAME] [IP]

Listing (no target needed):
  -l, --list          Every spec OSImager knows about; (*) = ISO present locally
  -a, --avail         Specs you can build now, with local ISO path or download URL
  --local             Like -a, but only specs whose ISO is already present
  --latest            Each <dist>-latest-<arch> target and the spec it resolves to;
                      with -a/--local, narrows those lists to the latest of each dist
  --arch ARCH         Limit any listing to one architecture
  --check-urls        HEAD-check every download URL in every spec

Building:
  --local             Build only from an ISO already present; never download
  -n, --dry           Generate everything and print the packer command, don't run it
  -f                  Replace an existing VM/output of the same name (packer -force)
  -k                  On failure keep the VM (packer -on-error=abort) and temp files
  --skip              Skip post-install configuration (Ansible)
  -D K=V[,K=V]        Override defs for this build
  -F FQDN             Use this FQDN instead of NAME.<location domain>

Inspecting:
  -x, --defs          Print the resolved defs and exit
  -u, --dump          Print the Packer build JSON and exit
  -v / -d             Verbose / debug output (-d also runs packer -debug)
  -L, -N FILE         Packer log on, written to FILE

Settings:
  --set KEY=VALUE     Change a setting and save it to ~/.config/osimager/config.json
  --show-config       Print the current settings

Every option, with exact behavior, is in the CLI reference.

Documentation

For detailed documentation on location setup, platform configuration, spec format, template syntax, and the credential system, see the OSImager Documentation.

License

MIT License -- see LICENSE for details.

Metadata

Release files for osimager 1.10.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for osimager 1.10.1
File Size Uploaded Provenance
osimager-1.10.1.tar.gz 106.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for osimager 1.10.1
File Interpreter ABI Platform
osimager-1.10.1-py3-none-any.whl Python 3 none any Details

Total release size: 267.7 kB

Release files / osimager-1.10.1.tar.gz

Download URL osimager-1.10.1.tar.gz
Size 106.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c5fb600024cf5684eae551451c977f1661bf1141832991a1ef753da6c8304f96
BLAKE2b-256 checksum
How to use checksums
704349ebbf8c9ebd06f93438ae2bc4334bad739dcfb4743bb6b658ca6cd48fef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / osimager-1.10.1-py3-none-any.whl

Download URL osimager-1.10.1-py3-none-any.whl
Size 160.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
008a44d59c5ad7c03531e886c242fb5ea7c4c24173d53a8a1e20cb031252d84d
BLAKE2b-256 checksum
How to use checksums
2fccddce98fb9a13bd48d168e18c5f33f92f24e906f808e757281cb676cb7555
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for osimager 1.10.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page