Automated, repeatable deployment of cloud-init-enabled Linux VMs on vSphere, using PowerShell/PowerCLI and custom seed ISO generation.
/etc/hosts
, and moreinfra/
directory to the Template VM. sudo dnf install open-vm-tools
sudo dnf install cloud-init cloud-utils-growpart
π‘ See infra/req-pkg-cloudinit.txt
for the package list.
cd infra/
sudo ./prevent-cloud-init.sh
This will:
/etc/cloud/cloud-init.disabled
(prevents cloud-init auto-execution)/etc/cloud/cloud.cfg
with the optimized configuration/etc/cloud/cloud.cfg.d/99-template-maint.cfg
Clean up previous cloud-init artifacts, if any.
You can safely run cloud-init clean
to remove any old instance state here on the Template VM.
mkisofs.exe
is available (from cdrtfe) and placed according to the scriptβs $mkisofs
path. See Notes & Recommendations for alternatives.params/vm-settings_example.yaml
β params/vm-settings_<VMNAME>.yaml
(any name you prefer) and edit for your VMβs resources, network, and cloud-init needs.
templates/original/*_template.yaml
to templates/
, and update for your site:
user-data_template.yaml
meta-data_template.yaml
network-config_template.yaml
infra/cloud.cfg
or infra/99-template-maint.cfg
only if you need to customize template/clone-level cloud-init behavior.Create spool
folder on the repository root to save logs and seed ISO and its source files.
Open a PowerShell terminal in the repository root and run:
.\cloudinit-linux-vm-deploy.ps1 -Phase 1,2,3 -Config .\params\vm-settings_<VMNAME>.yaml
-Phase 1
, -Phase 2
, -Phase 3
) if needed.spool/<VMNAME>/
directory on the admin host and /var/log/cloud-init*.log
files in the guest if troubleshooting is needed./
βββ cloudinit-linux-vm-deploy.ps1
βββ params/
β βββ vm-settings_example.yaml
β βββ <your copy of above>
βββ templates/
β βββ <your copies of *_template.yaml>
β βββ original/
β βββ user-data_template.yaml
β βββ meta-data_template.yaml
β βββ network-config_template.yaml
βββ scripts/
β βββ init-vm-cloudinit.sh
βββ infra/
β βββ cloud.cfg
β βββ 99-template-maint.cfg
β βββ enable-cloudinit-service.sh
β βββ prevent-cloud-init.sh
β βββ req-pkg-cloudinit.txt
β βββ req-pkg-cloudinit-full.txt
βββ spool/
βββ <VMNAME>/
/etc/hosts Customization:
The kit uses write_files
in cloud-init user-data to fully control /etc/hosts
for each VM.
manage_etc_hosts: false
is automatically set during clone-init to avoid conflicts.
Template and Clone Safety:
The Template VM is fully protected from cloud-init (cloud-init.disabled
and config files).
Clones automatically remove this protection and enable cloud-init on first boot.
cloudinit-linux-vm-deploy.ps1
and vm-settings*.yaml
: CRLF (Windows)Multi-NIC/Advanced:
Edit cloud.cfg
and templates as needed for advanced configurations.
PowerCLI and powershell-yaml modules are required on the admin host.
mkisofs.exe must be available as specified in the script.
Alternatives such as genisoimage
(e.g., under WSL2 on Windows Server 2022/Windows 11) are supported if you adjust $mkisofs
and related script variables accordingly.
disk_format:
and/or the disks:
parameter (in whole or in part) from your parameter YAML file if you do not wish to change disk provisioning type or disk sizes for some or all disks, as already defined in the template VM./etc/cloud/cloud-init.disabled
was removed in the clone.spool/<your_vm>/
directory.spool/<VMNAME>/deploy-*.log
and guest /var/log/cloud-init*.log
for details.This project is licensed under the MIT License - see the LICENSE file for details.