From 9f3458e9b1c0869f26e145322ad529e5e7a0be45 Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Wed, 14 Apr 2021 13:49:06 +0530 Subject: [PATCH 01/24] initial commit --- plugins/modules/azure_rm_ddos.py | 0 plugins/modules/azure_rm_ddos_info.py | 0 pr-pipelines.yml | 1 + tests/integration/targets/azure_rm_ddos/aliases | 0 tests/integration/targets/azure_rm_ddos/meta/main.yml | 0 tests/integration/targets/azure_rm_ddos/tasks/main.yml | 0 6 files changed, 1 insertion(+) create mode 100644 plugins/modules/azure_rm_ddos.py create mode 100644 plugins/modules/azure_rm_ddos_info.py create mode 100644 tests/integration/targets/azure_rm_ddos/aliases create mode 100644 tests/integration/targets/azure_rm_ddos/meta/main.yml create mode 100644 tests/integration/targets/azure_rm_ddos/tasks/main.yml diff --git a/plugins/modules/azure_rm_ddos.py b/plugins/modules/azure_rm_ddos.py new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/modules/azure_rm_ddos_info.py b/plugins/modules/azure_rm_ddos_info.py new file mode 100644 index 000000000..e69de29bb diff --git a/pr-pipelines.yml b/pr-pipelines.yml index 7691f9a2a..e485c8934 100644 --- a/pr-pipelines.yml +++ b/pr-pipelines.yml @@ -38,6 +38,7 @@ parameters: - "azure_rm_containerregistry" - "azure_rm_cosmosdbaccount" - "azure_rm_datalakestore" + - "azure_rm_ddos" - "azure_rm_deployment" - "azure_rm_dnsrecordset" - "azure_rm_dnszone" diff --git a/tests/integration/targets/azure_rm_ddos/aliases b/tests/integration/targets/azure_rm_ddos/aliases new file mode 100644 index 000000000..e69de29bb diff --git a/tests/integration/targets/azure_rm_ddos/meta/main.yml b/tests/integration/targets/azure_rm_ddos/meta/main.yml new file mode 100644 index 000000000..e69de29bb diff --git a/tests/integration/targets/azure_rm_ddos/tasks/main.yml b/tests/integration/targets/azure_rm_ddos/tasks/main.yml new file mode 100644 index 000000000..e69de29bb From 07788ac58d4d758b75baf5cff4a4eb25f5a9c1dd Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Wed, 14 Apr 2021 17:00:44 +0530 Subject: [PATCH 02/24] add ddos protection plan operations --- plugins/modules/azure_rm_ddos.py | 0 plugins/modules/azure_rm_ddos_info.py | 0 .../modules/azure_rm_ddos_protection_plan.py | 222 ++++++++++++++++++ .../azure_rm_ddos_protection_plan_info.py | 155 ++++++++++++ pr-pipelines.yml | 2 +- 5 files changed, 378 insertions(+), 1 deletion(-) delete mode 100644 plugins/modules/azure_rm_ddos.py delete mode 100644 plugins/modules/azure_rm_ddos_info.py create mode 100644 plugins/modules/azure_rm_ddos_protection_plan.py create mode 100644 plugins/modules/azure_rm_ddos_protection_plan_info.py diff --git a/plugins/modules/azure_rm_ddos.py b/plugins/modules/azure_rm_ddos.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/plugins/modules/azure_rm_ddos_info.py b/plugins/modules/azure_rm_ddos_info.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/plugins/modules/azure_rm_ddos_protection_plan.py b/plugins/modules/azure_rm_ddos_protection_plan.py new file mode 100644 index 000000000..98aa15f31 --- /dev/null +++ b/plugins/modules/azure_rm_ddos_protection_plan.py @@ -0,0 +1,222 @@ +#!/usr/bin/python +# +# Copyright (c) 2021 Praveen Ghuge (@praveenghuge), Karl Dasan (@ikarldasan) +# +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import absolute_import, division, print_function +__metaclass__ = type +DOCUMENTATION = ''' +--- +module: azure_rm_ddos_protection_plan +version_added: "0.1.2" +short_description: Manage DDoS protection plan +description: + - Create, update and delete instance of DDoS protection plan. +options: + resource_group: + description: + - Name of the resource group to which the resource belongs. + required: true + type: str + name: + description: + - Unique name of the app service plan to create or update. + required: true + type: str + location: + description: + - Resource location. If not set, location from the resource group will be used as default. + type: str + state: + description: + - Assert the state of the DDoS protection plan. + - Use C(present) to create or update an DDoS protection plan and C(absent) to delete it. + type: str + default: present + choices: + - absent + - present +extends_documentation_fragment: +- azure.azcollection.azure +author: + - Praveen Ghuge (@praveenghuge) + - Karl Dasan (@ikarldasan) +''' +EXAMPLES = ''' +- name: "Create DDoS protection plan" + azure_rm_ddos_protection_plan: + resource_group: rg + location: eastus + name: ddosplan +- name: Delete DDoS protection plan + azure_rm_ddos_protection_plan: + resource_group: rg + name: ddosplan + state: absent +''' + +RETURN = ''' +sample: { + +} +''' + +from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common import AzureRMModuleBase + +try: + from msrestazure.azure_exceptions import CloudError + from azure.mgmt.network import NetworkManagementClient +except ImportError: + # This is handled in azure_rm_common + pass + + +class AzureDDoSProtectionPlan(AzureRMModuleBase): + + def __init__(self): + # define user inputs from playbook + + self.module_arg_spec = dict( + resource_group=dict(type='str', required=True), + name=dict(type='str', required=True), + location=dict(type='str') + ) + + self.resource_group = None + self.name = None + self.location = None + self.results = dict( + changed=False, + state=dict() + ) + + super(AzureDDoSProtectionPlan, self).__init__(self.module_arg_spec, + supports_check_mode=True, + supports_tags=True) + + def exec_module(self, **kwargs): + + for key in list(self.module_arg_spec.keys()) + ['tags']: + setattr(self, key, kwargs[key]) + + self.results['check_mode'] = self.check_mode + + # retrieve resource group to make sure it exists + self.get_resource_group(self.resource_group) + + results = dict() + changed = False + + try: + self.log('Fetching DDoS protection plan {0}'.format(self.name)) + ddos_protection_plan = self.network_client.ddos_protection_plans.get( + self.resource_group, self.name) + + results = ddos_protection_plan_to_dict(ddos_protection_plan) + + # don't change anything if creating an existing zone, but change if deleting it + if self.state == 'present': + changed = False + + update_tags, results['tags'] = self.update_tags( + results['tags']) + if update_tags: + changed = True + + elif self.state == 'absent': + changed = True + + except CloudError: + # the DDoS protection plan does not exist so create it + if self.state == 'present': + changed = True + else: + # you can't delete what is not there + changed = False + + self.results['changed'] = changed + self.results['state'] = results + + # return the results if your only gathering information + if self.check_mode: + return self.results + + if changed: + if self.state == "present": + self.results['state'] = self.create_or_update_ddos_protection_plan( + self.module.params) + elif self.state == "absent": + # delete DDoS protection plan + self.delete_ddos_protection_plan() + self.results['state']['status'] = 'Deleted' + + return self.results + + def create_or_update_ddos_protection_plan(self, params): + ''' + Create or update DDoS protection plan. + :return: create or update DDoS protection plan instance state dictionary + ''' + self.log("create or update DDoS protection plan {0}".format(self.name)) + try: + poller = self.network_client.ddos_protection_plans.create_or_update( + resource_group_name=params.get("resource_group"), + ddos_protection_plan_name=params.get("name"), + parameters=params) + result = self.get_poller_result(poller) + self.log("Response : {0}".format(result)) + except CloudError as ex: + self.fail("Failed to create DDoS protection plan {0} in resource group {1}: {2}".format( + self.name, self.resource_group, str(ex))) + return ddos_protection_plan_to_dict(result) + + def delete_ddos_protection_plan(self): + ''' + Deletes specified DDoS protection plan + :return True + ''' + self.log("Deleting the DDoS protection plan {0}".format(self.name)) + try: + poller = self.network_client.ddos_protection_plans.delete( + self.resource_group, self.name) + result = self.get_poller_result(poller) + except CloudError as e: + self.log('Error attempting to delete DDoS protection plan.') + self.fail( + "Error deleting the DDoS protection plan : {0}".format(str(e))) + return result + + +def ddos_protection_plan_to_dict(item): + # turn DDoS protection plan object into a dictionary (serialization) + ddos_protection_plan = item.as_dict() + + vnet = ddos_protection_plan.get('virtual_networks') + virtual_networks = [] + if vnet and len(vnet)>0: + virtual_networks = [] + for network in vnet: + nw_as_dict = network.as_dict() + virtual_networks.append(nw_as_dict) + + result = dict( + additional_properties=ddos_protection_plan.get('additional_properties', None), + id=ddos_protection_plan.get('id', None), + name=ddos_protection_plan.get('name', None), + type=ddos_protection_plan.get('type', None), + location=ddos_protection_plan.get('location', None), + tags=ddos_protection_plan.get('tags', None), + etag=ddos_protection_plan.get('etag', None), + resource_guid=ddos_protection_plan.get('resource_guid', None), + provisioning_state=ddos_protection_plan.get('provisioning_state', None), + virtual_networks=virtual_networks + ) + return result + + +def main(): + AzureDDoSProtectionPlan() + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/plugins/modules/azure_rm_ddos_protection_plan_info.py b/plugins/modules/azure_rm_ddos_protection_plan_info.py new file mode 100644 index 000000000..8ef601d9a --- /dev/null +++ b/plugins/modules/azure_rm_ddos_protection_plan_info.py @@ -0,0 +1,155 @@ +#!/usr/bin/python +# +# Copyright (c) 2021 Praveen Ghuge (@praveenghuge), Karl Dasan (@ikarldasan) +# +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = ''' +--- +module: azure_rm_ddos_protection_plan_info +short_description: Get Azure DDoS protection plan +description: + - Get facts of Azure DDoS protection plan. +options: + resource_group: + description: + - The name of the resource group. + required: True + type: str + name: + description: + - The name of the DDoS protection plan. + type: str +extends_documentation_fragment: +- azure.azcollection.azure +author: + - Praveen Ghuge (@praveenghuge) + - Karl Dasan (@ikarldasan) +''' + + +EXAMPLES = ''' + - name: Get facts of specific DDoS protection plan + community.azure.azure_rm_ddos_protection_plan_info: + resource_group: myResourceGroup + name: myDDoSProtectionPlan +''' + +RETURN = ''' +''' + +from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common import AzureRMModuleBase + +try: + from msrestazure.azure_exceptions import CloudError + from azure.mgmt.network import NetworkManagementClient + from msrest.serialization import Model +except ImportError: + # This is handled in azure_rm_common + pass + + +class AzureDDoSProtectionPlanInfo(AzureRMModuleBase): + def __init__(self): + self.module_arg_spec = dict( + resource_group=dict( + type='str', + required=True + ), + name=dict( + type='str' + ) + ) + # store the results of the module operation + self.results = dict( + changed=False) + self.resource_group = None + self.name = None + self.tags = None + + super(AzureDDoSProtectionPlanInfo, self).__init__( + self.module_arg_spec, supports_tags=False) + + def exec_module(self, **kwargs): + + for key in self.module_arg_spec: + setattr(self, key, kwargs[key]) + + if self.name is not None: + results = self.get() + elif self.resource_group: + # all the DDoS protection plan listed in that specific resource group + results = self.list_resource_group() + + self.results['ddos_protection_plan'] = [ + self.ddos_protection_plan_to_dict(x) for x in results] + return self.results + + def get(self): + response = None + results = [] + try: + response = self.network_client.ddos_protection_plans.get( + self.resource_group, self.name) + self.log("Response : {0}".format(response)) + except CloudError as e: + self.fail('Could not get info for DDoS protection plan. {0}').format(str(e)) + + if response and self.has_tags(response.tags, self.tags): + results = [response] + return results + + def list_resource_group(self): + self.log('List items for resource group') + try: + response = self.network_client.ddos_protection_plans.list_by_resource_group( + self.resource_group) + + except CloudError as exc: + self.fail( + "Failed to list for resource group {0} - {1}".format(self.resource_group, str(exc))) + + results = [] + for item in response: + if self.has_tags(item.tags, self.tags): + results.append(item) + return results + + def ddos_protection_plan_to_dict(self, item): + # turn DDoS protection plan object into a dictionary (serialization) + ddos_protection_plan = item.as_dict() + + vnet = ddos_protection_plan.get('virtual_networks') + virtual_networks = [] + if vnet and len(vnet)>0: + virtual_networks = [] + for network in vnet: + nw_as_dict = network.as_dict() + virtual_networks.append(nw_as_dict) + + result = dict( + additional_properties=ddos_protection_plan.get('additional_properties', None), + id=ddos_protection_plan.get('id', None), + name=ddos_protection_plan.get('name', None), + type=ddos_protection_plan.get('type', None), + location=ddos_protection_plan.get('location', None), + tags=ddos_protection_plan.get('tags', None), + etag=ddos_protection_plan.get('etag', None), + resource_guid=ddos_protection_plan.get('resource_guid', None), + provisioning_state=ddos_protection_plan.get('provisioning_state', None), + virtual_networks=virtual_networks + ) + return result + + +def main(): + AzureDDoSProtectionPlanInfo() + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/pr-pipelines.yml b/pr-pipelines.yml index e485c8934..1af5a9dc8 100644 --- a/pr-pipelines.yml +++ b/pr-pipelines.yml @@ -38,7 +38,7 @@ parameters: - "azure_rm_containerregistry" - "azure_rm_cosmosdbaccount" - "azure_rm_datalakestore" - - "azure_rm_ddos" + - "azure_rm_ddos_operation_plan" - "azure_rm_deployment" - "azure_rm_dnsrecordset" - "azure_rm_dnszone" From fd71f2b042930d6c94926aacf891a28896070532 Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Wed, 14 Apr 2021 19:02:45 +0530 Subject: [PATCH 03/24] enhance create flow --- plugins/modules/azure_rm_ddos_protection_plan.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/modules/azure_rm_ddos_protection_plan.py b/plugins/modules/azure_rm_ddos_protection_plan.py index 98aa15f31..e4fbf4887 100644 --- a/plugins/modules/azure_rm_ddos_protection_plan.py +++ b/plugins/modules/azure_rm_ddos_protection_plan.py @@ -79,12 +79,15 @@ def __init__(self): self.module_arg_spec = dict( resource_group=dict(type='str', required=True), name=dict(type='str', required=True), - location=dict(type='str') + location=dict(type='str', required=True), + state=dict(choices=['present', 'absent'], + default='present', type='str') ) self.resource_group = None self.name = None self.location = None + self.state = None self.results = dict( changed=False, state=dict() @@ -161,8 +164,8 @@ def create_or_update_ddos_protection_plan(self, params): try: poller = self.network_client.ddos_protection_plans.create_or_update( resource_group_name=params.get("resource_group"), - ddos_protection_plan_name=params.get("name"), - parameters=params) + location=self.location, + ddos_protection_plan_name=params.get("name")) result = self.get_poller_result(poller) self.log("Response : {0}".format(result)) except CloudError as ex: @@ -219,4 +222,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() From 9f5da5493906aa970f62ac9c4182bbc915e9773f Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Thu, 15 Apr 2021 20:28:46 +0530 Subject: [PATCH 04/24] enhance operations --- .../modules/azure_rm_ddos_protection_plan.py | 11 +++++--- .../azure_rm_ddos_protection_plan_info.py | 25 ++++++++++++++++--- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/plugins/modules/azure_rm_ddos_protection_plan.py b/plugins/modules/azure_rm_ddos_protection_plan.py index e4fbf4887..7bafd7b41 100644 --- a/plugins/modules/azure_rm_ddos_protection_plan.py +++ b/plugins/modules/azure_rm_ddos_protection_plan.py @@ -79,7 +79,7 @@ def __init__(self): self.module_arg_spec = dict( resource_group=dict(type='str', required=True), name=dict(type='str', required=True), - location=dict(type='str', required=True), + location=dict(type='str'), state=dict(choices=['present', 'absent'], default='present', type='str') ) @@ -88,6 +88,7 @@ def __init__(self): self.name = None self.location = None self.state = None + self.tags = None self.results = dict( changed=False, state=dict() @@ -140,7 +141,7 @@ def exec_module(self, **kwargs): self.results['changed'] = changed self.results['state'] = results - # return the results if your only gathering information + # return the results if you are only gathering information if self.check_mode: return self.results @@ -165,7 +166,8 @@ def create_or_update_ddos_protection_plan(self, params): poller = self.network_client.ddos_protection_plans.create_or_update( resource_group_name=params.get("resource_group"), location=self.location, - ddos_protection_plan_name=params.get("name")) + ddos_protection_plan_name=params.get("name"), + tags=self.tags) result = self.get_poller_result(poller) self.log("Response : {0}".format(result)) except CloudError as ex: @@ -182,7 +184,8 @@ def delete_ddos_protection_plan(self): try: poller = self.network_client.ddos_protection_plans.delete( self.resource_group, self.name) - result = self.get_poller_result(poller) + poller.wait() + result = poller.done() except CloudError as e: self.log('Error attempting to delete DDoS protection plan.') self.fail( diff --git a/plugins/modules/azure_rm_ddos_protection_plan_info.py b/plugins/modules/azure_rm_ddos_protection_plan_info.py index 8ef601d9a..011d08ff5 100644 --- a/plugins/modules/azure_rm_ddos_protection_plan_info.py +++ b/plugins/modules/azure_rm_ddos_protection_plan_info.py @@ -58,8 +58,7 @@ class AzureDDoSProtectionPlanInfo(AzureRMModuleBase): def __init__(self): self.module_arg_spec = dict( resource_group=dict( - type='str', - required=True + type='str' ), name=dict( type='str' @@ -85,6 +84,9 @@ def exec_module(self, **kwargs): elif self.resource_group: # all the DDoS protection plan listed in that specific resource group results = self.list_resource_group() + else: + # all the DDoS protection plan listed in the subscription + results = self.list_subscription() self.results['ddos_protection_plan'] = [ self.ddos_protection_plan_to_dict(x) for x in results] @@ -98,7 +100,7 @@ def get(self): self.resource_group, self.name) self.log("Response : {0}".format(response)) except CloudError as e: - self.fail('Could not get info for DDoS protection plan. {0}').format(str(e)) + self.fail('Could not get info for DDoS protection plan. {0}'.format(str(e))) if response and self.has_tags(response.tags, self.tags): results = [response] @@ -120,6 +122,21 @@ def list_resource_group(self): results.append(item) return results + def list_subscription(self): + self.log('List items for subscription') + try: + response = self.network_client.ddos_protection_plans.list() + + except CloudError as exc: + self.fail( + "Failed to list DDoS protection plan in the subscription - {0}".format(str(exc))) + + results = [] + for item in response: + if self.has_tags(item.tags, self.tags): + results.append(item) + return results + def ddos_protection_plan_to_dict(self, item): # turn DDoS protection plan object into a dictionary (serialization) ddos_protection_plan = item.as_dict() @@ -152,4 +169,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() From 1088567568dbf17af1a6237f208f4b2a82ff02e8 Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Fri, 16 Apr 2021 12:51:39 +0530 Subject: [PATCH 05/24] enhance get and delete operations --- plugins/modules/azure_rm_ddos_protection_plan.py | 10 ++-------- plugins/modules/azure_rm_ddos_protection_plan_info.py | 8 ++------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/plugins/modules/azure_rm_ddos_protection_plan.py b/plugins/modules/azure_rm_ddos_protection_plan.py index 7bafd7b41..01f9cb04c 100644 --- a/plugins/modules/azure_rm_ddos_protection_plan.py +++ b/plugins/modules/azure_rm_ddos_protection_plan.py @@ -184,8 +184,7 @@ def delete_ddos_protection_plan(self): try: poller = self.network_client.ddos_protection_plans.delete( self.resource_group, self.name) - poller.wait() - result = poller.done() + result = self.get_poller_result(poller) except CloudError as e: self.log('Error attempting to delete DDoS protection plan.') self.fail( @@ -198,12 +197,7 @@ def ddos_protection_plan_to_dict(item): ddos_protection_plan = item.as_dict() vnet = ddos_protection_plan.get('virtual_networks') - virtual_networks = [] - if vnet and len(vnet)>0: - virtual_networks = [] - for network in vnet: - nw_as_dict = network.as_dict() - virtual_networks.append(nw_as_dict) + virtual_networks = [network for network in (vnet or [])] result = dict( additional_properties=ddos_protection_plan.get('additional_properties', None), diff --git a/plugins/modules/azure_rm_ddos_protection_plan_info.py b/plugins/modules/azure_rm_ddos_protection_plan_info.py index 011d08ff5..a8899acfd 100644 --- a/plugins/modules/azure_rm_ddos_protection_plan_info.py +++ b/plugins/modules/azure_rm_ddos_protection_plan_info.py @@ -142,12 +142,8 @@ def ddos_protection_plan_to_dict(self, item): ddos_protection_plan = item.as_dict() vnet = ddos_protection_plan.get('virtual_networks') - virtual_networks = [] - if vnet and len(vnet)>0: - virtual_networks = [] - for network in vnet: - nw_as_dict = network.as_dict() - virtual_networks.append(nw_as_dict) + print("vnet:", vnet) + virtual_networks = [network for network in (vnet or [])] result = dict( additional_properties=ddos_protection_plan.get('additional_properties', None), From 5d2a295476e914909a207b5e320f97e7892c55b2 Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Fri, 16 Apr 2021 17:07:36 +0530 Subject: [PATCH 06/24] address sanity checks --- .../modules/azure_rm_ddos_protection_plan.py | 28 +++++++++++++------ .../azure_rm_ddos_protection_plan_info.py | 7 +---- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/plugins/modules/azure_rm_ddos_protection_plan.py b/plugins/modules/azure_rm_ddos_protection_plan.py index 01f9cb04c..d08e47b15 100644 --- a/plugins/modules/azure_rm_ddos_protection_plan.py +++ b/plugins/modules/azure_rm_ddos_protection_plan.py @@ -56,9 +56,22 @@ ''' RETURN = ''' -sample: { - -} +state: + description: + - Current state of the DDoS protection plan. + returned: always + type: dict + sample: { + "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroup/myResourceGroup/providers/Microsoft.Network/ddosProtectionPlans/ddosplan", + "location": "eastus", + "name": "ddosplan", + "etag": "W/60ac0480-44dd-4881-a2ed-680d20b3978e", + "provisioning_state": "Succeeded", + "resource_guid": null, + "type": "Microsoft.Network/ddosProtectionPlans", + "tags": {"a": "b"}, + "virtual_networks": [] + } ''' from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common import AzureRMModuleBase @@ -95,8 +108,8 @@ def __init__(self): ) super(AzureDDoSProtectionPlan, self).__init__(self.module_arg_spec, - supports_check_mode=True, - supports_tags=True) + supports_check_mode=True, + supports_tags=True) def exec_module(self, **kwargs): @@ -196,9 +209,6 @@ def ddos_protection_plan_to_dict(item): # turn DDoS protection plan object into a dictionary (serialization) ddos_protection_plan = item.as_dict() - vnet = ddos_protection_plan.get('virtual_networks') - virtual_networks = [network for network in (vnet or [])] - result = dict( additional_properties=ddos_protection_plan.get('additional_properties', None), id=ddos_protection_plan.get('id', None), @@ -209,7 +219,7 @@ def ddos_protection_plan_to_dict(item): etag=ddos_protection_plan.get('etag', None), resource_guid=ddos_protection_plan.get('resource_guid', None), provisioning_state=ddos_protection_plan.get('provisioning_state', None), - virtual_networks=virtual_networks + virtual_networks=ddos_protection_plan.get('virtual_networks', None) ) return result diff --git a/plugins/modules/azure_rm_ddos_protection_plan_info.py b/plugins/modules/azure_rm_ddos_protection_plan_info.py index a8899acfd..ebe8bc6f9 100644 --- a/plugins/modules/azure_rm_ddos_protection_plan_info.py +++ b/plugins/modules/azure_rm_ddos_protection_plan_info.py @@ -19,7 +19,6 @@ resource_group: description: - The name of the resource group. - required: True type: str name: description: @@ -141,10 +140,6 @@ def ddos_protection_plan_to_dict(self, item): # turn DDoS protection plan object into a dictionary (serialization) ddos_protection_plan = item.as_dict() - vnet = ddos_protection_plan.get('virtual_networks') - print("vnet:", vnet) - virtual_networks = [network for network in (vnet or [])] - result = dict( additional_properties=ddos_protection_plan.get('additional_properties', None), id=ddos_protection_plan.get('id', None), @@ -155,7 +150,7 @@ def ddos_protection_plan_to_dict(self, item): etag=ddos_protection_plan.get('etag', None), resource_guid=ddos_protection_plan.get('resource_guid', None), provisioning_state=ddos_protection_plan.get('provisioning_state', None), - virtual_networks=virtual_networks + virtual_networks=ddos_protection_plan.get('virtual_networks', None) ) return result From 01de919c2799db8e36f5d889ae7e0001765bae77 Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Fri, 16 Apr 2021 17:44:37 +0530 Subject: [PATCH 07/24] add integration tests --- pr-pipelines.yml | 2 +- .../targets/azure_rm_ddos/meta/main.yml | 0 .../targets/azure_rm_ddos/tasks/main.yml | 0 .../aliases | 0 .../meta/main.yml | 2 + .../tasks/main.yml | 83 +++++++++++++++++++ 6 files changed, 86 insertions(+), 1 deletion(-) delete mode 100644 tests/integration/targets/azure_rm_ddos/meta/main.yml delete mode 100644 tests/integration/targets/azure_rm_ddos/tasks/main.yml rename tests/integration/targets/{azure_rm_ddos => azure_rm_ddos_protection_plan}/aliases (100%) create mode 100644 tests/integration/targets/azure_rm_ddos_protection_plan/meta/main.yml create mode 100644 tests/integration/targets/azure_rm_ddos_protection_plan/tasks/main.yml diff --git a/pr-pipelines.yml b/pr-pipelines.yml index 1af5a9dc8..29e2f8274 100644 --- a/pr-pipelines.yml +++ b/pr-pipelines.yml @@ -38,7 +38,7 @@ parameters: - "azure_rm_containerregistry" - "azure_rm_cosmosdbaccount" - "azure_rm_datalakestore" - - "azure_rm_ddos_operation_plan" + - "azure_rm_ddos_protection_plan" - "azure_rm_deployment" - "azure_rm_dnsrecordset" - "azure_rm_dnszone" diff --git a/tests/integration/targets/azure_rm_ddos/meta/main.yml b/tests/integration/targets/azure_rm_ddos/meta/main.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/integration/targets/azure_rm_ddos/tasks/main.yml b/tests/integration/targets/azure_rm_ddos/tasks/main.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/integration/targets/azure_rm_ddos/aliases b/tests/integration/targets/azure_rm_ddos_protection_plan/aliases similarity index 100% rename from tests/integration/targets/azure_rm_ddos/aliases rename to tests/integration/targets/azure_rm_ddos_protection_plan/aliases diff --git a/tests/integration/targets/azure_rm_ddos_protection_plan/meta/main.yml b/tests/integration/targets/azure_rm_ddos_protection_plan/meta/main.yml new file mode 100644 index 000000000..cf34ae763 --- /dev/null +++ b/tests/integration/targets/azure_rm_ddos_protection_plan/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_azure \ No newline at end of file diff --git a/tests/integration/targets/azure_rm_ddos_protection_plan/tasks/main.yml b/tests/integration/targets/azure_rm_ddos_protection_plan/tasks/main.yml new file mode 100644 index 000000000..a47bc9cd0 --- /dev/null +++ b/tests/integration/targets/azure_rm_ddos_protection_plan/tasks/main.yml @@ -0,0 +1,83 @@ +- name: Create random ddos protection plan + set_fact: + ddos_protection_plan: "test{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}" + +- name: Create DDoS protection plan (check mode) + azure_rm_ddos_protection_plan: + location: eastus2 + name: "{{ ddos_protection_plan }}" + resource_group: "{{ resource_group }}" + check_mode: yes + register: results + +- assert: + that: results.changed + +- name: Create DDoS protection plan + azure_rm_ddos_protection_plan: + location: eastus2 + name: "{{ ddos_protection_plan }}" + resource_group: "{{ resource_group }}" + register: results + +- assert: + that: results.changed + +- name: Update DDoS protection plan + azure_rm_ddos_protection_plan: + location: eastus2 + name: "{{ ddos_protection_plan }}" + resource_group: "{{ resource_group }}" + tags: + test: modified + register: results + +- assert: + that: + - results.changed + - results.state.tags.test == 'modified' + +- name: Retrieve DDoS protection plan + azure_rm_ddos_protection_plan_info: + location: eastus2 + name: "{{ ddos_protection_plan }}" + resource_group: "{{ resource_group }}" + register: results + +- name: Assert that facts module returned result + assert: + that: + - results.ddos_protection_plan[0].tags.test == 'modified' + +- name: Test idempotent + azure_rm_ddos_protection_plan_info: + location: eastus2 + name: "{{ ddos_protection_plan }}" + resource_group: "{{ resource_group }}" + register: results + +- assert: + that: + - not results.changed + +# +# azure_rm_ddos_protection_plan cleanup +# + +- name: Delete DDoS protection plan + azure_rm_ddos_protection_plan: + location: eastus2 + name: "{{ ddos_protection_plan }}" + resource_group: "{{ resource_group }}" + state: absent + +- name: Delete DDoS protection plan + azure_rm_ddos_protection_plan: + location: eastus2 + name: "{{ ddos_protection_plan }}" + resource_group: "{{ resource_group }}" + state: absent + register: results + +- assert: + that: not results.changed From 7d799ffdd005b645095b5917a01468f27453b947 Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Mon, 19 Apr 2021 16:00:06 +0530 Subject: [PATCH 08/24] add log parameters and aliases --- .../modules/azure_rm_ddos_protection_plan.py | 17 +++++++++++++++-- .../azure_rm_ddos_protection_plan/aliases | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/plugins/modules/azure_rm_ddos_protection_plan.py b/plugins/modules/azure_rm_ddos_protection_plan.py index d08e47b15..79da8283e 100644 --- a/plugins/modules/azure_rm_ddos_protection_plan.py +++ b/plugins/modules/azure_rm_ddos_protection_plan.py @@ -36,8 +36,17 @@ choices: - absent - present + log_path: + description: + - parent argument. + type: str + log_mode: + description: + - parent argument. + type: str extends_documentation_fragment: -- azure.azcollection.azure + - azure.azcollection.azure + - azure.azcollection.azure_tags author: - Praveen Ghuge (@praveenghuge) - Karl Dasan (@ikarldasan) @@ -94,7 +103,9 @@ def __init__(self): name=dict(type='str', required=True), location=dict(type='str'), state=dict(choices=['present', 'absent'], - default='present', type='str') + default='present', type='str'), + log_path=dict(type='str'), + log_mode=dict(type='str') ) self.resource_group = None @@ -102,6 +113,8 @@ def __init__(self): self.location = None self.state = None self.tags = None + self.log_path = None + self.log_mode = None self.results = dict( changed=False, state=dict() diff --git a/tests/integration/targets/azure_rm_ddos_protection_plan/aliases b/tests/integration/targets/azure_rm_ddos_protection_plan/aliases index e69de29bb..5cf25760d 100644 --- a/tests/integration/targets/azure_rm_ddos_protection_plan/aliases +++ b/tests/integration/targets/azure_rm_ddos_protection_plan/aliases @@ -0,0 +1,3 @@ +cloud/azure +shippable/azure/group10 +destructive \ No newline at end of file From 8106f4011abbc530a2fe546341d9cd51377de4f6 Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Mon, 19 Apr 2021 16:29:07 +0530 Subject: [PATCH 09/24] rename module for consistency --- ...plan.py => azure_rm_ddosprotectionplan.py} | 6 ++-- ...py => azure_rm_ddosprotectionplan_info.py} | 6 ++-- .../aliases | 0 .../meta/main.yml | 0 .../tasks/main.yml | 34 +++++++++---------- 5 files changed, 23 insertions(+), 23 deletions(-) rename plugins/modules/{azure_rm_ddos_protection_plan.py => azure_rm_ddosprotectionplan.py} (98%) rename plugins/modules/{azure_rm_ddos_protection_plan_info.py => azure_rm_ddosprotectionplan_info.py} (97%) rename tests/integration/targets/{azure_rm_ddos_protection_plan => azure_rm_ddosprotectionplan}/aliases (100%) rename tests/integration/targets/{azure_rm_ddos_protection_plan => azure_rm_ddosprotectionplan}/meta/main.yml (100%) rename tests/integration/targets/{azure_rm_ddos_protection_plan => azure_rm_ddosprotectionplan}/tasks/main.yml (63%) diff --git a/plugins/modules/azure_rm_ddos_protection_plan.py b/plugins/modules/azure_rm_ddosprotectionplan.py similarity index 98% rename from plugins/modules/azure_rm_ddos_protection_plan.py rename to plugins/modules/azure_rm_ddosprotectionplan.py index 79da8283e..ff417b723 100644 --- a/plugins/modules/azure_rm_ddos_protection_plan.py +++ b/plugins/modules/azure_rm_ddosprotectionplan.py @@ -7,7 +7,7 @@ __metaclass__ = type DOCUMENTATION = ''' --- -module: azure_rm_ddos_protection_plan +module: azure_rm_ddosprotectionplan version_added: "0.1.2" short_description: Manage DDoS protection plan description: @@ -53,12 +53,12 @@ ''' EXAMPLES = ''' - name: "Create DDoS protection plan" - azure_rm_ddos_protection_plan: + azure_rm_ddosprotectionplan: resource_group: rg location: eastus name: ddosplan - name: Delete DDoS protection plan - azure_rm_ddos_protection_plan: + azure_rm_ddosprotectionplan: resource_group: rg name: ddosplan state: absent diff --git a/plugins/modules/azure_rm_ddos_protection_plan_info.py b/plugins/modules/azure_rm_ddosprotectionplan_info.py similarity index 97% rename from plugins/modules/azure_rm_ddos_protection_plan_info.py rename to plugins/modules/azure_rm_ddosprotectionplan_info.py index ebe8bc6f9..4b4483816 100644 --- a/plugins/modules/azure_rm_ddos_protection_plan_info.py +++ b/plugins/modules/azure_rm_ddosprotectionplan_info.py @@ -11,7 +11,7 @@ DOCUMENTATION = ''' --- -module: azure_rm_ddos_protection_plan_info +module: azure_rm_ddosprotectionplan_info short_description: Get Azure DDoS protection plan description: - Get facts of Azure DDoS protection plan. @@ -34,7 +34,7 @@ EXAMPLES = ''' - name: Get facts of specific DDoS protection plan - community.azure.azure_rm_ddos_protection_plan_info: + azure_rm_ddosprotectionplan_info: resource_group: myResourceGroup name: myDDoSProtectionPlan ''' @@ -87,7 +87,7 @@ def exec_module(self, **kwargs): # all the DDoS protection plan listed in the subscription results = self.list_subscription() - self.results['ddos_protection_plan'] = [ + self.results['ddosprotectionplan'] = [ self.ddos_protection_plan_to_dict(x) for x in results] return self.results diff --git a/tests/integration/targets/azure_rm_ddos_protection_plan/aliases b/tests/integration/targets/azure_rm_ddosprotectionplan/aliases similarity index 100% rename from tests/integration/targets/azure_rm_ddos_protection_plan/aliases rename to tests/integration/targets/azure_rm_ddosprotectionplan/aliases diff --git a/tests/integration/targets/azure_rm_ddos_protection_plan/meta/main.yml b/tests/integration/targets/azure_rm_ddosprotectionplan/meta/main.yml similarity index 100% rename from tests/integration/targets/azure_rm_ddos_protection_plan/meta/main.yml rename to tests/integration/targets/azure_rm_ddosprotectionplan/meta/main.yml diff --git a/tests/integration/targets/azure_rm_ddos_protection_plan/tasks/main.yml b/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml similarity index 63% rename from tests/integration/targets/azure_rm_ddos_protection_plan/tasks/main.yml rename to tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml index a47bc9cd0..4076cf00f 100644 --- a/tests/integration/targets/azure_rm_ddos_protection_plan/tasks/main.yml +++ b/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml @@ -1,11 +1,11 @@ - name: Create random ddos protection plan set_fact: - ddos_protection_plan: "test{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}" + ddosprotectionplan: "test{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}" - name: Create DDoS protection plan (check mode) - azure_rm_ddos_protection_plan: + azure_rm_ddosprotectionplan: location: eastus2 - name: "{{ ddos_protection_plan }}" + name: "{{ ddosprotectionplan }}" resource_group: "{{ resource_group }}" check_mode: yes register: results @@ -14,9 +14,9 @@ that: results.changed - name: Create DDoS protection plan - azure_rm_ddos_protection_plan: + azure_rm_ddosprotectionplan: location: eastus2 - name: "{{ ddos_protection_plan }}" + name: "{{ ddosprotectionplan }}" resource_group: "{{ resource_group }}" register: results @@ -24,9 +24,9 @@ that: results.changed - name: Update DDoS protection plan - azure_rm_ddos_protection_plan: + azure_rm_ddosprotectionplan: location: eastus2 - name: "{{ ddos_protection_plan }}" + name: "{{ ddosprotectionplan }}" resource_group: "{{ resource_group }}" tags: test: modified @@ -38,21 +38,21 @@ - results.state.tags.test == 'modified' - name: Retrieve DDoS protection plan - azure_rm_ddos_protection_plan_info: + azure_rm_ddosprotectionplan_info: location: eastus2 - name: "{{ ddos_protection_plan }}" + name: "{{ ddosprotectionplan }}" resource_group: "{{ resource_group }}" register: results - name: Assert that facts module returned result assert: that: - - results.ddos_protection_plan[0].tags.test == 'modified' + - results.ddosprotectionplan[0].tags.test == 'modified' - name: Test idempotent - azure_rm_ddos_protection_plan_info: + azure_rm_ddosprotectionplan_info: location: eastus2 - name: "{{ ddos_protection_plan }}" + name: "{{ ddosprotectionplan }}" resource_group: "{{ resource_group }}" register: results @@ -61,20 +61,20 @@ - not results.changed # -# azure_rm_ddos_protection_plan cleanup +# azure_rm_ddosprotectionplan cleanup # - name: Delete DDoS protection plan - azure_rm_ddos_protection_plan: + azure_rm_ddosprotectionplan: location: eastus2 - name: "{{ ddos_protection_plan }}" + name: "{{ ddosprotectionplan }}" resource_group: "{{ resource_group }}" state: absent - name: Delete DDoS protection plan - azure_rm_ddos_protection_plan: + azure_rm_ddosprotectionplan: location: eastus2 - name: "{{ ddos_protection_plan }}" + name: "{{ ddosprotectionplan }}" resource_group: "{{ resource_group }}" state: absent register: results From 1ef76545d0a860a70e7fbbd8eb129cbaf4902d0c Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Mon, 19 Apr 2021 17:01:23 +0530 Subject: [PATCH 10/24] update pr-pipeline for consistency --- pr-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr-pipelines.yml b/pr-pipelines.yml index b253fad1f..fe1834d2f 100644 --- a/pr-pipelines.yml +++ b/pr-pipelines.yml @@ -39,7 +39,7 @@ parameters: - "azure_rm_containerregistry" - "azure_rm_cosmosdbaccount" - "azure_rm_datalakestore" - - "azure_rm_ddos_protection_plan" + - "azure_rm_ddosprotectionplan" - "azure_rm_deployment" - "azure_rm_dnsrecordset" - "azure_rm_dnszone" From c3e6d5967de9559407fee33a9ec9caac508bf5ab Mon Sep 17 00:00:00 2001 From: haiyuan_zhang Date: Fri, 7 May 2021 15:56:22 +0800 Subject: [PATCH 11/24] fixing update account_enabled bug in azure_rm_aduser.py (#524) --- plugins/modules/azure_rm_aduser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/azure_rm_aduser.py b/plugins/modules/azure_rm_aduser.py index 21808d6c2..28dd39bfd 100644 --- a/plugins/modules/azure_rm_aduser.py +++ b/plugins/modules/azure_rm_aduser.py @@ -310,7 +310,7 @@ def exec_module(self, **kwargs): should_update = True if should_update or self.user_type and ad_user.user_type != self.user_type: should_update = True - if should_update or self.account_enabled and ad_user.account_enabled != self.account_enabled: + if should_update or self.account_enabled is not None and ad_user.account_enabled != self.account_enabled: should_update = True if should_update or self.display_name and ad_user.display_name != self.display_name: should_update = True From 6fdfefe6270de2ad30c0ea9434907fe9a202e1bf Mon Sep 17 00:00:00 2001 From: haiyuan_zhang Date: Sat, 8 May 2021 03:03:55 +0800 Subject: [PATCH 12/24] fixing ad related auth issue when using service pricinpal. (#525) --- plugins/module_utils/azure_rm_common.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/module_utils/azure_rm_common.py b/plugins/module_utils/azure_rm_common.py index 95a823a4a..3c70d5294 100644 --- a/plugins/module_utils/azure_rm_common.py +++ b/plugins/module_utils/azure_rm_common.py @@ -1427,19 +1427,20 @@ def __init__(self, auth_source=None, profile=None, subscription_id=None, client_ else: self._adfs_authority_url = self.credentials.get('adfs_authority_url') - # get resource from cloud environment - self._resource = self._cloud_environment.endpoints.active_directory_resource_id - if self.credentials.get('credentials') is not None: # AzureCLI credentials self.azure_credentials = self.credentials['credentials'] elif self.credentials.get('client_id') is not None and \ self.credentials.get('secret') is not None and \ self.credentials.get('tenant') is not None: + + graph_resource = self._cloud_environment.endpoints.active_directory_graph_resource_id + rm_resource = self._cloud_environment.endpoints.resource_manager self.azure_credentials = ServicePrincipalCredentials(client_id=self.credentials['client_id'], secret=self.credentials['secret'], tenant=self.credentials['tenant'], cloud_environment=self._cloud_environment, + resource=graph_resource if self.is_ad_resource else rm_resource, verify=self._cert_validation_mode == 'validate') elif self.credentials.get('ad_user') is not None and \ @@ -1449,7 +1450,7 @@ def __init__(self, auth_source=None, profile=None, subscription_id=None, client_ self.azure_credentials = self.acquire_token_with_username_password( self._adfs_authority_url, - self._resource, + self._cloud_environment.endpoints.active_directory_resource_id, self.credentials['ad_user'], self.credentials['password'], self.credentials['client_id'], From 24b08f7979eddb9b6668b8b9039b1284938f2686 Mon Sep 17 00:00:00 2001 From: haiyuan_zhang Date: Sat, 8 May 2021 20:05:34 +0800 Subject: [PATCH 13/24] change class name of azure_rm_aduser (#526) * class are worngly named. fixed. * fixing sanity errors. --- plugins/modules/azure_rm_aduser.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/modules/azure_rm_aduser.py b/plugins/modules/azure_rm_aduser.py index 28dd39bfd..599b79aed 100644 --- a/plugins/modules/azure_rm_aduser.py +++ b/plugins/modules/azure_rm_aduser.py @@ -220,7 +220,7 @@ pass -class AzureRMADUserInfo(AzureRMModuleBase): +class AzureRMADUser(AzureRMModuleBase): def __init__(self): self.module_arg_spec = dict( @@ -271,13 +271,13 @@ def __init__(self): required_together = [['attribute_name', 'attribute_value']] required_one_of = [['odata_filter', 'attribute_name', 'object_id', 'user_principal_name']] - super(AzureRMADUserInfo, self).__init__(derived_arg_spec=self.module_arg_spec, - supports_check_mode=False, - supports_tags=False, - mutually_exclusive=mutually_exclusive, - required_together=required_together, - required_one_of=required_one_of, - is_ad_resource=True) + super(AzureRMADUser, self).__init__(derived_arg_spec=self.module_arg_spec, + supports_check_mode=False, + supports_tags=False, + mutually_exclusive=mutually_exclusive, + required_together=required_together, + required_one_of=required_one_of, + is_ad_resource=True) def exec_module(self, **kwargs): @@ -416,7 +416,7 @@ def to_dict(self, object): def main(): - AzureRMADUserInfo() + AzureRMADUser() if __name__ == '__main__': From 912b074bda85f010a7a34b4a2c29c41d3e835f4f Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Mon, 17 May 2021 20:23:26 +0530 Subject: [PATCH 14/24] updating ignore text --- tests/sanity/ignore-2.10.txt | 2 ++ tests/sanity/ignore-2.11.txt | 2 ++ tests/sanity/ignore-2.12.txt | 2 ++ tests/sanity/ignore-2.9.txt | 2 ++ 4 files changed, 8 insertions(+) diff --git a/tests/sanity/ignore-2.10.txt b/tests/sanity/ignore-2.10.txt index 5d1cda335..ffe7c947c 100644 --- a/tests/sanity/ignore-2.10.txt +++ b/tests/sanity/ignore-2.10.txt @@ -96,6 +96,8 @@ plugins/modules/azure_rm_datalakestore.py validate-modules:doc-elements-mismatch plugins/modules/azure_rm_datalakestore.py validate-modules:nonexistent-parameter-documented plugins/modules/azure_rm_datalakestore_info.py validate-modules:required_if-unknown-key plugins/modules/azure_rm_datalakestore_info.py validate-modules:required_if-requirements-unknown +plugins/modules/azure_rm_ddosprotectionplan_info.py validate-modules:required_if-requirements-unknown +plugins/modules/azure_rm_ddosprotectionplan_info.py validate-modules:required_if-unknown-key plugins/modules/azure_rm_deployment.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_deployment.py validate-modules:required_if-requirements-unknown plugins/modules/azure_rm_deployment.py validate-modules:required_if-unknown-key diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index 22f1d37c2..8382416f4 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -101,6 +101,8 @@ plugins/modules/azure_rm_datalakestore.py validate-modules:doc-elements-mismatch plugins/modules/azure_rm_datalakestore.py validate-modules:nonexistent-parameter-documented plugins/modules/azure_rm_datalakestore_info.py validate-modules:required_if-unknown-key plugins/modules/azure_rm_datalakestore_info.py validate-modules:required_if-requirements-unknown +plugins/modules/azure_rm_ddosprotectionplan_info.py validate-modules:required_if-requirements-unknown +plugins/modules/azure_rm_ddosprotectionplan_info.py validate-modules:required_if-unknown-key plugins/modules/azure_rm_deployment.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_deployment.py validate-modules:required_if-requirements-unknown plugins/modules/azure_rm_deployment.py validate-modules:required_if-unknown-key diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 147959000..ad0a3a085 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -100,6 +100,8 @@ plugins/modules/azure_rm_datalakestore.py validate-modules:doc-elements-mismatch plugins/modules/azure_rm_datalakestore.py validate-modules:nonexistent-parameter-documented plugins/modules/azure_rm_datalakestore_info.py validate-modules:required_if-unknown-key plugins/modules/azure_rm_datalakestore_info.py validate-modules:required_if-requirements-unknown +plugins/modules/azure_rm_ddosprotectionplan_info.py validate-modules:required_if-requirements-unknown +plugins/modules/azure_rm_ddosprotectionplan_info.py validate-modules:required_if-unknown-key plugins/modules/azure_rm_deployment.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_deployment.py validate-modules:required_if-requirements-unknown plugins/modules/azure_rm_deployment.py validate-modules:required_if-unknown-key diff --git a/tests/sanity/ignore-2.9.txt b/tests/sanity/ignore-2.9.txt index 6e9796e7c..5c18b4418 100644 --- a/tests/sanity/ignore-2.9.txt +++ b/tests/sanity/ignore-2.9.txt @@ -32,6 +32,8 @@ plugins/modules/azure_rm_containerregistrywebhook_info.py validate-modules:doc-d plugins/modules/azure_rm_containerregistrywebhook_info.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_containerregistrywebhook_info.py validate-modules:undocumented-parameter plugins/modules/azure_rm_datalakestore.py validate-modules:nonexistent-parameter-documented +plugins/modules/azure_rm_ddosprotectionplan_info.py validate-modules:required_if-requirements-unknown +plugins/modules/azure_rm_ddosprotectionplan_info.py validate-modules:required_if-unknown-key plugins/modules/azure_rm_deployment.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_deployment_info.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_dnsrecordset.py validate-modules:doc-missing-type From 22553b13eb742c6157e229b22a49df5ae5c71810 Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Fri, 28 May 2021 15:30:54 +0530 Subject: [PATCH 15/24] Update plugins/modules/azure_rm_ddosprotectionplan.py Co-authored-by: Fred-sun <37327967+Fred-sun@users.noreply.github.com> --- plugins/modules/azure_rm_ddosprotectionplan.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/modules/azure_rm_ddosprotectionplan.py b/plugins/modules/azure_rm_ddosprotectionplan.py index ff417b723..04e0c6751 100644 --- a/plugins/modules/azure_rm_ddosprotectionplan.py +++ b/plugins/modules/azure_rm_ddosprotectionplan.py @@ -114,7 +114,6 @@ def __init__(self): self.state = None self.tags = None self.log_path = None - self.log_mode = None self.results = dict( changed=False, state=dict() From 1b5cacc3c7c14b152a7e4ee1c6e1f31d39972ee2 Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Fri, 28 May 2021 15:31:04 +0530 Subject: [PATCH 16/24] Update plugins/modules/azure_rm_ddosprotectionplan.py Co-authored-by: Fred-sun <37327967+Fred-sun@users.noreply.github.com> --- plugins/modules/azure_rm_ddosprotectionplan.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/modules/azure_rm_ddosprotectionplan.py b/plugins/modules/azure_rm_ddosprotectionplan.py index 04e0c6751..e4f781699 100644 --- a/plugins/modules/azure_rm_ddosprotectionplan.py +++ b/plugins/modules/azure_rm_ddosprotectionplan.py @@ -104,7 +104,6 @@ def __init__(self): location=dict(type='str'), state=dict(choices=['present', 'absent'], default='present', type='str'), - log_path=dict(type='str'), log_mode=dict(type='str') ) From 6a2c4fedd040d1efde233b3b1432cbe6b336590f Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Fri, 28 May 2021 15:31:12 +0530 Subject: [PATCH 17/24] Update plugins/modules/azure_rm_ddosprotectionplan.py Co-authored-by: Fred-sun <37327967+Fred-sun@users.noreply.github.com> --- plugins/modules/azure_rm_ddosprotectionplan.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/modules/azure_rm_ddosprotectionplan.py b/plugins/modules/azure_rm_ddosprotectionplan.py index e4f781699..5679204db 100644 --- a/plugins/modules/azure_rm_ddosprotectionplan.py +++ b/plugins/modules/azure_rm_ddosprotectionplan.py @@ -104,7 +104,6 @@ def __init__(self): location=dict(type='str'), state=dict(choices=['present', 'absent'], default='present', type='str'), - log_mode=dict(type='str') ) self.resource_group = None From f5e43e0fdb81258678d9da624de579f543916321 Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Fri, 28 May 2021 15:31:18 +0530 Subject: [PATCH 18/24] Update tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml Co-authored-by: Fred-sun <37327967+Fred-sun@users.noreply.github.com> --- .../targets/azure_rm_ddosprotectionplan/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml b/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml index 4076cf00f..8fdb42a5f 100644 --- a/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml +++ b/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml @@ -7,7 +7,7 @@ location: eastus2 name: "{{ ddosprotectionplan }}" resource_group: "{{ resource_group }}" - check_mode: yes + check_mode: yes register: results - assert: From 76199fff9f6df129da17216032534b152369ec23 Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Fri, 28 May 2021 15:31:48 +0530 Subject: [PATCH 19/24] Update tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml Co-authored-by: Fred-sun <37327967+Fred-sun@users.noreply.github.com> --- .../targets/azure_rm_ddosprotectionplan/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml b/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml index 8fdb42a5f..6517c70df 100644 --- a/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml +++ b/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml @@ -50,7 +50,7 @@ - results.ddosprotectionplan[0].tags.test == 'modified' - name: Test idempotent - azure_rm_ddosprotectionplan_info: + azure_rm_ddosprotectionplan: location: eastus2 name: "{{ ddosprotectionplan }}" resource_group: "{{ resource_group }}" From b8e6bc1e43dbe2d8cb5404601b988718bc54621e Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Fri, 28 May 2021 15:34:22 +0530 Subject: [PATCH 20/24] Update main.yml --- .../targets/azure_rm_ddosprotectionplan/tasks/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml b/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml index 6517c70df..a61003680 100644 --- a/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml +++ b/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml @@ -39,7 +39,6 @@ - name: Retrieve DDoS protection plan azure_rm_ddosprotectionplan_info: - location: eastus2 name: "{{ ddosprotectionplan }}" resource_group: "{{ resource_group }}" register: results From 329623c458b7388b0c0b558fae0554cef3bbc510 Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Fri, 28 May 2021 15:48:37 +0530 Subject: [PATCH 21/24] delete ignores --- tests/sanity/ignore-2.10.txt | 2 -- tests/sanity/ignore-2.11.txt | 2 -- tests/sanity/ignore-2.12.txt | 2 -- tests/sanity/ignore-2.9.txt | 2 -- 4 files changed, 8 deletions(-) diff --git a/tests/sanity/ignore-2.10.txt b/tests/sanity/ignore-2.10.txt index 325a26029..bab631f4d 100644 --- a/tests/sanity/ignore-2.10.txt +++ b/tests/sanity/ignore-2.10.txt @@ -53,8 +53,6 @@ plugins/modules/azure_rm_datalakestore.py validate-modules:doc-elements-mismatch plugins/modules/azure_rm_datalakestore.py validate-modules:nonexistent-parameter-documented plugins/modules/azure_rm_datalakestore_info.py validate-modules:required_if-unknown-key plugins/modules/azure_rm_datalakestore_info.py validate-modules:required_if-requirements-unknown -plugins/modules/azure_rm_ddosprotectionplan_info.py validate-modules:required_if-requirements-unknown -plugins/modules/azure_rm_ddosprotectionplan_info.py validate-modules:required_if-unknown-key plugins/modules/azure_rm_deployment.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_deployment.py validate-modules:return-syntax-error plugins/modules/azure_rm_deployment_info.py validate-modules:parameter-type-not-in-doc diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index 2282f8588..be684fdc8 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -54,8 +54,6 @@ plugins/modules/azure_rm_datalakestore.py validate-modules:doc-elements-mismatch plugins/modules/azure_rm_datalakestore.py validate-modules:nonexistent-parameter-documented plugins/modules/azure_rm_datalakestore_info.py validate-modules:required_if-unknown-key plugins/modules/azure_rm_datalakestore_info.py validate-modules:required_if-requirements-unknown -plugins/modules/azure_rm_ddosprotectionplan_info.py validate-modules:required_if-requirements-unknown -plugins/modules/azure_rm_ddosprotectionplan_info.py validate-modules:required_if-unknown-key plugins/modules/azure_rm_deployment.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_deployment.py validate-modules:return-syntax-error plugins/modules/azure_rm_deployment_info.py validate-modules:parameter-type-not-in-doc diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 2c6be8613..33ac574dd 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -53,8 +53,6 @@ plugins/modules/azure_rm_datalakestore.py validate-modules:doc-elements-mismatch plugins/modules/azure_rm_datalakestore.py validate-modules:nonexistent-parameter-documented plugins/modules/azure_rm_datalakestore_info.py validate-modules:required_if-unknown-key plugins/modules/azure_rm_datalakestore_info.py validate-modules:required_if-requirements-unknown -plugins/modules/azure_rm_ddosprotectionplan_info.py validate-modules:required_if-requirements-unknown -plugins/modules/azure_rm_ddosprotectionplan_info.py validate-modules:required_if-unknown-key plugins/modules/azure_rm_deployment.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_deployment.py validate-modules:return-syntax-error plugins/modules/azure_rm_deployment_info.py validate-modules:parameter-type-not-in-doc diff --git a/tests/sanity/ignore-2.9.txt b/tests/sanity/ignore-2.9.txt index 5c18b4418..6e9796e7c 100644 --- a/tests/sanity/ignore-2.9.txt +++ b/tests/sanity/ignore-2.9.txt @@ -32,8 +32,6 @@ plugins/modules/azure_rm_containerregistrywebhook_info.py validate-modules:doc-d plugins/modules/azure_rm_containerregistrywebhook_info.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_containerregistrywebhook_info.py validate-modules:undocumented-parameter plugins/modules/azure_rm_datalakestore.py validate-modules:nonexistent-parameter-documented -plugins/modules/azure_rm_ddosprotectionplan_info.py validate-modules:required_if-requirements-unknown -plugins/modules/azure_rm_ddosprotectionplan_info.py validate-modules:required_if-unknown-key plugins/modules/azure_rm_deployment.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_deployment_info.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_dnsrecordset.py validate-modules:doc-missing-type From 75eb2362798ac452f29105df33b9e0ebf63ebe0a Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Fri, 28 May 2021 21:12:48 +0530 Subject: [PATCH 22/24] remove ignores --- tests/sanity/ignore-2.10.txt | 2 -- tests/sanity/ignore-2.11.txt | 2 -- tests/sanity/ignore-2.12.txt | 2 -- 3 files changed, 6 deletions(-) diff --git a/tests/sanity/ignore-2.10.txt b/tests/sanity/ignore-2.10.txt index bab631f4d..468c3e35c 100644 --- a/tests/sanity/ignore-2.10.txt +++ b/tests/sanity/ignore-2.10.txt @@ -51,8 +51,6 @@ plugins/modules/azure_rm_containerregistrywebhook_info.py validate-modules:retur plugins/modules/azure_rm_containerregistrywebhook_info.py validate-modules:undocumented-parameter plugins/modules/azure_rm_datalakestore.py validate-modules:doc-elements-mismatch plugins/modules/azure_rm_datalakestore.py validate-modules:nonexistent-parameter-documented -plugins/modules/azure_rm_datalakestore_info.py validate-modules:required_if-unknown-key -plugins/modules/azure_rm_datalakestore_info.py validate-modules:required_if-requirements-unknown plugins/modules/azure_rm_deployment.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_deployment.py validate-modules:return-syntax-error plugins/modules/azure_rm_deployment_info.py validate-modules:parameter-type-not-in-doc diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index be684fdc8..a8700c66f 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -52,8 +52,6 @@ plugins/modules/azure_rm_containerregistrywebhook_info.py validate-modules:undoc plugins/modules/azure_rm_containerregistrywebhook_info.py validate-modules:return-syntax-error plugins/modules/azure_rm_datalakestore.py validate-modules:doc-elements-mismatch plugins/modules/azure_rm_datalakestore.py validate-modules:nonexistent-parameter-documented -plugins/modules/azure_rm_datalakestore_info.py validate-modules:required_if-unknown-key -plugins/modules/azure_rm_datalakestore_info.py validate-modules:required_if-requirements-unknown plugins/modules/azure_rm_deployment.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_deployment.py validate-modules:return-syntax-error plugins/modules/azure_rm_deployment_info.py validate-modules:parameter-type-not-in-doc diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 33ac574dd..9c280ce48 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -51,8 +51,6 @@ plugins/modules/azure_rm_containerregistrywebhook_info.py validate-modules:undoc plugins/modules/azure_rm_containerregistrywebhook_info.py validate-modules:return-syntax-error plugins/modules/azure_rm_datalakestore.py validate-modules:doc-elements-mismatch plugins/modules/azure_rm_datalakestore.py validate-modules:nonexistent-parameter-documented -plugins/modules/azure_rm_datalakestore_info.py validate-modules:required_if-unknown-key -plugins/modules/azure_rm_datalakestore_info.py validate-modules:required_if-requirements-unknown plugins/modules/azure_rm_deployment.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_deployment.py validate-modules:return-syntax-error plugins/modules/azure_rm_deployment_info.py validate-modules:parameter-type-not-in-doc From f0b482e7ee5c51b6985a0fac897d0a35ca500dd0 Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Sat, 19 Jun 2021 14:00:16 +0530 Subject: [PATCH 23/24] Update plugins/modules/azure_rm_ddosprotectionplan.py Co-authored-by: Fred-sun <37327967+Fred-sun@users.noreply.github.com> --- plugins/modules/azure_rm_ddosprotectionplan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/azure_rm_ddosprotectionplan.py b/plugins/modules/azure_rm_ddosprotectionplan.py index 5679204db..0c78aef70 100644 --- a/plugins/modules/azure_rm_ddosprotectionplan.py +++ b/plugins/modules/azure_rm_ddosprotectionplan.py @@ -8,7 +8,7 @@ DOCUMENTATION = ''' --- module: azure_rm_ddosprotectionplan -version_added: "0.1.2" +version_added: "1.7.0" short_description: Manage DDoS protection plan description: - Create, update and delete instance of DDoS protection plan. From 13128f93d96067271093d525d53cbf8ece023eb5 Mon Sep 17 00:00:00 2001 From: Karl Dasan Date: Sat, 19 Jun 2021 14:00:31 +0530 Subject: [PATCH 24/24] Update plugins/modules/azure_rm_ddosprotectionplan_info.py Co-authored-by: Fred-sun <37327967+Fred-sun@users.noreply.github.com> --- plugins/modules/azure_rm_ddosprotectionplan_info.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/azure_rm_ddosprotectionplan_info.py b/plugins/modules/azure_rm_ddosprotectionplan_info.py index 4b4483816..489c99be7 100644 --- a/plugins/modules/azure_rm_ddosprotectionplan_info.py +++ b/plugins/modules/azure_rm_ddosprotectionplan_info.py @@ -12,6 +12,7 @@ DOCUMENTATION = ''' --- module: azure_rm_ddosprotectionplan_info +version_added: "1.7.0" short_description: Get Azure DDoS protection plan description: - Get facts of Azure DDoS protection plan.