Change from cloud init to ignition

This commit is contained in:
2026-06-10 19:26:28 +02:00
parent f2c6da73df
commit 71c67cb81a
4 changed files with 23 additions and 8 deletions
+4 -4
View File
@@ -5,7 +5,7 @@ This project provides an Ansible-based framework to automatically provision virt
## 🚀 Features
- **Automated Host Setup**: Installs and configures `libvirt`, `qemu-kvm`, and `libguestfs-tools`.
- **Cloud-init Support**: Generates and injects Cloud-init user-data for all supported OSs via a NoCloud ISO.
- **Ignition Support**: Generates and injects Ignition configuration for all supported OSs via the `fw_cfg` QEMU feature.
- **Custom User Provisioning**: Automatically creates a default user with a hashed password and injects your SSH public key.
- **Modular Design**: Uses Ansible roles for host preparation, configuration generation, and VM provisioning.
@@ -20,7 +20,7 @@ ansible-kvm-vms/
│ └── vms.yml # List of VMs to create with CPU, RAM, and Disk specs
├── roles/
│ ├── kvm_host_setup/ # Installs virtualization dependencies on the host
│ ├── os_config/ # Generates Ignition/Cloud-init config files
│ ├── os_config/ # Generates Ignition configuration files
│ └── vm_provision/ # Downloads images and creates VMs via virt-install
└── playbooks/
└── create_vms.yml # Main orchestration playbook
@@ -65,8 +65,8 @@ Edit `vars/vms.yml` to add or modify the VMs you wish to deploy. You can specify
## 🔍 How it Works
Since immutable OSs do not use traditional installers, this setup uses a "seed" approach:
1. **Config Generation**: The `os_config` role creates a YAML Cloud-init user-data file based on your variables.
2. **Deployment**: `virt-install` is used to create the VM with UEFI boot. The `--cloud-init` flag is used to attach the configuration as a NoCloud ISO, which the immutable OSs (CoreOS, Flatcar, MicroOS) process at first boot.
1. **Config Generation**: The `os_config` role creates a JSON Ignition configuration file based on your variables.
2. **Deployment**: `virt-install` is used to create the VM with UEFI boot. The `--sysinfo` flag is used to provide the Ignition config via the `fw_cfg` device, which the immutable OSs (CoreOS, Flatcar, MicroOS) process at first boot.
## 🌐 Accessing your VMs
@@ -1,6 +1,6 @@
---
- name: Generate Cloud-init config
- name: Generate Ignition config
template:
src: user-data.yaml.j2
dest: "/tmp/{{ vm_name }}_user-data"
src: ignition.json.j2
dest: "/tmp/{{ vm_name }}.ign"
@@ -0,0 +1,15 @@
{
"ignition": {
"version": "3.3.0"
},
"passwd": {
"users": [
{
"name": "{{ vm_user }}",
"sshAuthorizedKeys": [
"{{ lookup('file', vm_ssh_public_key | replace('~', lookup('env', 'HOME'))) }}"
]
}
]
}
}
@@ -54,7 +54,7 @@
--graphics none \
--noautoconsole \
--boot uefi \
--cloud-init user-data=/tmp/{{ vm_name }}_user-data
--sysinfo type=fwcfg,entry0.name="opt/com.coreos/config",entry0.file="/tmp/{{ vm_name }}.ign"
args:
creates: "/etc/libvirt/qemu/{{ vm_name }}.xml"
become: yes