2017-09-06 04:38:56 +02:00
|
|
|
- name: Create random dns label
|
|
|
|
set_fact:
|
|
|
|
dns_label: "test{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
|
|
|
|
|
2017-08-12 01:16:39 +02:00
|
|
|
- name: Create Azure Deploy
|
|
|
|
azure_rm_deployment:
|
2017-09-06 04:38:56 +02:00
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
location: "eastus"
|
2019-02-07 20:24:51 +01:00
|
|
|
template_link: 'https://raw.githubusercontent.com/Azure/azure-quickstart-templates/d01a5c06f4f1bc03a049ca17bbbd6e06d62657b3/101-vm-simple-linux/azuredeploy.json'
|
2017-09-06 04:38:56 +02:00
|
|
|
deployment_name: "{{ dns_label }}"
|
2017-08-12 01:16:39 +02:00
|
|
|
parameters:
|
|
|
|
adminUsername:
|
2017-09-06 04:38:56 +02:00
|
|
|
value: chouseknecht
|
2017-08-12 01:16:39 +02:00
|
|
|
adminPassword:
|
|
|
|
value: password123!
|
|
|
|
dnsLabelPrefix:
|
2017-09-06 04:38:56 +02:00
|
|
|
value: "{{ dns_label }}"
|
2017-08-12 01:16:39 +02:00
|
|
|
ubuntuOSVersion:
|
2017-09-06 04:38:56 +02:00
|
|
|
value: "16.04.0-LTS"
|
2017-08-12 01:16:39 +02:00
|
|
|
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 }}"
|
2019-03-19 05:10:31 +01:00
|
|
|
|
|
|
|
- name: Get Deployment Facts
|
2019-08-28 13:01:10 +02:00
|
|
|
azure_rm_deployment_info:
|
2019-03-19 05:10:31 +01:00
|
|
|
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
|