Sample Ansible Playbook to provision VM on HyperV
This is heavily inspired by glenndehaan's original code to provision a vm on HyperV.
The code has been modified to provision VMs by:
The configuration is stored as an environment yaml file, such as vars/sit.yml
. This is meant to allow the user to define the environments such as DEV/UAT/SIT and its associated network information for each vm.
There is a sample create_vm.yml
playbook:
wait_for
WinRM is up before exitingThe playbook build_golden.yml
is use to install the necessary software using roles. After building the image, you can then use the vhd in your environment yaml file.
prov_web_db.yml
is to provision the sample App_Data
and restore a database from a backup from templates. The roles to install the IIS and MS-SQL have been disabled by default.
Use delete_vm.yml
to delete the vms and clean out the disk.
You can change enviornment by either editing the var/
yaml files or using -e
option in the command line.
Ansible Tower can also be used by using a survey form.
There is a bin/run.ps1
sample script that calls Ansible Tower API to launch the Job Teamplate and monitor the job till it exits.
The various roles and PowerShell scripts are adopted from: