Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add features to azure_rm_appgateway #990

Conversation

petitalotc
Copy link
Contributor

@petitalotc petitalotc commented Oct 3, 2022

SUMMARY
  • add waf configuration settings
  • add trusted root certificates
  • add enable http 2 parameter
  • add autoscale configuration
  • add draining options

All of these features are provided by the Azure python SDK however was not previously included in the azure_rm_appgateway module.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

azure_rm_appgateway.py

ADDITIONAL INFORMATION

integration tests. results

ansible-test integration azure_rm_appgateway --allow-destructive -v --allow-disabled
Using existing azure cloud config: tests/integration/cloud-config-azure.ini
Creating container database.
Configuring target inventory.
Running azure_rm_appgateway integration test role
Initializing "/tmp/ansible-test-scmqo3l5-injector" as the temporary injector directory.
Stream command: ansible-playbook azure_rm_appgateway-ma6xzyni.yml -i inventory -v
[WARNING]: running playbook inside collection azure.azcollection

PLAY [testhost] ****************************************************************

TASK [Gathering Facts] *********************************************************
ok: [testhost]

TASK [azure_rm_appgateway : Prepare random number] *****************************
ok: [testhost] => {"ansible_facts": {"cert1_file": "cert1.txt", "cert2_file": "cert2.txt", "cert3b64_file": "cert3b64.txt", "rpfx": "9f0db4438"}, "changed": false}

TASK [azure_rm_appgateway : Set json query to only retrieve gateways from this test] ***
ok: [testhost] => {"ansible_facts": {"query": "[?ends_with(name, `9f0db4438`)]"}, "changed": false}

TASK [azure_rm_appgateway : Load app gateways] *********************************
ok: [testhost] => {"changed": false, "gateways": [{"id": "/subscriptions/4aea99db-397a-45e5-a508-e6e06db77164/resourceGroups/rg-agaetis-ansible-azure-contrib/providers/Microsoft.Network/applicationGateways/appgateway9f0db44709", "location": "eastus", "name": "appgateway9f0db44709", "operational_state": "Running", "provisioning_state": "Succeeded", "resource_group": "rg-agaetis-ansible-azure-contrib", "ssl_policy": {"policy_name": "ssl_policy20150501", "policy_type": "predefined"}}, {"id": "/subscriptions/4aea99db-397a-45e5-a508-e6e06db77164/resourceGroups/rg-agaetis-ansible-azure-contrib/providers/Microsoft.Network/applicationGateways/appgateway9f0db44566", "location": "eastus", "name": "appgateway9f0db44566", "operational_state": "Running", "provisioning_state": "Succeeded", "resource_group": "rg-agaetis-ansible-azure-contrib", "ssl_policy": {"policy_name": null, "policy_type": "custom"}}, {"id": "/subscriptions/4aea99db-397a-45e5-a508-e6e06db77164/resourceGroups/rg-agaetis-ansible-azure-contrib/providers/Microsoft.Network/applicationGateways/appgateway-waf-v2-9f0db44989", "location": "eastus", "name": "appgateway-waf-v2-9f0db44989", "operational_state": "Running", "provisioning_state": "Succeeded", "resource_group": "rg-agaetis-ansible-azure-contrib", "ssl_policy": {"policy_name": "ssl_policy20170401_s", "policy_type": "predefined"}}, {"id": "/subscriptions/4aea99db-397a-45e5-a508-e6e06db77164/resourceGroups/rg-agaetis-ansible-azure-contrib/providers/Microsoft.Network/applicationGateways/appgateway-v2-9f0db44989", "location": "eastus", "name": "appgateway-v2-9f0db44989", "operational_state": "Running", "provisioning_state": "Succeeded", "resource_group": "rg-agaetis-ansible-azure-contrib", "ssl_policy": {"policy_name": "ssl_policy20170401_s", "policy_type": "predefined"}}, {"id": "/subscriptions/4aea99db-397a-45e5-a508-e6e06db77164/resourceGroups/rg-agaetis-ansible-azure-contrib/providers/Microsoft.Network/applicationGateways/appgateway-subnet-lookup9f0db44566", "location": "eastus", "name": "appgateway-subnet-lookup9f0db44566", "operational_state": "Running", "provisioning_state": "Succeeded", "resource_group": "rg-agaetis-ansible-azure-contrib", "ssl_policy": {"policy_name": "ssl_policy20150501", "policy_type": "predefined"}}]}

