mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
migrate azure_rm_vm tests to active (#30452)
This commit is contained in:
parent
c12c7a72ed
commit
035a17e8aa
7 changed files with 6 additions and 108 deletions
|
@ -1,8 +0,0 @@
|
|||
ssh_keys:
|
||||
- path: '/home/chouseknecht/.ssh/authorized_keys'
|
||||
key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC1igsIlcmTa/yfsJnTtnrEX7PP/a01gwbXcig6JOKyrUmJB8E6c/wtZwP115VSyDRTO6TEL/sBFUpkSw01zM8ydNATErh8meBlAlbnDq5NLhDXnMizgG0VNn0iLc/WplFTqkefsHXa8NtIxAtyEVIj/fKbK3XfBOdEpE3+MJYNtGlWyaod28W+5qmQPZDQys+YnE4OjSwN7D3g85/7dtLFvDH+lEC4ooJOaxVFr9VSMXUIkaRF6oI+R1Zu803LFSCTb4BfFOYOHPuQ/rEMP0KuUzggvP+TEBY14PEA2FoHOn+oRsT0ZR2+loGRaxSVqCQKaEHbNbkm+6Rllx2NQRO0BJxCSKRU1iifInLPxmSc4gvsHCKMAWy/tGkmKHPWIfN8hvwyDMK5MNBp/SJ1pVx4xuFDQjVWNbll0yk2+72uJgtFHHwEPK9QsOz45gX85vS3yhYCKrscS/W9h2l36SWwQXuGy4fXotE7esPsvNGAzBndHX1O8RMPg47qJXz059RyoGforoa9TnzIs3hIv+ts7ESx3OEq3HNk0FJ+wDka7IM7WQpGrVToJ0vfDy9Q46nw54vv5Zc/u4OZF3F5twHmyf3rLYKXRDuCvZQKT2iWQKVX6j63bq6orA5hwl22zndxWZNtOwtq8Sd0Ns0K/Fo/ggYDDGBtr68DwhA+MrxrHw== chouseknecht@ansible.com"
|
||||
image:
|
||||
offer: CentOS
|
||||
publisher: OpenLogic
|
||||
sku: '7.1'
|
||||
version: latest
|
|
@ -1,2 +0,0 @@
|
|||
- include: virtualmachine.yml
|
||||
#- include: virtualmachine_with_defaults.yml
|
|
@ -1,157 +0,0 @@
|
|||
- name: Delete virtual machine
|
||||
azure_rm_virtualmachine:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm002
|
||||
state: absent
|
||||
vm_size: Standard_A0
|
||||
register: output
|
||||
|
||||
- name: Create storage account name
|
||||
set_fact:
|
||||
storage_account: "{{ resource_group | hash('md5') | truncate(24, True, '') }}"
|
||||
|
||||
- name: Create storage account
|
||||
azure_rm_storageaccount:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: "{{ storage_account }}"
|
||||
account_type: Standard_LRS
|
||||
|
||||
- name: Create virtual network
|
||||
azure_rm_virtualnetwork:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm001
|
||||
address_prefixes: "10.10.0.0/16"
|
||||
|
||||
- name: Add subnet
|
||||
azure_rm_subnet:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm001
|
||||
address_prefix: "10.10.0.0/24"
|
||||
virtual_network: testvm001
|
||||
|
||||
- name: Create public ip
|
||||
azure_rm_publicipaddress:
|
||||
resource_group: "{{ resource_group }}"
|
||||
allocation_method: Static
|
||||
name: testvm001
|
||||
|
||||
- name: Create security group
|
||||
azure_rm_securitygroup:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm001
|
||||
|
||||
- name: Create NIC
|
||||
azure_rm_networkinterface:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm001
|
||||
virtual_network: testvm001
|
||||
subnet: testvm001
|
||||
public_ip_name: testvm001
|
||||
security_group: testvm001
|
||||
|
||||
- name: Create virtual machine
|
||||
azure_rm_virtualmachine:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm002
|
||||
vm_size: Standard_A0
|
||||
storage_account: "{{ storage_account }}"
|
||||
storage_container: testvm001
|
||||
storage_blob: testvm001.vhd
|
||||
admin_username: adminuser
|
||||
admin_password: Password123!
|
||||
short_hostname: testvm
|
||||
os_type: Linux
|
||||
network_interfaces: testvm001
|
||||
image:
|
||||
offer: UbuntuServer
|
||||
publisher: Canonical
|
||||
sku: 16.04-LTS
|
||||
version: latest
|
||||
register: output
|
||||
|
||||
- name: Restart the virtual machine
|
||||
azure_rm_virtualmachine:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm002
|
||||
restarted: yes
|
||||
vm_size: Standard_A0
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "azure_vm.powerstate in ['starting', 'running']"
|
||||
- output.changed
|
||||
|
||||
- name: Deallocate the virtual machine
|
||||
azure_rm_virtualmachine:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm002
|
||||
allocated: no
|
||||
vm_size: Standard_A0
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- azure_vm.powerstate == 'deallocated'
|
||||
- output.changed
|
||||
|
||||
- name: Start the virtual machine
|
||||
azure_rm_virtualmachine:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm002
|
||||
vm_size: Standard_A0
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "azure_vm.powerstate in ['starting', 'running']"
|
||||
- output.changed
|
||||
|
||||
- name: Should be idempotent
|
||||
azure_rm_virtualmachine:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm002
|
||||
vm_size: Standard_A0
|
||||
storage_account: "{{ storage_account }}"
|
||||
storage_container: testvm001
|
||||
storage_blob: testvm001.vhd
|
||||
admin_username: adminuser
|
||||
admin_password: Password123!
|
||||
short_hostname: testvm
|
||||
os_type: Linux
|
||||
network_interfaces: testvm001
|
||||
image:
|
||||
offer: UbuntuServer
|
||||
publisher: Canonical
|
||||
sku: 16.04-LTS
|
||||
version: latest
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that: not output.changed
|
||||
|
||||
- name: Delete VM
|
||||
azure_rm_virtualmachine:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm002
|
||||
state: absent
|
||||
vm_size: Standard_A0
|
||||
register: output
|
||||
|
||||
- name: NIC should be gone
|
||||
azure_rm_networkinterface_facts:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm001
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that: azure_networkinterfaces | length == 0
|
||||
|
||||
- name: PIP should be gone
|
||||
azure_rm_publicipaddress_facts:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm001
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that: azure_publicipaddresses | length == 0
|
|
@ -1,106 +0,0 @@
|
|||
- name: Remove VM
|
||||
azure_rm_virtualmachine:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm10
|
||||
state: absent
|
||||
vm_size: Standard_A0
|
||||
register: output
|
||||
|
||||
- name: Remove VM
|
||||
azure_rm_virtualmachine:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm20
|
||||
state: absent
|
||||
vm_size: Standard_A0
|
||||
register: output
|
||||
|
||||
- name: Create VM with defaults
|
||||
azure_rm_virtualmachine:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm10
|
||||
vm_size: Standard_A0
|
||||
admin_username: chouseknecht
|
||||
admin_password: Password123
|
||||
short_hostname: test10
|
||||
os_type: Linux
|
||||
open_ports:
|
||||
- "22-23"
|
||||
image:
|
||||
offer: UbuntuServer
|
||||
publisher: Canonical
|
||||
sku: 16.04-LTS
|
||||
version: latest
|
||||
register: output
|
||||
|
||||
- name: Add host
|
||||
add_host:
|
||||
groups: just_created
|
||||
hostname: testvm10
|
||||
ansible_host: "{{ azure_vm.properties.networkProfile.networkInterfaces[0].properties.ipConfigurations[0].properties.publicIPAddress.properties.ipAddress }}"
|
||||
ansible_user: chouseknecht
|
||||
ansible_ssh_pass: Password123
|
||||
|
||||
- name: Create VM accessible via ssh keys only
|
||||
azure_rm_virtualmachine:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm20
|
||||
short_hostname: testvm20
|
||||
ssh_password_enabled: false
|
||||
ssh_public_keys:
|
||||
- path: /home/chouseknecht/.ssh/authorized_keys
|
||||
key_data: "{{ lookup('env', 'HOME') }}/.ssh/id_rsa"
|
||||
vm_size: Standard_A0
|
||||
admin_username: chouseknecht
|
||||
image:
|
||||
offer: UbuntuServer
|
||||
publisher: Canonical
|
||||
sku: 16.04-LTS
|
||||
version: latest
|
||||
register: output
|
||||
|
||||
- name: Should be idempotent
|
||||
azure_rm_virtualmachine:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm20
|
||||
short_hostname: testvm20
|
||||
ssh_password_enabled: false
|
||||
ssh_public_keys:
|
||||
- path: /home/chouseknecht/.ssh/authorized_keys
|
||||
key_data: "{{ lookup('env', 'HOME') }}/.ssh/id_rsa"
|
||||
vm_size: Standard_A0
|
||||
admin_username: chouseknecht
|
||||
image:
|
||||
offer: UbuntuServer
|
||||
publisher: Canonical
|
||||
sku: 16.04-LTS
|
||||
version: latest
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that: not output.changed
|
||||
|
||||
- name: Add host
|
||||
add_host:
|
||||
groups: just_created
|
||||
hostname: testvm20
|
||||
ansible_ssh_host: "{{ azure_vm.properties.networkProfile.networkInterfaces[0].properties.ipConfigurations[0].properties.publicIPAddress.properties.ipAddress }}"
|
||||
ansible_ssh_user: chouseknecht
|
||||
|
||||
- name: Power Off
|
||||
azure_rm_virtualmachine:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm10
|
||||
started: no
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that: "azure_vm.powerstate not in ['starting', 'running']"
|
||||
|
||||
- name: Power On
|
||||
azure_rm_virtualmachine:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: testvm10
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that: "azure_vm.powerstate in ['starting', 'running']"
|
Loading…
Add table
Add a link
Reference in a new issue