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.
1234
-name:Create a resource groupazure_rm_resourcegroup:name:"{{resource_group}}"location:"{{location}}"
Creating DevTest Lab
This task creates an instance of DevTest Lab.
12345678
-name:Create instance of Labazure_rm_devtestlab:resource_group:"{{resource_group}}"name:"{{lab_name}}"location:"{{location}}"storage_type:standardpremium_data_disks:noregister:output_lab
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
12345678
-name:Create instance of DevTest Lab Policyazure_rm_devtestlabpolicy:resource_group:"{{resource_group}}"lab_name:"{{lab_name}}"policy_set_name:myDtlPolicySetname:myDtlPolicyfact_name:user_owned_lab_vm_countthreshold:5
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.
123456789
-name:Create instance of DevTest Labs artifacts sourceazure_rm_devtestlabartifactsource:resource_group:"{{resource_group}}"lab_name:"{{lab_name}}"name:"{{artifacts_name}}"uri:https://github.com/Azure/azure_preview_modules.gitsource_type:githubfolder_path:/taskssecurity_token:"{{github_token}}"
DevTest Lab Virtual Machine
This task shows how to create DevTest Labs virtual machine.
12345678910111213141516171819202122232425
-name:Create instance of DTL Virtual Machineazure_rm_devtestlabvirtualmachine:resource_group:"{{resource_group}}"lab_name:"{{lab_name}}"name:"{{vm_name}}"notes:Virtual machine notes, just something....os_type:linuxvm_size:Standard_A2_v2user_name:dtladminpassword:ZSasfovobocu$$21!lab_subnet:virtual_network_name:"{{vn_name}}"name:"{{vn_name}}Subnet"disallow_public_ip_address:noimage:offer:UbuntuServerpublisher:Canonicalsku:16.04-LTSos_type:Linuxversion:latestartifacts:-source_name:"{{artifacts_name}}"source_path:"/Artifacts/linux-install-mongodb"allow_claim:noexpiration_date:"2029-02-22T01:49:12.117974Z"
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.
1234567
-name:List all artifact sourcesazure_rm_devtestlabartifactsource_facts:resource_group:"{{resource_group}}"lab_name:"{{lab_name}}"register:output-debug:var:output
Following task lists all the artifact in public repo which is predefined artifact source.
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.
12345678
-name:List ARM Template factsazure_rm_devtestlabarmtemplate_facts:resource_group:"{{resource_group}}"lab_name:"{{lab_name}}"artifact_source_name:"publicenvironmentrepo"register:output-debug:var:output
And following task retrieves details of a specific ARM template from the repository:
123456789
-name:Get ARM Template factsazure_rm_devtestlabarmtemplate_facts:resource_group:"{{resource_group}}"lab_name:"{{lab_name}}"artifact_source_name:"publicenvironmentrepo"name:ServiceFabric-LabClusterregister:output-debug:var:output
Creating DevTest Lab Environment
Finally following task creates DevTest Lab environment. As you see it refers one of the templates from public environment repo.
123456789
-name:Create instance of DevTest Lab Environmentazure_rm_devtestlabenvironment:resource_group:"{{resource_group}}"lab_name:"{{lab_name}}"user_name:"@me"name:myEnvironmentlocation:eastusdeployment_template:"{{output_lab.id}}/artifactSources/publicenvironmentrepo/armTemplates/WebApp"register:output
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.
1234567
-name:Create instance of DevTest Lab Imageazure_rm_devtestlabcustomimage:resource_group:"{{resource_group}}"lab_name:"{{lab_name}}"name:myImagesource_vm:"{{output_vm.virtualmachines[0]['name']}}"linux_os_state:non_deprovisioned
Deleting the Lab
Final task deletes entire lab.
12345678910
-name:Delete instance of Labazure_rm_devtestlab:resource_group:"{{resource_group}}"name:"{{lab_name}}"state:absentregister:output-name:Assert the change was correctly reportedassert:that:-output.changed