2019-01-24 00:03:16 +00:00
|
|
|
- name: Prepare random number
|
|
|
|
set_fact:
|
|
|
|
lab_name: "lab{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
|
|
|
vn_name: "vn{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
|
|
|
run_once: yes
|
|
|
|
|
|
|
|
- name: Create instance of Lab -- check mode
|
|
|
|
azure_rm_devtestlab:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ lab_name }}"
|
|
|
|
location: eastus
|
|
|
|
storage_type: standard
|
|
|
|
premium_data_disks: no
|
|
|
|
check_mode: yes
|
|
|
|
register: output
|
|
|
|
- name: Check if the change was correctly reported
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
|
|
|
- name: Create instance of Lab
|
|
|
|
azure_rm_devtestlab:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ lab_name }}"
|
|
|
|
location: eastus
|
|
|
|
storage_type: standard
|
|
|
|
premium_data_disks: no
|
|
|
|
register: output
|
|
|
|
- name: Check if the change was correctly reported
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
|
|
|
- name: Create again instance of Lab
|
|
|
|
azure_rm_devtestlab:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ lab_name }}"
|
|
|
|
location: eastus
|
|
|
|
storage_type: standard
|
|
|
|
premium_data_disks: no
|
|
|
|
register: output
|
|
|
|
- name: Assert the state has not changed
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed == false
|
|
|
|
|
|
|
|
- name: Update lab - premium_data_disks
|
|
|
|
azure_rm_devtestlab:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ lab_name }}"
|
|
|
|
location: eastus
|
|
|
|
storage_type: standard
|
|
|
|
premium_data_disks: yes
|
|
|
|
register: output
|
|
|
|
- name: Assert the change was registered
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
2019-02-19 05:01:44 +00:00
|
|
|
- name: Get DevTest Lab facts
|
|
|
|
azure_rm_devtestlab_facts:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ lab_name }}"
|
|
|
|
register: output
|
|
|
|
- name: Assert that facts are returned
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed == False
|
|
|
|
- output.labs[0]['id'] != None
|
|
|
|
- output.labs[0]['resource_group'] != None
|
|
|
|
- output.labs[0]['name'] != None
|
|
|
|
- output.labs[0]['location'] != None
|
|
|
|
- output.labs[0]['storage_type'] != None
|
|
|
|
- output.labs[0]['premium_data_disks'] != None
|
|
|
|
- output.labs[0]['provisioning_state'] != None
|
|
|
|
- output.labs[0]['artifacts_storage_account'] != None
|
|
|
|
- output.labs[0]['default_premium_storage_account'] != None
|
|
|
|
- output.labs[0]['default_storage_account'] != None
|
|
|
|
- output.labs[0]['premium_data_disk_storage_account'] != None
|
|
|
|
- output.labs[0]['vault_name'] != None
|
|
|
|
|
|
|
|
- name: List DevTest Lab in a resource group
|
|
|
|
azure_rm_devtestlab_facts:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
register: output
|
|
|
|
- name: Assert that facts are returned
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed == False
|
|
|
|
- output.labs[0]['id'] != None
|
|
|
|
- output.labs[0]['resource_group'] != None
|
|
|
|
- output.labs[0]['name'] != None
|
|
|
|
- output.labs[0]['location'] != None
|
|
|
|
- output.labs[0]['storage_type'] != None
|
|
|
|
- output.labs[0]['premium_data_disks'] != None
|
|
|
|
- output.labs[0]['provisioning_state'] != None
|
|
|
|
- output.labs[0]['vault_name'] != None
|
|
|
|
|
2019-01-24 00:03:16 +00:00
|
|
|
- name: Create instance of DebTest Labs virtual network
|
|
|
|
azure_rm_devtestlabvirtualnetwork:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
lab_name: "{{ lab_name }}"
|
|
|
|
name: "{{ vn_name }}"
|
|
|
|
location: eastus
|
|
|
|
description: My DevTest Lab
|
|
|
|
register: output
|
|
|
|
- name: Assert the change was registered
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
|
|
|
- name: Update instance of DebTest Labs virtual network with same parameters
|
|
|
|
azure_rm_devtestlabvirtualnetwork:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
lab_name: "{{ lab_name }}"
|
|
|
|
name: "{{ vn_name }}"
|
|
|
|
location: eastus
|
|
|
|
description: My DevTest Lab
|
|
|
|
register: output
|
|
|
|
- name: Assert that nothing was changed
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed == false
|
|
|
|
|
|
|
|
- name: Update instance of DebTest Labs virtual network with changed description
|
|
|
|
azure_rm_devtestlabvirtualnetwork:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
lab_name: "{{ lab_name }}"
|
|
|
|
name: "{{ vn_name }}"
|
|
|
|
location: eastus
|
|
|
|
description: My DevTest Lab Updated
|
|
|
|
register: output
|
|
|
|
- name: Assert that nothing was changed
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
|
|
|
- name: Delete instance of Lab -- check mode
|
|
|
|
azure_rm_devtestlab:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
state: absent
|
|
|
|
name: "{{ lab_name }}"
|
|
|
|
check_mode: yes
|
|
|
|
register: output
|
|
|
|
- name: Assert if the change was correctly reported in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
|
|
|
- name: Delete instance of Lab
|
|
|
|
azure_rm_devtestlab:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ lab_name }}"
|
|
|
|
state: absent
|
|
|
|
register: output
|
|
|
|
- name: Assert the change was correctly reported
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed
|
|
|
|
|
|
|
|
- name: Delete unexisting instance of Lab
|
|
|
|
azure_rm_devtestlab:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ lab_name }}unexisting"
|
|
|
|
state: absent
|
|
|
|
register: output
|
|
|
|
- name: Assert thes state has not changed
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- output.changed == false
|