45 lines
1.4 KiB
YAML
45 lines
1.4 KiB
YAML
- name: Create random dns label
|
|
set_fact:
|
|
dns_label: "test{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
|
|
|
|
- name: Create Azure Deploy
|
|
azure_rm_deployment:
|
|
resource_group: "{{ resource_group }}"
|
|
location: "eastus"
|
|
template_link: 'https://raw.githubusercontent.com/Azure/azure-quickstart-templates/d01a5c06f4f1bc03a049ca17bbbd6e06d62657b3/101-vm-simple-linux/azuredeploy.json'
|
|
deployment_name: "{{ dns_label }}"
|
|
parameters:
|
|
adminUsername:
|
|
value: chouseknecht
|
|
adminPassword:
|
|
value: password123!
|
|
dnsLabelPrefix:
|
|
value: "{{ dns_label }}"
|
|
ubuntuOSVersion:
|
|
value: "16.04.0-LTS"
|
|
register: output
|
|
|
|
- name: Add new instance to host group
|
|
add_host:
|
|
hostname: "{{ item.vm_name }}"
|
|
ansible_host: "{{ item['ips'][0].public_ip }}"
|
|
ansible_user: chouseknecht
|
|
ansible_ssh_pass: password123!
|
|
groupname: azure_vms
|
|
with_items: "{{ output.deployment.instances }}"
|
|
|
|
- name: Get Deployment Facts
|
|
azure_rm_deployment_info:
|
|
resource_group: "{{ resource_group }}"
|
|
name: "{{ dns_label }}"
|
|
register: output
|
|
- debug:
|
|
var: output
|
|
|
|
- name: Assert that values are returned
|
|
assert:
|
|
that:
|
|
- not output.changed
|
|
- output.deployments[0]['provisioning_state'] != None
|
|
- output.deployments[0]['output_resources'] | length > 0
|
|
- output.deployments[0]['outputs'] | length > 0
|