DIB7 is an automated pipeline for building and deploying virtual machine disk images across multiple cloud platforms using Ansible and diskimage-builder (DIB).
DIB7 streamlines the entire lifecycle of VM image creation and deployment:
- Build: Create base QCOW2 images using diskimage-builder
- Convert: Transform images to platform-specific formats (OVA)
- Deploy: Import and publish images to AWS, GCP, OpenStack and VMware vSphere
flowchart TB
DIB["diskimage-builder"] --> QCOW2["💽 qcow2"]
QCOW2 --> VMDK["📦 vmdk"]
VMDK --> OVF["📄 ovf"]
OVF --> OVA["📦 ova"]
QCOW2 --> GCS["🪣 GCS Bucket"]
GCS --> GCP_IMG["☁️ GCP Image"]
QCOW2 --> OPENSTACK_IMG["☁️ OpenStack Image"]
OVA --> S3["🪣 S3 Bucket"]
S3 --> AWS_IMG["☁️ AWS AMI"]
OVA --> VSPHERE_IMG["☁️ vSphere OVA"]
- AWS - AMI import via S3 and VM Import/Export
- GCP - Compute Engine images via Cloud Storage (GCS)
- OpenStack - Glance images via direct upload
- VMware vSphere - Content Library OVA deployment
- Ubuntu (16.04, 18.04, 20.04, 22.04, 23.04, 24.04)
- CentOS/RHEL (8.x, 9.x, 10)
- Fedora (37, 38, 39)
- Debian (10, 11, 12.x)
- Amazon Linux (2, 2023)
- Rocky Linux (9.x, 10)
- Oracle Linux (8.x-10.x)
- SUSE Linux Enterprise (11, 12, 15)
- Debian
- Ubuntu
- Fedora
- Red Hat Enterprise Linux (RHEL)
- CentOS
- openSUSE
- Gentoo
-
Python Environment
sudo apt update sudo apt install -y python3 python3-venv python3-pip git python3 -m venv ~/venvs/dib source ~/venvs/dib/bin/activate pip install diskimage-builder
-
Ansible Collections
ansible-galaxy collection install \ amazon.aws \ community.vmware \ google.cloud \ openstack.cloud
-
System Dependencies
sudo apt install -y qemu-utils kpartx debootstrap parted dosfstools gdisk squashfs-tools
-
Configure Vaults (see Vault Configuration)
-
Build Base Image
# Build all hosts in the inventory ansible-playbook playbooks/build-qcow2.yml # Build a specific host ansible-playbook playbooks/build-qcow2.yml -l ubuntu24044 # Build all hosts in a group ansible-playbook playbooks/build-qcow2.yml -l ubuntu
Omit
-lto run against every host inhosts.yml. Use-lonly when you want to limit the run to a specific host or inventory group. -
Deploy to Target Platform
AWS:
ansible-playbook playbooks/convert-qcow2-to-ova.yml -l <host-or-group> --ask-vault-pass ansible-playbook playbooks/import-ova-aws.yml -l <host-or-group> --ask-vault-pass
GCP:
ansible-playbook playbooks/import-qcow2-gcp.yml -l <host-or-group> --ask-vault-pass
OpenStack:
ansible-playbook playbooks/import-qcow2-openstack.yml -l <host-or-group> --ask-vault-pass
vSphere:
ansible-playbook playbooks/convert-qcow2-to-ova.yml -l <host-or-group> --ask-vault-pass ansible-playbook playbooks/import-ova-vsphere.yml -l <host-or-group> --ask-vault-pass
dib7/
├── ansible.cfg # Ansible configuration
├── bin/ # Utility scripts
│ ├── import-ova-vsphere.ps1 # PowerShell vSphere import script
│ ├── inspect-qcow2.sh # Script for examining and modifying virtual machines
│ └── *-vault.sh # Vault management scripts
├── doc/ # Documentation
├── elements/ # DIB elements for custom OS configurations
├── group_vars/ # Ansible group variables
├── hosts.yml # Inventory file
├── playbooks/ # Ansible playbooks
├── templates/ # Jinja2 templates
└── vaults/ # Encrypted credentials| Playbook | Purpose | Dependencies |
|---|---|---|
build-qcow2.yml |
Build base QCOW2 image | diskimage-builder |
convert-qcow2-to-ova.yml |
Convert QCOW2 to OVA | qemu-img, ovftool |
import-ova-aws.yml |
Upload OVA to S3, import to AWS AMI | AWS CLI, S3, VM Import |
import-ova-vsphere.yml |
Import OVA to vSphere | pwsh, PowerCLI |
import-qcow2-gcp.yml |
Import QCOW2 to GCP | gcloud, gsutil |
import-qcow2-openstack.yml |
Import QCOW2 to OpenStack | OpenStack CLI |
DIB7 uses Ansible Vault for secure credential management. Create encrypted vault files:
aws_region: "my-region"
s3_bucket: "my-bucket"
vmimport_role_name: "vmimport-role"gcp_project: "my-project"
gcs_bucket: "my-image-bucket"
gcs_location: "my-location"
service_account_key: |
{
"type": "service_account",
...
}openstack_auth:
auth_url: "https://keystone.example.com:5000/v3"
username: "my-username"
password: "my-password"
project_name: "my-project"
user_domain_name: "Default"
project_domain_name: "Default"vcenter_hostname: "vcenter.example.com"
vcenter_username: "administrator@vsphere.local"
vcenter_password: "secure-password"
vsphere_content_library: "my-content-library"DIB7 includes custom diskimage-builder elements for supported operating systems:
elements/custom-centos10stream/- CentOS Stream 10 customizationselements/custom-debian/- Debian customizationselements/custom-fedora/- Fedora customizationselements/custom-ubuntu/- Ubuntu customizations
Each element directory can contain standard diskimage-builder phase subdirectories. Common phases include:
pre-install.d/- Pre-installation setupinstall.d/- Package installationpost-install.d/- Post-installation configurationfinalise.d/- Image finalization
See doc/phases.md for the complete ordered list of DIB phases and whether each phase runs inside or outside the chroot.
image_arch: CPU architecture (default:amd64)image_name: Image base name (default:{{ inventory_hostname }}-base)image_size: Image size in GB (default:35)image_type: Image format (default:qcow2)qcow2_file,vmdk_file,ovf_file,ova_file,mf_file: Derived output filenamesdpkg_opts,debian_frontend,needrestart_mode: Debian/Ubuntu packaging options
group_vars/centos10stream/main.ymlgroup_vars/debian/main.ymlgroup_vars/fedora/main.ymlgroup_vars/ubuntu/main.yml
# Test basic DIB functionality
export DIB_RELEASE=noble
disk-image-create ubuntu vm -o test-ubuntu
# Inspect QCOW2 contents
./bin/inspect-qcow2.sh test-ubuntu.qcow2- Create custom element in
elements/ - Add group variables in
group_vars/ - Update documentation in
doc/
-
DIB Build Failures
- Ensure all system dependencies are installed
- Check available disk space (>50GB recommended)
- Verify Python virtual environment is activated
-
Cloud Import Failures
- Validate vault credentials
- Check cloud provider quotas and permissions
- Review cloud provider import logs
-
Ansible Collection Issues
- Update collections:
ansible-galaxy collection install --force <collection> - Check collection compatibility with Ansible version
- Update collections:
Run playbooks with verbose output:
ansible-playbook playbooks/build-qcow2.yml -vvv- Fork the repository
- Create a feature branch
- Make changes with proper documentation
- Test thoroughly across all supported platforms
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
- Check existing documentation in
doc/ - Review Ansible playbook logs
- Validate cloud provider service status
- Create an issue with detailed error logs and configuration