Create a VM image and publish it to a image gallery from a single file
_______________________________
< Desired state managed images! >
-------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
- Bootstrap packer and ansible from a single desired state
- Automated building of images and publishing
- Supports Windows and Ubuntu images
- Data as Config driven (DaC)
Developed with the following tool versions
- Ansible version 2.9.97
- Packer version 1.8.0
- Python version 3.10.0
After an image has been published to the compute gallery you can create an VMSS from it. Make sure that the following settings are used
- Add VMSS to the correct VNET/subnet
- Autoscaling settings must be set to "manual" if you want to use VMSS as a self-hosted DevOps agent
- Everything from the desired_state.yaml file
- This file is converted by
templater.py
to Hasicorp Packer HCL templates for IaC image provisioning + Ansible playbook for OS level Config-as-Code - CI pipeline runs everything in sequence
Manually
- Update
desired_settings.yaml
- Run templater.py (this will create 3 files;
scripts/pre-processor-img.sh
,build_config/playbook.yaml
&builds/azure-vmss.pkr.hcl
) - Execute
scripts/pre-processor-img.sh
with bash (this will create an image definition in the compute gallery specified indesired_settings.yaml
) - Run the
builds/azure-vmss.pkr.hcl
file with packer
From CI
- Create a pipeline from the ci/azure-pipelines.yaml file
- Change the
service_connection
variable value to an existing service connection - Update Update
desired_settings.yaml
- e voilà
- Create reference docs for desired_state.yaml
- Creating VMSS based self hosted Azure DevOps agents: https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/scale-set-agents?view=azure-devops