The new sample containing tasks to create and manage Azure DevTest Lab is available here:
https://github.com/Azure-Samples/ansible-playbooks/blob/master/devtestlab-create.yml
This sample will:
- create resource group
- create DevTest Lab
- create sample DevTest Lab policy
- create sample DevTest Lab schedule
- create sample DevTest Lab Virtual Network
- create sample DevTest Lab artifact source
- create instance of DTL Virtual Machine
- list all artifact sources
- get artifacts source facts
- list ARM Template facts
- get ARM Template facts
- create instance of DevTest Lab Environment
- create instance of DevTest Lab Image
- delete instance of Lab
Running the sample
Variables
1 2 3 4 5 6 7 8 |
|
Following variables can be set in vars section of the playbook:
Variable Name | Description | Notes |
---|---|---|
resource_group | resource group where resources will be created | by default it’s using resource_group_name parameter passed when running the playbook |
location | location where resources should be created | |
lab_name | name of the lab instance | |
vn_name | lab virtual network name | |
vm_name | name of the vm instance | |
artifacts_name | lab artifacts name | |
github_token | GitHub token to access artifacts sources | by default playbook will attempt to get it from GITHUB_ACCESS_TOKEN environment variable |
Create Resource Group
This simple task creates a resource group if doesn’t exist yet.
1 2 3 4 |
|
Creating DevTest Lab
This task creates an instance of DevTest Lab.
1 2 3 4 5 6 7 8 |
|
DevTest Lab Policies
This task shows how to set up DevTest Lab policy settings.
Following values can be set:
Value | Description |
---|---|
user_owned_lab_vm_count | count of VMs that can be owned by an user |
user_owned_lab_premium_vm_count | count of premium VMs that can be owned by an user |
lab_vm_count | maximum lab VM count |
lab_premium_vm_count | maximum lab premium VM count |
lab_vm_size | allowed lab VMs size(s) |
gallery_image | allowed gallery image(s) |
user_owned_lab_vm_count_in_subnet | maximum number of user’s VMs in a subnet |
lab_target_cost | target cost of the lab |
1 2 3 4 5 6 7 8 |
|
DevTest Lab Schedules
Sample task setting DevTest Lab VM schedule.
Currently allowed are: |Name|Description| |—-|———–| |lab_vms_startup|Lab VMs startup time| |lab_vms_shutdown|Lab VMs shutdown time|
Time and time zone id must be specified.
1 2 3 4 5 6 7 8 |
|
DevTest Lab Virtual Network
This task creates default DevTest Lab virtual network.
1 2 3 4 5 6 7 8 |
|
DevTest Lab Artifact Source
This task shows how to create DevTest Lab artifacts source. DevTest Lab artifacts source is properly structured GitHub repository that contains artifact definition and ARM templates. Please note that every lab comes with predefined public artifacts source.
1 2 3 4 5 6 7 8 9 |
|
DevTest Lab Virtual Machine
This task shows how to create DevTest Labs virtual machine.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
Listing All Artifact Sources and Artifacts
This task lists all artifacts sources in the lab. Please use it to see default and custom artifacts sources.
1 2 3 4 5 6 7 |
|
Following task lists all the artifact in public repo which is predefined artifact source.
1 2 3 4 5 6 7 8 |
|
Getting Information on ARM Templates in Artifact Source
This task lists all the ARM templates in public environment repo that is predefined repo with templates.
1 2 3 4 5 6 7 8 |
|
And following task retrieves details of a specific ARM template from the repository:
1 2 3 4 5 6 7 8 9 |
|
Creating DevTest Lab Environment
Finally following task creates DevTest Lab environment. As you see it refers one of the templates from public environment repo.
1 2 3 4 5 6 7 8 9 |
|
Creating DevTest Lab Image
This is also a very useful task. It creates DevTest Lab image from existing DevTest Lab Virtual Machine. It can be later used to created new DevTest Lab virtual machines.
1 2 3 4 5 6 7 |
|
Deleting the Lab
Final task deletes entire lab.
1 2 3 4 5 6 7 8 9 10 |
|