TASK [azure_rm_appgateway : Assert there are no gateways] **********************
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [azure_rm_appgateway : Create a virtual network] **************************
changed: [testhost] => {"changed": true, "check_mode": false, "state": {"address_prefixes": ["10.1.0.0/16", "172.100.0.0/16"], "dns_servers": ["127.0.0.1", "127.0.0.2"], "etag": "W/\"715224cb-95af-401c-904f-e2f74199eb1f\"", "id": "/subscriptions/4aea99db-397a-45e5-a508-e6e06db77164/resourceGroups/rg-agaetis-ansible-azure-contrib/providers/Microsoft.Network/virtualNetworks/vnet9f0db4438", "location": "eastus", "name": "vnet9f0db4438", "provisioning_state": "Succeeded", "tags": null, "type": "Microsoft.Network/virtualNetworks"}}

TASK [azure_rm_appgateway : Create a subnet] ***********************************
changed: [testhost] => {"changed": true, "state": {"address_prefix": "10.1.0.0/24", "address_prefixes": null, "id": "/subscriptions/4aea99db-397a-45e5-a508-e6e06db77164/resourceGroups/rg-agaetis-ansible-azure-contrib/providers/Microsoft.Network/virtualNetworks/vnet9f0db4438/subnets/subnet9f0db4438", "name": "subnet9f0db4438", "nat_gateway": null, "network_security_group": {}, "private_endpoint_network_policies": "Enabled", "private_link_service_network_policies": "Enabled", "provisioning_state": "Succeeded", "route_table": {}}}

TASK [azure_rm_appgateway : Configure public IP for v2 gateway] ****************
changed: [testhost] => {"changed": true, "state": {"dns_settings": {}, "etag": "W/\"725019e4-2a09-403c-b0fe-cef489e06104\"", "idle_timeout_in_minutes": 4, "ip_address": "20.168.220.142", "location": "eastus", "name": "appgateway-v2-9f0db4438-pip", "provisioning_state": "Succeeded", "public_ip_address_version": "ipv4", "public_ip_allocation_method": "static", "sku": "Standard", "tags": null, "type": "Microsoft.Network/publicIPAddresses", "zones": null}}

TASK [azure_rm_appgateway : Try to create v2 instance of Application Gateway with autoscale configuration and trusted root certificates] ***
changed: [testhost] => {"changed": true, "id": "/subscriptions/4aea99db-397a-45e5-a508-e6e06db77164/resourceGroups/rg-agaetis-ansible-azure-contrib/providers/Microsoft.Network/applicationGateways/appgateway-v2-9f0db4438", "location": "eastus", "name": "appgateway-v2-9f0db4438", "operational_state": "Running", "provisioning_state": "Succeeded", "resource_group": "rg-agaetis-ansible-azure-contrib"}

TASK [azure_rm_appgateway : Assert the resource instance is well created] ******
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [azure_rm_appgateway : Try to create v2 instance of Application Gateway with autoscale configuration and trusted root certificates - no update] ***
ok: [testhost] => {"changed": false, "id": "/subscriptions/4aea99db-397a-45e5-a508-e6e06db77164/resourceGroups/rg-agaetis-ansible-azure-contrib/providers/Microsoft.Network/applicationGateways/appgateway-v2-9f0db4438", "location": "eastus", "name": "appgateway-v2-9f0db4438", "operational_state": "Running", "provisioning_state": "Succeeded", "resource_group": "rg-agaetis-ansible-azure-contrib"}

TASK [azure_rm_appgateway : Assert the resource instance is not updated] *******
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [azure_rm_appgateway : Configure public IP for waf_v2 gateway] ************
changed: [testhost] => {"changed": true, "state": {"dns_settings": {}, "etag": "W/\"3e142ecb-57e8-48e5-84b6-14c274f3f8bf\"", "idle_timeout_in_minutes": 4, "ip_address": "52.188.163.254", "location": "eastus", "name": "appgateway-waf-v2-9f0db4438-pip", "provisioning_state": "Succeeded", "public_ip_address_version": "ipv4", "public_ip_allocation_method": "static", "sku": "Standard", "tags": null, "type": "Microsoft.Network/publicIPAddresses", "zones": null}}

TASK [azure_rm_appgateway : Try to create waf_v2 instance of Application Gateway with waf configuration] ***
changed: [testhost] => {"changed": true, "id": "/subscriptions/4aea99db-397a-45e5-a508-e6e06db77164/resourceGroups/rg-agaetis-ansible-azure-contrib/providers/Microsoft.Network/applicationGateways/appgateway-waf-v2-9f0db4438", "location": "eastus", "name": "appgateway-waf-v2-9f0db4438", "operational_state": "Running", "provisioning_state": "Succeeded", "resource_group": "rg-agaetis-ansible-azure-contrib"}

