From 790324258858b8e92f61a4f06f5e5436b2fe6e75 Mon Sep 17 00:00:00 2001 From: Fred-sun Date: Thu, 10 Jun 2021 20:13:49 +0800 Subject: [PATCH 1/3] Add new feature storage_profile --- plugins/modules/azure_rm_mysqlserver.py | 77 ++++++++++++++++--- plugins/modules/azure_rm_mysqlserver_info.py | 44 +++++++---- .../azure_rm_mysqlserver/tasks/main.yml | 38 +++++++-- 3 files changed, 130 insertions(+), 29 deletions(-) diff --git a/plugins/modules/azure_rm_mysqlserver.py b/plugins/modules/azure_rm_mysqlserver.py index ebd2aef00..015bd8163 100644 --- a/plugins/modules/azure_rm_mysqlserver.py +++ b/plugins/modules/azure_rm_mysqlserver.py @@ -21,39 +21,71 @@ description: - The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. required: True + type: str name: description: - The name of the server. required: True + type: str sku: description: - The SKU (pricing tier) of the server. + type: dict suboptions: name: description: - The name of the sku, typically, tier + family + cores, for example C(B_Gen4_1), C(GP_Gen5_8). + type: str tier: description: - The tier of the particular SKU, for example C(Basic). + type: str choices: - basic - standard capacity: description: - The scale up/out capacity, representing server's compute units. + type: str size: description: - The size code, to be interpreted by resource as appropriate. + type: int location: description: - Resource location. If not set, location from the resource group will be used as default. - storage_mb: + type: str + storage_profile: description: - - The maximum storage allowed for a server. - type: int + - Storage Profile properties of a server. + type: dict + suboptions: + storage_mb: + description: + - The maximum storage allowed for a server. + type: int + backup_retention_days: + description: + - Backup retention days for the server + type: int + geo_redundant_backup: + description: + - Enable Geo-redundant or not for server backup. + type: str + choices: + - Disabled + - Enabled + storage_autogrow: + description: + - Enable Storage Auto Grow. + type: str + choices: + - Disabled + - Enabled version: description: - Server version. + type: str choices: - 5.6 - 5.7 @@ -65,18 +97,23 @@ default: False admin_username: description: - - The administrator's login name of a server. Can only be specified when the server is being created (and is required for creation). + - The administrator's login name of a server. + - Can only be specified when the server is being created (and is required for creation). + type: str admin_password: description: - The password of the administrator login. + type: str create_mode: description: - Create mode of SQL Server. default: Default + type: str state: description: - Assert the state of the MySQL Server. Use C(present) to create or update a server and C(absent) to delete it. default: present + type: str choices: - absent - present @@ -99,7 +136,11 @@ name: B_Gen5_1 tier: Basic location: eastus - storage_mb: 1024 + storage_profile: + storage_mb: 51200 + backup_retention_days: 7 + geo_redundant_backup: Disabled + storage_autogrow: Disabled enforce_ssl: True version: 5.6 admin_username: cloudsa @@ -145,6 +186,23 @@ # This is handled in azure_rm_common pass +storage_profile_spec = dict( + storage_mb=dict( + type='int' + ), + backup_retention_days=dict( + type='int' + ), + geo_redundant_backup=dict( + type='str', + choices=['Disabled', 'Enabled'] + ), + storage_autogrow=dict( + type='str', + choices=['Disabled', 'Enabled'] + ) +) + class Actions: NoAction, Create, Update, Delete = range(4) @@ -169,8 +227,9 @@ def __init__(self): location=dict( type='str' ), - storage_mb=dict( - type='int' + storage_profile=dict( + type='dict', + options=storage_profile_spec ), version=dict( type='str', @@ -228,8 +287,8 @@ def exec_module(self, **kwargs): self.parameters["sku"] = ev elif key == "location": self.parameters["location"] = kwargs[key] - elif key == "storage_mb": - self.parameters.setdefault("properties", {}).setdefault("storage_profile", {})["storage_mb"] = kwargs[key] + elif key == "storage_profile": + self.parameters.setdefault("properties", {})["storage_profile"] = kwargs[key] elif key == "version": self.parameters.setdefault("properties", {})["version"] = kwargs[key] elif key == "enforce_ssl": diff --git a/plugins/modules/azure_rm_mysqlserver_info.py b/plugins/modules/azure_rm_mysqlserver_info.py index 0d404456c..eeb0b8b46 100644 --- a/plugins/modules/azure_rm_mysqlserver_info.py +++ b/plugins/modules/azure_rm_mysqlserver_info.py @@ -26,13 +26,10 @@ description: - The name of the server. type: str - tags: - description: - - Limit results by providing a list of tags. Format tags as 'key' or 'key:value'. - type: list extends_documentation_fragment: - azure.azcollection.azure + - azure.azcollection.azure_tags author: - Zim Kalinowski (@zikalino) @@ -105,12 +102,36 @@ returned: always type: int sample: 2 - storage_mb: + storage_profile: description: - - The maximum storage allowed for a server. + - Storage Profile properties of a server. + type: complex returned: always - type: int - sample: 128000 + contains: + storage_mb: + description: + - The maximum storage allowed for a server. + returned: always + type: int + sample: 128000 + backup_retention_days: + description: + - Backup retention days for the server + returned: always + type: int + sample: 7 + geo_redundant_backup: + description: + - Enable Geo-redundant or not for server backup. + returned: always + type: str + sample: Disabled + storage_autogrow: + description: + - Enable Storage Auto Grow. + returned: always + type: str + sample: Disabled enforce_ssl: description: - Enable SSL enforcement. @@ -168,9 +189,6 @@ def __init__(self): ), name=dict( type='str' - ), - tags=dict( - type='list' ) ) # store the results of the module operation @@ -180,7 +198,7 @@ def __init__(self): self.resource_group = None self.name = None self.tags = None - super(AzureRMMySqlServerInfo, self).__init__(self.module_arg_spec, supports_tags=False) + super(AzureRMMySqlServerInfo, self).__init__(self.module_arg_spec, supports_tags=True) def exec_module(self, **kwargs): is_old_facts = self.module._name == 'azure_rm_mysqlserver_facts' @@ -236,7 +254,7 @@ def format_item(self, item): 'name': d['name'], 'sku': d['sku'], 'location': d['location'], - 'storage_mb': d['storage_profile']['storage_mb'], + 'storage_profile': d['storage_profile'], 'version': d['version'], 'enforce_ssl': (d['ssl_enforcement'] == 'Enabled'), 'admin_username': d['administrator_login'], diff --git a/tests/integration/targets/azure_rm_mysqlserver/tasks/main.yml b/tests/integration/targets/azure_rm_mysqlserver/tasks/main.yml index 123778e97..ba562738b 100644 --- a/tests/integration/targets/azure_rm_mysqlserver/tasks/main.yml +++ b/tests/integration/targets/azure_rm_mysqlserver/tasks/main.yml @@ -11,7 +11,11 @@ name: B_Gen5_1 tier: Basic location: westus2 - storage_mb: 51200 + storage_profile: + storage_mb: 51200 + backup_retention_days: 7 + geo_redundant_backup: Disabled + storage_autogrow: Disabled version: 5.6 enforce_ssl: True admin_username: zimxyz @@ -31,7 +35,11 @@ name: B_Gen5_1 tier: Basic location: westus2 - storage_mb: 51200 + storage_profile: + storage_mb: 51200 + backup_retention_days: 7 + geo_redundant_backup: Disabled + storage_autogrow: Disabled version: 5.6 enforce_ssl: True admin_username: zimxyz @@ -51,7 +59,11 @@ name: B_Gen5_1 tier: Basic location: westus2 - storage_mb: 51200 + storage_profile: + storage_mb: 51200 + backup_retention_days: 7 + geo_redundant_backup: Disabled + storage_autogrow: Disabled version: 5.6 enforce_ssl: True admin_username: zimxyz @@ -71,7 +83,11 @@ name: B_Gen5_1 tier: Basic location: westus2 - storage_mb: 128000 + storage_profile: + storage_mb: 128000 + backup_retention_days: 7 + geo_redundant_backup: Disabled + storage_autogrow: Disabled version: 5.6 enforce_ssl: True admin_username: zimxyz @@ -93,7 +109,7 @@ - name: Assert that storage size is correct assert: that: - - output.servers[0]['storage_mb'] == 128000 + - output.servers[0]['storage_profile']['storage_mb'] == 128000 - name: Create second instance of MySQL Server azure_rm_mysqlserver: @@ -103,7 +119,11 @@ name: B_Gen5_1 tier: Basic location: westus2 - storage_mb: 51200 + storage_profile: + storage_mb: 51200 + backup_retention_days: 7 + geo_redundant_backup: Disabled + storage_autogrow: Disabled version: 5.6 enforce_ssl: True admin_username: zimxyz @@ -119,7 +139,11 @@ name: B_Gen5_1 tier: Basic location: westus2 - storage_mb: 51200 + storage_profile: + storage_mb: 51200 + backup_retention_days: 7 + geo_redundant_backup: Disabled + storage_autogrow: Disabled version: 5.6 enforce_ssl: True admin_username: zimxyz From 0e358a29b8f3b61beaacc44409e390911b45dad2 Mon Sep 17 00:00:00 2001 From: Fred-sun Date: Thu, 10 Jun 2021 20:36:21 +0800 Subject: [PATCH 2/3] remove ignore --- plugins/modules/azure_rm_apimanagementservice.py | 4 ++-- 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 | 1 - 5 files changed, 2 insertions(+), 9 deletions(-) diff --git a/plugins/modules/azure_rm_apimanagementservice.py b/plugins/modules/azure_rm_apimanagementservice.py index 55b192c78..0c2860191 100644 --- a/plugins/modules/azure_rm_apimanagementservice.py +++ b/plugins/modules/azure_rm_apimanagementservice.py @@ -65,8 +65,8 @@ - present extends_documentation_fragment: - - azure - - azure_tags + - azure.azcollection.azure + - azure.azcollection.azure_tags author: - Nikhil Patne (@nikhilpatne) - Sakar Mehra (@sakar97) diff --git a/tests/sanity/ignore-2.10.txt b/tests/sanity/ignore-2.10.txt index 468c3e35c..e46a4d657 100644 --- a/tests/sanity/ignore-2.10.txt +++ b/tests/sanity/ignore-2.10.txt @@ -243,8 +243,6 @@ plugins/modules/azure_rm_mysqlconfiguration_info.py validate-modules:return-synt plugins/modules/azure_rm_mysqldatabase.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_mysqlfirewallrule.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_mysqlfirewallrule.py validate-modules:doc-required-mismatch -plugins/modules/azure_rm_mysqlserver.py validate-modules:parameter-type-not-in-doc -plugins/modules/azure_rm_mysqlserver_info.py validate-modules:parameter-list-no-elements plugins/modules/azure_rm_postgresqlconfiguration.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_postgresqlconfiguration_info.py validate-modules:return-syntax-error plugins/modules/azure_rm_postgresqldatabase.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 a8700c66f..fd8114888 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -244,8 +244,6 @@ plugins/modules/azure_rm_mysqlconfiguration_info.py validate-modules:return-synt plugins/modules/azure_rm_mysqldatabase.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_mysqlfirewallrule.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_mysqlfirewallrule.py validate-modules:doc-required-mismatch -plugins/modules/azure_rm_mysqlserver.py validate-modules:parameter-type-not-in-doc -plugins/modules/azure_rm_mysqlserver_info.py validate-modules:parameter-list-no-elements plugins/modules/azure_rm_postgresqlconfiguration.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_postgresqlconfiguration_info.py validate-modules:return-syntax-error plugins/modules/azure_rm_postgresqldatabase.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 9c280ce48..80d3982d7 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -246,8 +246,6 @@ plugins/modules/azure_rm_mysqlconfiguration_info.py validate-modules:return-synt plugins/modules/azure_rm_mysqldatabase.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_mysqlfirewallrule.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_mysqlfirewallrule.py validate-modules:doc-required-mismatch -plugins/modules/azure_rm_mysqlserver.py validate-modules:parameter-type-not-in-doc -plugins/modules/azure_rm_mysqlserver_info.py validate-modules:parameter-list-no-elements plugins/modules/azure_rm_postgresqlconfiguration.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_postgresqlconfiguration_info.py validate-modules:return-syntax-error plugins/modules/azure_rm_postgresqldatabase.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 6e9796e7c..bbb7a717c 100644 --- a/tests/sanity/ignore-2.9.txt +++ b/tests/sanity/ignore-2.9.txt @@ -113,7 +113,6 @@ plugins/modules/azure_rm_mariadbserver.py validate-modules:parameter-type-not-in plugins/modules/azure_rm_mysqlconfiguration.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_mysqldatabase.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_mysqlfirewallrule.py validate-modules:parameter-type-not-in-doc -plugins/modules/azure_rm_mysqlserver.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_postgresqlconfiguration.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_postgresqldatabase.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_postgresqlfirewallrule.py validate-modules:parameter-type-not-in-doc From e7e8cd1bf4d4d2060f3c17a3d5d447be808346ec Mon Sep 17 00:00:00 2001 From: Fred-sun Date: Thu, 10 Jun 2021 20:54:12 +0800 Subject: [PATCH 3/3] remove ignore 02 --- tests/sanity/ignore-2.9.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/sanity/ignore-2.9.txt b/tests/sanity/ignore-2.9.txt index bbb7a717c..9f4ab1965 100644 --- a/tests/sanity/ignore-2.9.txt +++ b/tests/sanity/ignore-2.9.txt @@ -165,7 +165,6 @@ plugins/modules/azure_rm_cdnprofile.py validate-modules:parameter-type-not-in-do plugins/modules/azure_rm_cosmosdbaccount.py validate-modules:nonexistent-parameter-documented plugins/modules/azure_rm_cosmosdbaccount_info.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_devtestlabschedule.py validate-modules:parameter-type-not-in-doc -plugins/modules/azure_rm_apimanagementservice.py validate-modules:doc-default-does-not-match-spec plugins/modules/azure_rm_hdinsightcluster_info.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_loadbalancer_info.py validate-modules:parameter-type-not-in-doc plugins/modules/azure_rm_loganalyticsworkspace_info.py validate-modules:parameter-type-not-in-doc