-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ACA-1500: Create a common resource management convention for all roles
The following rules must be followed: * The main file for each role should include the "Get Resource Group" task. * In the "Create" tasks: - Verify that if the resource group doesn't exist, the user must provide the region name. - If the resource group doesn't exist, create it with the given region name. * In the "Delete" tasks: - Verify that the resource group exists. - After all resources are deleted successfully, if the user requested to delete the resource group, delete it. - The role shouldn't include an option for force deleting non-empty resource groups. Also changing the integration tests to have 2 tests cases: 1. Pre created Resource Group 2. Resource Group has to be created and deleted by role
- Loading branch information
Showing
7 changed files
with
122 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
--- | ||
azure_load_balancer_with_public_ip_operation: create | ||
azure_load_balancer_with_public_ip_delete_resource_group: false |
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
3 changes: 1 addition & 2 deletions
3
tests/integration/targets/test_azure_load_balancer_with_public_ip/defaults/main.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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
--- | ||
azure_load_balancer_with_public_ip_resource_group: "{{ resource_group }}" | ||
azure_load_balancer_with_public_ip_tags: | ||
resource_prefix: "{{ resource_prefix }}" | ||
load_balancer_name: "{{ resource_prefix }}-load-balancer" | ||
load_balancer_public_ip_name: "{{ resource_prefix }}-publicIP" | ||
load_balancer_sku: 'Basic' | ||
load_balancer_sku: 'Basic' |
72 changes: 72 additions & 0 deletions
72
...ntegration/targets/test_azure_load_balancer_with_public_ip/tasks/create_and_delete_lb.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,72 @@ | ||
- name: Test Create and Delete Load Balancer | ||
block: | ||
- name: Print test step details | ||
ansible.builtin.debug: | ||
msg: "Run test with resource_group={{ test_resource_group }}" | ||
|
||
# Test: Create Load Balancer | ||
- name: Create Load Balancer with Public IP | ||
ansible.builtin.include_role: | ||
name: cloud.azure_ops.azure_load_balancer_with_public_ip | ||
vars: | ||
azure_load_balancer_with_public_ip_resource_group: "{{ test_resource_group }}" | ||
azure_load_balancer_with_public_ip_operation: create | ||
azure_load_balancer_with_public_ip_load_balancer: | ||
name: "{{ load_balancer_name }}" | ||
public_ip_name: "{{ load_balancer_public_ip_name }}" | ||
sku: "{{ load_balancer_sku }}" | ||
|
||
- name: Gather Load Balancer info | ||
azure.azcollection.azure_rm_loadbalancer_info: | ||
name: "{{ load_balancer_name }}" | ||
resource_group: "{{ test_resource_group }}" | ||
register: _loadbalancer | ||
|
||
- name: Ensure Load Balancer was created as expected | ||
ansible.builtin.assert: | ||
that: | ||
- _loadbalancer.loadbalancers | length == 1 | ||
|
||
- name: Gather Public IP info | ||
azure.azcollection.azure_rm_publicipaddress_info: | ||
name: "{{ load_balancer_public_ip_name }}" | ||
resource_group: "{{ test_resource_group }}" | ||
register: _publicip | ||
|
||
- name: Ensure Public IP was created | ||
ansible.builtin.assert: | ||
that: | ||
- _publicip.publicipaddresses | length == 1 | ||
|
||
# Test: Delete Load Balancer | ||
- name: Delete Load Balancer with Public IP | ||
ansible.builtin.include_role: | ||
name: cloud.azure_ops.azure_load_balancer_with_public_ip | ||
vars: | ||
azure_load_balancer_with_public_ip_resource_group: "{{ test_resource_group }}" | ||
azure_load_balancer_with_public_ip_operation: delete | ||
azure_load_balancer_with_public_ip_load_balancer: | ||
name: "{{ load_balancer_name }}" | ||
public_ip_name: "{{ load_balancer_public_ip_name }}" | ||
sku: "{{ load_balancer_sku }}" | ||
|
||
- name: Ensure Load Balancer was deleted | ||
azure.azcollection.azure_rm_loadbalancer_info: | ||
name: "{{ load_balancer_name }}" | ||
resource_group: "{{ test_resource_group }}" | ||
register: _loadbalancer | ||
failed_when: _loadbalancer.loadbalancers | length > 0 | ||
|
||
- name: Ensure Public IP was deleted | ||
azure.azcollection.azure_rm_publicipaddress_info: | ||
name: "{{ load_balancer_public_ip_name }}" | ||
resource_group: "{{ test_resource_group }}" | ||
register: _publicip | ||
failed_when: _publicip.publicipaddresses | length > 0 | ||
|
||
- name: Ensure Resource Group was deleted - {{ test_resource_group }} | ||
azure.azcollection.azure_rm_resourcegroup_info: | ||
name: "{{ test_resource_group }}" | ||
when: azure_load_balancer_with_public_ip_delete_resource_group is defined and azure_load_balancer_with_public_ip_delete_resource_group | ||
register: _resourcegroup | ||
failed_when: _resourcegroup.resourcegroups | length > 0 |
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