Build and manage a local Red Hat Enterprise Linux (RHEL) lab environment for testing and development.
This project uses Packer, Vagrant, and VirtualBox to automate the creation and management of RHEL virtual machines for a repeatable, local lab setup.
Optional provisioning with Ansible is supported but not required — the main focus is building and running the lab environment itself.
The following software must be installed on your local machine before building and running the lab:
- Packer — used to build RHEL base boxes for Vagrant
- Vagrant — used to create and manage the lab VMs
- VirtualBox — virtualization provider for the lab environment
(Optional) Ansible — used for provisioning and configuration management
You must have a Red Hat Subscription to download the RHEL DVD ISO, create an activation key, and access repositories for package installs or updates.
If you don’t already have an account, create one here and accept the terms and conditions of the Red Hat Developer Program, which provides no-cost subscriptions for development use only.
git clone https://github.com/notjustanyjoe/labctl.git
cd labctl- Download the RHEL DVD ISO and copy the checksum for your desired version (8 or 9) from
https://access.redhat.com/downloads/content/rhelClick on Show details and then copy the SHA-256 Checksum.
- Place the ISO under
packer/iso/:mkdir -p packer/iso mv ~/Downloads/rhel-9.*-x86_64-dvd.iso packer/iso/
- Copy a variable file template and edit it:
cd packer cp rhel9.pkrvars.hcl.example rhel9.pkrvars.hcl # edit iso_path and iso_checksum vim rhel9.pkrvars.hcl cd ..
Generate a global ~/.vagrant.d/Vagrantfile and install required plugins.
You’ll be prompted for your Organization ID and Activation Key.
If you don’t have these yet:
- Visit https://console.redhat.com/insights/connector/activation-keys
- Log in with your Red Hat Developer account.
- Create a key → choose Role: Workstation, SLA: Self-Support, Usage: Development/Test.
- Note your Organization ID and Activation Key Name.
Now Run:
./scripts/setup-vagrant-registration.shNOTE: This is only needed the first time you run this project or if your Organization ID/Activation Key changes.
cd packer
packer fmt .
packer init .
packer validate -var-file=rhel9.pkrvars.hcl rhel.pkr.hcl
packer build -var-file=rhel9.pkrvars.hcl rhel.pkr.hcl
cd ..The output .box file is stored in packer/builds/.
cd vagrant
vagrant upThis will:
- Register the VMs with RHSM (via
vagrant-registration) - Sync
/etc/hostsentries between machines (viavagrant-hosts)
Default VMs:
| Hostname | IP Address | Purpose |
|---|---|---|
| ctl | 10.10.10.10 | Control |
| node1 | 10.10.10.11 | Managed |
SSH in:
vagrant ssh ctlFrom your host:
ansible-playbook -i ansible/inventories/vagrant.ini ansible/playbooks/common.ymlcd vagrant
vagrant destroy -fThis unregisters all VMs from RHSM and removes them cleanly.
labctl/
├── ansible/
│ ├── inventories/
│ │ └── vagrant.ini
│ └── playbooks/
│ └── common.yml
├── packer/
│ ├── builds/
│ ├── http/
│ │ ├── ks.cfg
│ │ └── (future ks10.cfg)
│ ├── iso/
│ ├── scripts/
│ │ ├── prepare.sh
│ │ └── cleanup.sh
│ ├── rhel.pkr.hcl
│ ├── rhel8.pkrvars.hcl.example
│ ├── rhel9.pkrvars.hcl.example
│ └── rhel10.pkrvars.hcl.example
├── vagrant/
│ └── Vagrantfile
├── scripts/
│ └── setup-vagrant-registration.sh
├── vagrant-plugins.list
└── README.md
- The default Packer and Vagrant settings use EFI, 4 GB RAM, and 2 vCPUs.
- Boxes are automatically registered/unregistered via the
vagrant-registrationplugin. - This project is intended for development and testing only (self-support SLA).
- Tested and verified working with: RHEL 8 and RHEL 9. (RHEL 10 support in progress)
© 2025 labctl project