mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-22 20:13:59 -07:00
Migrate more Azure integration tests. (#29034)
This commit is contained in:
parent
8f4c8844c4
commit
08bdb6198e
10 changed files with 34 additions and 8 deletions
3
test/integration/targets/azure_rm_deployment/aliases
Normal file
3
test/integration/targets/azure_rm_deployment/aliases
Normal file
|
@ -0,0 +1,3 @@
|
|||
cloud/azure
|
||||
posix/ci/cloud/group2/azure
|
||||
destructive
|
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- setup_azure
|
29
test/integration/targets/azure_rm_deployment/tasks/main.yml
Normal file
29
test/integration/targets/azure_rm_deployment/tasks/main.yml
Normal file
|
@ -0,0 +1,29 @@
|
|||
- 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/master/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 }}"
|
4
test/integration/targets/azure_rm_securitygroup/aliases
Normal file
4
test/integration/targets/azure_rm_securitygroup/aliases
Normal file
|
@ -0,0 +1,4 @@
|
|||
cloud/azure
|
||||
posix/ci/cloud/group2/azure
|
||||
destructive
|
||||
azure_rm_securitygroup_facts
|
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- setup_azure
|
140
test/integration/targets/azure_rm_securitygroup/tasks/main.yml
Normal file
140
test/integration/targets/azure_rm_securitygroup/tasks/main.yml
Normal file
|
@ -0,0 +1,140 @@
|
|||
- name: Create security group
|
||||
azure_rm_securitygroup:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: mysecgroup
|
||||
tags:
|
||||
testing: testing
|
||||
delete: on-exit
|
||||
foo: bar
|
||||
purge_rules: yes
|
||||
rules:
|
||||
- name: DenySSH
|
||||
protocol: Tcp
|
||||
destination_port_range: 22
|
||||
access: Deny
|
||||
priority: 100
|
||||
direction: Inbound
|
||||
- name: 'AllowSSH'
|
||||
protocol: Tcp
|
||||
source_address_prefix: '174.109.158.0/24'
|
||||
destination_port_range: 22
|
||||
access: Allow
|
||||
priority: 101
|
||||
direction: Inbound
|
||||
register: output
|
||||
|
||||
- assert: { that: "{{ output.state.rules | length }} == 2" }
|
||||
|
||||
- name: Gather facts by tags
|
||||
azure_rm_securitygroup_facts:
|
||||
resource_group: "{{ resource_group }}"
|
||||
tags:
|
||||
- testing
|
||||
- foo:bar
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that: azure_securitygroups | length == 1
|
||||
|
||||
- name: Add/Update rules on existing security group
|
||||
azure_rm_securitygroup:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: mysecgroup
|
||||
rules:
|
||||
- name: DenySSH
|
||||
protocol: Tcp
|
||||
destination_port_range: 22-23
|
||||
access: Deny
|
||||
priority: 100
|
||||
- name: AllowSSHFromHome
|
||||
protocol: Tcp
|
||||
source_address_prefix: '174.109.158.0/24'
|
||||
destination_port_range: 22-23
|
||||
priority: 102
|
||||
register: output
|
||||
|
||||
- assert: { that: "{{ output.state.rules | length }} == 3" }
|
||||
|
||||
- name: Test idempotence
|
||||
azure_rm_securitygroup:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: mysecgroup
|
||||
rules:
|
||||
- name: DenySSH
|
||||
protocol: Tcp
|
||||
destination_port_range: 22-23
|
||||
access: Deny
|
||||
priority: 100
|
||||
- name: AllowSSHFromHome
|
||||
protocol: Tcp
|
||||
source_address_prefix: '174.109.158.0/24'
|
||||
destination_port_range: 22-23
|
||||
priority: 102
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that: not output.changed
|
||||
|
||||
- name: Update tags
|
||||
azure_rm_securitygroup:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: mysecgroup
|
||||
tags:
|
||||
testing: testing
|
||||
delete: never
|
||||
baz: bar
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- output.state.tags | length == 3
|
||||
- output.state.tags.delete == 'never'
|
||||
|
||||
- name: Purge tags
|
||||
azure_rm_securitygroup:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: mysecgroup
|
||||
tags:
|
||||
testing: testing
|
||||
delete: on-exit
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- output.state.tags | length == 2
|
||||
- output.state.tags.delete == 'on-exit'
|
||||
|
||||
- name: Gather facts for one accounts
|
||||
azure_rm_securitygroup_facts:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: mysecgroup
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- azure_securitygroups | length == 1
|
||||
|
||||
- name: Gather facts for all accounts
|
||||
azure_rm_securitygroup_facts:
|
||||
resource_group: "{{ resource_group }}"
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- azure_securitygroups | length > 0
|
||||
|
||||
- name: Delete all security groups
|
||||
azure_rm_securitygroup:
|
||||
resource_group: "{{ resource_group }}"
|
||||
name: "{{ item.name }}"
|
||||
state: absent
|
||||
with_items: "{{ azure_securitygroups }}"
|
||||
|
||||
- name: Should have no security groups remaining
|
||||
azure_rm_securitygroup_facts:
|
||||
resource_group: "{{ resource_group }}"
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- azure_securitygroups | length == 0
|
|
@ -0,0 +1,3 @@
|
|||
cloud/azure
|
||||
posix/ci/cloud/group2/azure
|
||||
destructive
|
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- setup_azure
|
|
@ -0,0 +1,43 @@
|
|||
- name: set location
|
||||
set_fact:
|
||||
location: eastus
|
||||
|
||||
- name: Get facts for a specific image
|
||||
azure_rm_virtualmachineimage_facts:
|
||||
location: "{{ location }}"
|
||||
publisher: OpenLogic
|
||||
offer: CentOS
|
||||
sku: '7.3'
|
||||
version: '7.3.20170707'
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that: azure_vmimages | length == 1
|
||||
|
||||
- name: List available versions
|
||||
azure_rm_virtualmachineimage_facts:
|
||||
location: "{{ location }}"
|
||||
publisher: OpenLogic
|
||||
offer: CentOS
|
||||
sku: '7.3'
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that: azure_vmimages | length > 0
|
||||
|
||||
- name: List available offers
|
||||
azure_rm_virtualmachineimage_facts:
|
||||
location: "{{ location }}"
|
||||
publisher: OpenLogic
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that: azure_vmimages | length > 0
|
||||
|
||||
- name: List available publishers
|
||||
azure_rm_virtualmachineimage_facts:
|
||||
location: "{{ location }}"
|
||||
register: output
|
||||
|
||||
- assert:
|
||||
that: azure_vmimages | length > 0
|
Loading…
Add table
Add a link
Reference in a new issue