forked from ansible-collections/azure
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addition of Spot instance support for VM and VMSS (ansible-collection…
…s#559) * Addition of Spot instance support for VM and VMSS * PR comment relative to formatting * Addition of spot instance test for azure_rm_virtualmachine and vmss * Changed default priority to None. Added validation for Spot param update * Removed default values for spot instances parameters + formatting * small change Co-authored-by: Vincent Prince <[email protected]> Co-authored-by: Fred-sun <[email protected]> Co-authored-by: Fred-sun <[email protected]>
- Loading branch information
1 parent
a73de60
commit 26f59cd
Showing
4 changed files
with
306 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_spot.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
- include_tasks: setup.yml | ||
|
||
- name: Create minimal VM with Spot Instance default values | ||
azure_rm_virtualmachine: | ||
resource_group: "{{ resource_group }}" | ||
name: "{{ vm_name }}" | ||
priority: Spot | ||
eviction_policy: Deallocate | ||
admin_username: "testuser" | ||
ssh_password_enabled: false | ||
ssh_public_keys: | ||
- path: /home/testuser/.ssh/authorized_keys | ||
key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfoYlIV4lTPZTv7hXaVwQQuqBgGs4yeNRX0SPo2+HQt9u4X7IGwrtXc0nEUm6LfaCikMH58bOL8f20NTGz285kxdFHZRcBXtqmnMz2rXwhK9gwq5h1khc+GzHtdcJXsGA4y0xuaNcidcg04jxAlN/06fwb/VYwwWTVbypNC0gpGEpWckCNm8vlDlA55sU5et0SZ+J0RKVvEaweUOeNbFZqckGPA384imfeYlADppK/7eAxqfBVadVvZG8IJk4yvATgaIENIFj2cXxqu2mQ/Bp5Wr45uApvJsFXmi+v/nkiOEV1QpLOnEwAZo6EfFS4CCQtsymxJCl1PxdJ5LD4ZOtP [email protected]" | ||
vm_size: Standard_A1_v2 | ||
virtual_network: "{{ network_name }}" | ||
image: | ||
offer: CentOS | ||
publisher: OpenLogic | ||
sku: '7.1' | ||
version: latest | ||
register: vm_output | ||
|
||
- name: Ensure VM was created using Spot Instance default values | ||
assert: | ||
that: | ||
- azure_vm.properties.priority == 'Spot' | ||
- azure_vm.properties.evictionPolicy == 'Deallocate' | ||
- azure_vm.properties.billingProfile.maxPrice == -1.0 | ||
|
||
- name: Delete VM | ||
azure_rm_virtualmachine: | ||
resource_group: "{{ resource_group }}" | ||
name: "{{ vm_name }}" | ||
state: absent | ||
vm_size: Standard_A1_v2 | ||
|
||
- name: Create minimal VM with custom Spot Instance values | ||
azure_rm_virtualmachine: | ||
resource_group: "{{ resource_group }}" | ||
name: "{{ vm_name }}" | ||
priority: Spot | ||
eviction_policy: Delete | ||
max_price: 1.0 | ||
admin_username: "testuser" | ||
ssh_password_enabled: false | ||
ssh_public_keys: | ||
- path: /home/testuser/.ssh/authorized_keys | ||
key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfoYlIV4lTPZTv7hXaVwQQuqBgGs4yeNRX0SPo2+HQt9u4X7IGwrtXc0nEUm6LfaCikMH58bOL8f20NTGz285kxdFHZRcBXtqmnMz2rXwhK9gwq5h1khc+GzHtdcJXsGA4y0xuaNcidcg04jxAlN/06fwb/VYwwWTVbypNC0gpGEpWckCNm8vlDlA55sU5et0SZ+J0RKVvEaweUOeNbFZqckGPA384imfeYlADppK/7eAxqfBVadVvZG8IJk4yvATgaIENIFj2cXxqu2mQ/Bp5Wr45uApvJsFXmi+v/nkiOEV1QpLOnEwAZo6EfFS4CCQtsymxJCl1PxdJ5LD4ZOtP [email protected]" | ||
vm_size: Standard_A1_v2 | ||
virtual_network: "{{ network_name }}" | ||
image: | ||
offer: CentOS | ||
publisher: OpenLogic | ||
sku: '7.1' | ||
version: latest | ||
register: vm_output | ||
|
||
- name: Ensure VM was created using custom spot instance values | ||
assert: | ||
that: | ||
- azure_vm.properties.priority == 'Spot' | ||
- azure_vm.properties.evictionPolicy == 'Delete' | ||
- azure_vm.properties.billingProfile.maxPrice == 1.0 | ||
|
||
- name: Delete VM | ||
azure_rm_virtualmachine: | ||
resource_group: "{{ resource_group }}" | ||
name: "{{ vm_name }}" | ||
state: absent | ||
vm_size: Standard_A1_v2 | ||
|
||
- name: Destroy subnet | ||
azure_rm_subnet: | ||
resource_group: "{{ resource_group }}" | ||
virtual_network: "{{ network_name }}" | ||
name: "{{ subnet_name }}" | ||
state: absent | ||
|
||
- name: Destroy virtual network | ||
azure_rm_virtualnetwork: | ||
resource_group: "{{ resource_group }}" | ||
name: "{{ network_name }}" | ||
state: absent |
Oops, something went wrong.