special case for rest module (#54236)

This commit is contained in:
Zim Kalinowski 2019-03-25 11:55:43 +08:00 committed by GitHub
parent 0ec2d71b4a
commit 19e1b4de58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View file

@ -272,6 +272,9 @@ class AzureRMResource(AzureRMModuleBase):
if rt['resourceType'].lower() == resourceType.lower(): if rt['resourceType'].lower() == resourceType.lower():
self.api_version = rt['apiVersions'][0] self.api_version = rt['apiVersions'][0]
break break
else:
# if there's no provider in API version, assume Microsoft.Resources
self.api_version = '2018-05-01'
if not self.api_version: if not self.api_version:
self.fail("Couldn't find api version for {0}/{1}".format(provider, resourceType)) self.fail("Couldn't find api version for {0}/{1}".format(provider, resourceType))
except Exception as exc: except Exception as exc:

View file

@ -73,6 +73,11 @@ EXAMPLES = '''
resource_type: virtualmachinescalesets resource_type: virtualmachinescalesets
resource_name: myVmss resource_name: myVmss
api_version: "2017-12-01" api_version: "2017-12-01"
- name: Query all the resources in the resource group
azure_rm_resource_facts:
resource_group: "{{ resource_group }}"
resource_type: resources
''' '''
RETURN = ''' RETURN = '''
@ -187,6 +192,9 @@ class AzureRMResourceFacts(AzureRMModuleBase):
if rt['resourceType'].lower() == resourceType.lower(): if rt['resourceType'].lower() == resourceType.lower():
self.api_version = rt['apiVersions'][0] self.api_version = rt['apiVersions'][0]
break break
else:
# if there's no provider in API version, assume Microsoft.Resources
self.api_version = '2018-05-01'
if not self.api_version: if not self.api_version:
self.fail("Couldn't find api version for {0}/{1}".format(provider, resourceType)) self.fail("Couldn't find api version for {0}/{1}".format(provider, resourceType))
except Exception as exc: except Exception as exc:

View file

@ -99,6 +99,17 @@
- output.response[0]['name'] != None - output.response[0]['name'] != None
- output.response | length >= 1 - output.response | length >= 1
- name: Query all the resources in the resource group
azure_rm_resource_facts:
resource_group: "{{ resource_group }}"
resource_type: resources
register: output
- name: Assert value was returned
assert:
that:
- not output.changed
- output.response | length >= 1
- name: Create storage account that requires LRO polling - name: Create storage account that requires LRO polling
azure_rm_resource: azure_rm_resource:
polling_timeout: 600 polling_timeout: 600