summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZim Kalinowski <zikalino@microsoft.com>2019-03-25 11:55:43 +0800
committerGitHub <noreply@github.com>2019-03-25 11:55:43 +0800
commit19e1b4de58ef556857defa976338df2344d6783d (patch)
tree4b61169990cb63221d5e459108a63fc02e697e92
parent0ec2d71b4a5ecd882b24bcd9498208b269d3a403 (diff)
downloadansible-19e1b4de58ef556857defa976338df2344d6783d.tar.gz
special case for rest module (#54236)
-rw-r--r--lib/ansible/modules/cloud/azure/azure_rm_resource.py3
-rw-r--r--lib/ansible/modules/cloud/azure/azure_rm_resource_facts.py8
-rw-r--r--test/integration/targets/azure_rm_resource/tasks/main.yml11
3 files changed, 22 insertions, 0 deletions
diff --git a/lib/ansible/modules/cloud/azure/azure_rm_resource.py b/lib/ansible/modules/cloud/azure/azure_rm_resource.py
index 6ef23fce1f..4407a63c20 100644
--- a/lib/ansible/modules/cloud/azure/azure_rm_resource.py
+++ b/lib/ansible/modules/cloud/azure/azure_rm_resource.py
@@ -272,6 +272,9 @@ class AzureRMResource(AzureRMModuleBase):
if rt['resourceType'].lower() == resourceType.lower():
self.api_version = rt['apiVersions'][0]
break
+ else:
+ # if there's no provider in API version, assume Microsoft.Resources
+ self.api_version = '2018-05-01'
if not self.api_version:
self.fail("Couldn't find api version for {0}/{1}".format(provider, resourceType))
except Exception as exc:
diff --git a/lib/ansible/modules/cloud/azure/azure_rm_resource_facts.py b/lib/ansible/modules/cloud/azure/azure_rm_resource_facts.py
index c86c553e31..1e06a8db9a 100644
--- a/lib/ansible/modules/cloud/azure/azure_rm_resource_facts.py
+++ b/lib/ansible/modules/cloud/azure/azure_rm_resource_facts.py
@@ -73,6 +73,11 @@ EXAMPLES = '''
resource_type: virtualmachinescalesets
resource_name: myVmss
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 = '''
@@ -187,6 +192,9 @@ class AzureRMResourceFacts(AzureRMModuleBase):
if rt['resourceType'].lower() == resourceType.lower():
self.api_version = rt['apiVersions'][0]
break
+ else:
+ # if there's no provider in API version, assume Microsoft.Resources
+ self.api_version = '2018-05-01'
if not self.api_version:
self.fail("Couldn't find api version for {0}/{1}".format(provider, resourceType))
except Exception as exc:
diff --git a/test/integration/targets/azure_rm_resource/tasks/main.yml b/test/integration/targets/azure_rm_resource/tasks/main.yml
index 920ffe45f8..7c3024a5ef 100644
--- a/test/integration/targets/azure_rm_resource/tasks/main.yml
+++ b/test/integration/targets/azure_rm_resource/tasks/main.yml
@@ -99,6 +99,17 @@
- output.response[0]['name'] != None
- 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
azure_rm_resource:
polling_timeout: 600