TASK [azure_rm_appgateway : Assert the resource instance is well created] ******
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [azure_rm_appgateway : Try to create waf_v2 instance of Application Gateway with waf configuration - no update] ***
ok: [testhost] => {"changed": false, "id": "/subscriptions/4aea99db-397a-45e5-a508-e6e06db77164/resourceGroups/rg-agaetis-ansible-azure-contrib/providers/Microsoft.Network/applicationGateways/appgateway-waf-v2-9f0db4438", "location": "eastus", "name": "appgateway-waf-v2-9f0db4438", "operational_state": "Running", "provisioning_state": "Succeeded", "resource_group": "rg-agaetis-ansible-azure-contrib"}

TASK [azure_rm_appgateway : Assert the resource instance is not updated] *******
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [azure_rm_appgateway : Delete v2 instance of Application Gateway] *********
changed: [testhost] => {"changed": true}

TASK [azure_rm_appgateway : Assert the state has changed] **********************
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [azure_rm_appgateway : Delete waf_v2 instance of Application Gateway] *****
changed: [testhost] => {"changed": true}

TASK [azure_rm_appgateway : Assert the state has changed] **********************
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [azure_rm_appgateway : Delete public IP for v2 gateway] *******************
changed: [testhost] => {"changed": true, "state": {"status": "Deleted"}}

TASK [azure_rm_appgateway : Assert the state has changed] **********************
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [azure_rm_appgateway : Delete public IP for waf v2 gateway] ***************
changed: [testhost] => {"changed": true, "state": {"status": "Deleted"}}

TASK [azure_rm_appgateway : Assert the state has changed] **********************
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [azure_rm_appgateway : Delete virtual network] ****************************
changed: [testhost] => {"changed": true, "check_mode": false, "state": {"address_prefixes": ["10.1.0.0/16", "172.100.0.0/16"], "dns_servers": ["127.0.0.1", "127.0.0.2"], "etag": "W/\"542ab011-19b1-49b5-b54c-a38f1cf45b3a\"", "id": "/subscriptions/4aea99db-397a-45e5-a508-e6e06db77164/resourceGroups/rg-agaetis-ansible-azure-contrib/providers/Microsoft.Network/virtualNetworks/vnet9f0db4438", "location": "eastus", "name": "vnet9f0db4438", "provisioning_state": "Succeeded", "status": "Deleted", "tags": null, "type": "Microsoft.Network/virtualNetworks"}}

PLAY RECAP *********************************************************************
testhost                   : ok=26   changed=11   unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

add waf configuration settings

add trusted root cert & enable http 2 & draining options
@petitalotc
Copy link
Contributor Author

It also fixed this issues/478

@petitalotc petitalotc changed the title azure_rm_appgateway Add features to azure_rm_appgateway Oct 11, 2022
plugins/modules/azure_rm_appgateway.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_appgateway.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_appgateway.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_appgateway.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_appgateway.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_appgateway.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_appgateway.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_appgateway.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_appgateway.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_appgateway.py Show resolved Hide resolved
@Fred-sun Fred-sun added medium_priority Medium priority work in In trying to solve, or in working with contributors new_feature New feature requirments labels Oct 11, 2022
Copy link
Collaborator

@Fred-sun Fred-sun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small change request!

plugins/modules/azure_rm_appgateway.py Outdated Show resolved Hide resolved
plugins/modules/azure_rm_appgateway.py Show resolved Hide resolved
petitalotc and others added 2 commits November 25, 2022 14:09
Co-authored-by: Fred-sun <37327967+Fred-sun@users.noreply.github.com>
Co-authored-by: Fred-sun <37327967+Fred-sun@users.noreply.github.com>
@Fred-sun Fred-sun added ready_for_review The PR has been modified and can be reviewed and merged and removed work in In trying to solve, or in working with contributors labels Nov 25, 2022
@xuzhang3
Copy link
Collaborator

xuzhang3 commented Dec 2, 2022

@petitalotc LGTM

@xuzhang3 xuzhang3 merged commit fdae081 into ansible-collections:dev Dec 2, 2022
@petitalotc petitalotc deleted the add_parameters_to_azure_rm_appgateway branch December 5, 2022 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
medium_priority Medium priority new_feature New feature requirments ready_for_review The PR has been modified and can be reviewed and merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants