From f9877fca182b45b3969bbdae87ea82dcfcc5ba77 Mon Sep 17 00:00:00 2001 From: Zim Kalinowski Date: Mon, 1 Apr 2019 13:05:45 +0800 Subject: [PATCH] Rename inconsistent azure_rm_virtualmachine_scaleset modules (#54579) @yungezz yes, i remember. pls keep in mind that they are not broken --- .../_azure_rm_virtualmachine_scaleset.py | 1 + ..._azure_rm_virtualmachine_scaleset_facts.py | 1 + ....py => azure_rm_virtualmachinescaleset.py} | 14 +++++--- ... azure_rm_virtualmachinescaleset_facts.py} | 17 ++++++--- .../targets/azure_rm_autoscale/tasks/main.yml | 4 +-- .../aliases | 2 +- .../meta/main.yml | 0 .../tasks/main.yml | 36 +++++++++---------- 8 files changed, 45 insertions(+), 30 deletions(-) create mode 120000 lib/ansible/modules/cloud/azure/_azure_rm_virtualmachine_scaleset.py create mode 120000 lib/ansible/modules/cloud/azure/_azure_rm_virtualmachine_scaleset_facts.py rename lib/ansible/modules/cloud/azure/{azure_rm_virtualmachine_scaleset.py => azure_rm_virtualmachinescaleset.py} (98%) rename lib/ansible/modules/cloud/azure/{azure_rm_virtualmachine_scaleset_facts.py => azure_rm_virtualmachinescaleset_facts.py} (95%) rename test/integration/targets/{azure_rm_virtualmachine_scaleset => azure_rm_virtualmachinescaleset}/aliases (82%) rename test/integration/targets/{azure_rm_virtualmachine_scaleset => azure_rm_virtualmachinescaleset}/meta/main.yml (100%) rename test/integration/targets/{azure_rm_virtualmachine_scaleset => azure_rm_virtualmachinescaleset}/tasks/main.yml (96%) diff --git a/lib/ansible/modules/cloud/azure/_azure_rm_virtualmachine_scaleset.py b/lib/ansible/modules/cloud/azure/_azure_rm_virtualmachine_scaleset.py new file mode 120000 index 0000000000..60840b6c26 --- /dev/null +++ b/lib/ansible/modules/cloud/azure/_azure_rm_virtualmachine_scaleset.py @@ -0,0 +1 @@ +azure_rm_virtualmachinescaleset.py \ No newline at end of file diff --git a/lib/ansible/modules/cloud/azure/_azure_rm_virtualmachine_scaleset_facts.py b/lib/ansible/modules/cloud/azure/_azure_rm_virtualmachine_scaleset_facts.py new file mode 120000 index 0000000000..6b61986e1f --- /dev/null +++ b/lib/ansible/modules/cloud/azure/_azure_rm_virtualmachine_scaleset_facts.py @@ -0,0 +1 @@ +azure_rm_virtualmachinescaleset_facts.py \ No newline at end of file diff --git a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset.py b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachinescaleset.py similarity index 98% rename from lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset.py rename to lib/ansible/modules/cloud/azure/azure_rm_virtualmachinescaleset.py index ea5038fc77..7c5979623b 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachinescaleset.py @@ -15,7 +15,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1', DOCUMENTATION = ''' --- -module: azure_rm_virtualmachine_scaleset +module: azure_rm_virtualmachinescaleset version_added: "2.4" @@ -24,6 +24,9 @@ short_description: Manage Azure virtual machine scale sets. description: - Create and update a virtual machine scale set. +notes: + - This module was called C(azure_rm_virtualmachine_scaleset) before Ansible 2.8. The usage did not change. + options: resource_group: description: @@ -226,7 +229,7 @@ author: EXAMPLES = ''' - name: Create VMSS - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: myResourceGroup name: testvmss vm_size: Standard_DS1_v2 @@ -251,7 +254,7 @@ EXAMPLES = ''' managed_disk_type: Standard_LRS - name: Create a VMSS with a custom image - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: myResourceGroup name: testvmss vm_size: Standard_DS1_v2 @@ -264,7 +267,7 @@ EXAMPLES = ''' image: customimage001 - name: Create a VMSS with a custom image from a particular resource group - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: myResourceGroup name: testvmss vm_size: Standard_DS1_v2 @@ -481,6 +484,9 @@ class AzureRMVirtualMachineScaleSet(AzureRMModuleBase): for key in list(self.module_arg_spec.keys()) + ['tags']: setattr(self, key, kwargs[key]) + if self.module._name == 'azure_rm_virtualmachine_scaleset': + self.module.deprecate("The 'azure_rm_virtualmachine_scaleset' module has been renamed to 'azure_rm_virtualmachinescaleset'", version='2.12') + # make sure options are lower case self.remove_on_absent = set([resource.lower() for resource in self.remove_on_absent]) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset_facts.py b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachinescaleset_facts.py similarity index 95% rename from lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset_facts.py rename to lib/ansible/modules/cloud/azure/azure_rm_virtualmachinescaleset_facts.py index 94b360a504..b39b73030b 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset_facts.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachinescaleset_facts.py @@ -13,7 +13,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1', DOCUMENTATION = ''' --- -module: azure_rm_virtualmachine_scaleset_facts +module: azure_rm_virtualmachinescaleset_facts version_added: "2.4" @@ -22,6 +22,9 @@ short_description: Get Virtual Machine Scale Set facts description: - Get facts for a virtual machine scale set +notes: + - This module was called C(azure_rm_virtualmachine_scaleset_facts) before Ansible 2.8. The usage did not change. + options: name: description: @@ -36,7 +39,7 @@ options: description: - Format of the data returned. - If C(raw) is selected information will be returned in raw format from Azure Python SDK. - - If C(curated) is selected the structure will be identical to input parameters of azure_rm_virtualmachine_scaleset module. + - If C(curated) is selected the structure will be identical to input parameters of azure_rm_virtualmachinescaleset module. - In Ansible 2.5 and lower facts are always returned in raw format. - Please note that this option will be deprecated in 2.10 when curated format will become the only supported format. default: 'raw' @@ -54,17 +57,17 @@ author: EXAMPLES = ''' - name: Get facts for a virtual machine scale set - azure_rm_virtualmachine_scaleset_facts: + azure_rm_virtualmachinescaleset_facts: resource_group: myResourceGroup name: testvmss001 format: curated - name: Get facts for all virtual networks - azure_rm_virtualmachine_scaleset_facts: + azure_rm_virtualmachinescaleset_facts: resource_group: myResourceGroup - name: Get facts by tags - azure_rm_virtualmachine_scaleset_facts: + azure_rm_virtualmachinescaleset_facts: resource_group: myResourceGroup tags: - testing @@ -289,6 +292,10 @@ class AzureRMVirtualMachineScaleSetFacts(AzureRMModuleBase): for key in self.module_args: setattr(self, key, kwargs[key]) + if self.module._name == 'azure_rm_virtualmachine_scaleset_facts': + self.module.deprecate("The 'azure_rm_virtualmachine_scaleset_facts' module has been renamed to 'azure_rm_virtualmachinescaleset_facts'", + version='2.12') + if self.name and not self.resource_group: self.fail("Parameter error: resource group required when filtering by name.") if self.name: diff --git a/test/integration/targets/azure_rm_autoscale/tasks/main.yml b/test/integration/targets/azure_rm_autoscale/tasks/main.yml index af769c99bd..9d3b54a3ee 100644 --- a/test/integration/targets/azure_rm_autoscale/tasks/main.yml +++ b/test/integration/targets/azure_rm_autoscale/tasks/main.yml @@ -18,7 +18,7 @@ virtual_network: testVnet - name: Create VMSS - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: "{{ resource_group }}" name: testVMSS{{ rpfx }} vm_size: Standard_DS1_v2 @@ -199,7 +199,7 @@ - not output.changed - name: Clean VMSS - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: "{{ resource_group }}" vm_size: Standard_DS1_v2 name: testVMSS{{ rpfx }} diff --git a/test/integration/targets/azure_rm_virtualmachine_scaleset/aliases b/test/integration/targets/azure_rm_virtualmachinescaleset/aliases similarity index 82% rename from test/integration/targets/azure_rm_virtualmachine_scaleset/aliases rename to test/integration/targets/azure_rm_virtualmachinescaleset/aliases index 2b74583e9a..6761f3ec37 100644 --- a/test/integration/targets/azure_rm_virtualmachine_scaleset/aliases +++ b/test/integration/targets/azure_rm_virtualmachinescaleset/aliases @@ -1,7 +1,7 @@ cloud/azure shippable/azure/group4 destructive -azure_rm_virtualmachine_scaleset_facts +azure_rm_virtualmachinescaleset_facts azure_rm_virtualmachinescalesetinstance_facts azure_rm_virtualmachinescalesetextension azure_rm_virtualmachinescalesetextension_facts diff --git a/test/integration/targets/azure_rm_virtualmachine_scaleset/meta/main.yml b/test/integration/targets/azure_rm_virtualmachinescaleset/meta/main.yml similarity index 100% rename from test/integration/targets/azure_rm_virtualmachine_scaleset/meta/main.yml rename to test/integration/targets/azure_rm_virtualmachinescaleset/meta/main.yml diff --git a/test/integration/targets/azure_rm_virtualmachine_scaleset/tasks/main.yml b/test/integration/targets/azure_rm_virtualmachinescaleset/tasks/main.yml similarity index 96% rename from test/integration/targets/azure_rm_virtualmachine_scaleset/tasks/main.yml rename to test/integration/targets/azure_rm_virtualmachinescaleset/tasks/main.yml index 2ce0fbc1bf..900b60df85 100644 --- a/test/integration/targets/azure_rm_virtualmachine_scaleset/tasks/main.yml +++ b/test/integration/targets/azure_rm_virtualmachinescaleset/tasks/main.yml @@ -92,7 +92,7 @@ state: absent - name: Create VMSS (check mode) - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: "{{ resource_group }}" name: testVMSS{{ rpfx }} vm_size: Standard_B1s @@ -125,7 +125,7 @@ that: results.changed - name: Get VMSS to assert no VMSS is created in check mode - azure_rm_virtualmachine_scaleset_facts: + azure_rm_virtualmachinescaleset_facts: resource_group: "{{ resource_group }}" name: testVMSS{{ rpfx }} format: curated @@ -137,7 +137,7 @@ - output_scaleset.ansible_facts.azure_vmss | length == 0 - name: Create VMSS - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: "{{ resource_group }}" name: testVMSS{{ rpfx }} vm_size: Standard_B1s @@ -170,7 +170,7 @@ that: results.changed - name: Create VMSS -- test upgrade_policy idempotence and load balancer - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: "{{ resource_group }}" name: testVMSS{{ rpfx }} vm_size: Standard_B1s @@ -203,7 +203,7 @@ that: results.changed - name: Retrieve scaleset facts - azure_rm_virtualmachine_scaleset_facts: + azure_rm_virtualmachinescaleset_facts: resource_group: "{{ resource_group }}" name: testVMSS{{ rpfx }} format: curated @@ -236,7 +236,7 @@ body: "{{ output_scaleset.vmss[0] }}" - name: Try to update VMSS using output as input - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: "{{ body.resource_group }}" name: "{{ body.name }}" vm_size: "{{ body.vm_size }}" @@ -382,13 +382,13 @@ - name: Delete VMSS - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: "{{ resource_group }}" name: testVMSS{{ rpfx }} state: absent - name: Create VMSS with security group in same resource group, with accelerated networking(check mode). - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: "{{ resource_group }}" name: testVMSS{{ rpfx }}2 vm_size: Standard_D3_v2 @@ -412,7 +412,7 @@ that: results.changed - name: Create VMSS with security group in same resource group, with accelerated networking. - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: "{{ resource_group }}" name: testVMSS{{ rpfx }}2 vm_size: Standard_D3_v2 @@ -438,7 +438,7 @@ - 'results.ansible_facts.azure_vmss.properties.virtualMachineProfile.networkProfile.networkInterfaceConfigurations.0.properties.networkSecurityGroup != {}' - name: Create VMSS with security group in same resource group, with accelerated networking. - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: "{{ resource_group }}" name: testVMSS{{ rpfx }}2 vm_size: Standard_D3_v2 @@ -462,7 +462,7 @@ - not results.changed - name: Create VMSS with security group in same resource group, with accelerated networking. - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: "{{ resource_group }}" name: testVMSS{{ rpfx }}2 vm_size: Standard_D3_v2 @@ -486,7 +486,7 @@ - results.changed - name: update VMSS with security group in different resource group. - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: "{{ resource_group }}" name: testVMSS{{ rpfx }}2 vm_size: Standard_B1s @@ -513,13 +513,13 @@ # - '"testNetworkSecurityGroup2" in results.ansible_facts.azure_vmss.properties.virtualMachineProfile.networkProfile.networkInterfaceConfigurations.0.properties.networkSecurityGroup.id' - name: Delete VMSS - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: "{{ resource_group }}" name: testVMSS{{ rpfx }}2 state: absent - name: Fail when instance type is not supported to enable accelerated networking - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: "{{ resource_group }}" name: testVMSS{{ rpfx }}4 vm_size: Standard_B1s @@ -577,7 +577,7 @@ # TODO: Until we have a module to create/delete images this is the best tests # I can do - name: assert error thrown with invalid image dict - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: "{{ resource_group }}" name: testvm002 vm_size: Standard_B1s @@ -587,7 +587,7 @@ failed_when: 'fail_invalid_image_dict.msg != "parameter error: expecting image to contain [publisher, offer, sku, version] or [name, resource_group]"' - name: assert error thrown with invalid image type - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: "{{ resource_group }}" name: testvm002 vm_size: Standard_B1s @@ -597,7 +597,7 @@ failed_when: 'fail_invalid_image_type.msg != "parameter error: expecting image to be a string or dict not list"' - name: assert error finding missing custom image - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: "{{ resource_group }}" name: testvm002 vm_size: Standard_B1s @@ -606,7 +606,7 @@ failed_when: fail_missing_custom_image.msg != "Error could not find image with name invalid-image" - name: assert error finding missing custom image (dict style) - azure_rm_virtualmachine_scaleset: + azure_rm_virtualmachinescaleset: resource_group: "{{ resource_group }}" name: testvm002 vm_size: Standard_B1s