Azure fix _info/_facts return values for some modules (#61584)
* Azure fix _info/_facts return values for some modules * Further test fixes * securitygroup fixes after the move to _info module
This commit is contained in:
parent
cd24d57636
commit
951dac7691
6 changed files with 35 additions and 24 deletions
3
changelogs/fragments/azure-fact-fix.yaml
Normal file
3
changelogs/fragments/azure-fact-fix.yaml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
bugfixes:
|
||||||
|
- azure_rm_securitygroup_info - Fix up instances when ``ansible_facts`` is returned for the older ``_facts`` alias.
|
||||||
|
- azure_rm_networkinterface_info - Fix up instances when ``ansible_facts`` is returned for the older ``_facts`` alias.
|
|
@ -273,7 +273,6 @@ class AzureRMNetworkInterfaceInfo(AzureRMModuleBase):
|
||||||
|
|
||||||
self.results = dict(
|
self.results = dict(
|
||||||
changed=False,
|
changed=False,
|
||||||
ansible_info=dict(azure_networkinterfaces=[])
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.name = None
|
self.name = None
|
||||||
|
@ -307,7 +306,10 @@ class AzureRMNetworkInterfaceInfo(AzureRMModuleBase):
|
||||||
else:
|
else:
|
||||||
results = self.list_all()
|
results = self.list_all()
|
||||||
|
|
||||||
self.results['ansible_info']['azure_networkinterfaces'] = self.serialize_nics(results)
|
if is_old_facts:
|
||||||
|
self.results['ansible_facts'] = {
|
||||||
|
'azure_networkinterfaces': self.serialize_nics(results)
|
||||||
|
}
|
||||||
self.results['networkinterfaces'] = self.to_dict_list(results)
|
self.results['networkinterfaces'] = self.to_dict_list(results)
|
||||||
return self.results
|
return self.results
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,6 @@ class AzureRMPublicIPInfo(AzureRMModuleBase):
|
||||||
|
|
||||||
self.results = dict(
|
self.results = dict(
|
||||||
changed=False,
|
changed=False,
|
||||||
ansible_facts=dict(azure_publicipaddresses=[])
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.name = None
|
self.name = None
|
||||||
|
@ -240,7 +239,9 @@ class AzureRMPublicIPInfo(AzureRMModuleBase):
|
||||||
raw = self.filter(result)
|
raw = self.filter(result)
|
||||||
|
|
||||||
if is_old_facts:
|
if is_old_facts:
|
||||||
self.results['ansible_facts']['azure_publicipaddresses'] = self.serialize(raw)
|
self.results['ansible_facts'] = {
|
||||||
|
'azure_publicipaddresses': self.serialize(raw),
|
||||||
|
}
|
||||||
self.results['publicipaddresses'] = self.format(raw)
|
self.results['publicipaddresses'] = self.format(raw)
|
||||||
|
|
||||||
return self.results
|
return self.results
|
||||||
|
|
|
@ -59,7 +59,7 @@ EXAMPLES = '''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
azure_securitygroups:
|
securitygroups:
|
||||||
description:
|
description:
|
||||||
- List containing security group dicts.
|
- List containing security group dicts.
|
||||||
returned: always
|
returned: always
|
||||||
|
@ -247,7 +247,6 @@ class AzureRMSecurityGroupInfo(AzureRMModuleBase):
|
||||||
|
|
||||||
self.results = dict(
|
self.results = dict(
|
||||||
changed=False,
|
changed=False,
|
||||||
ansible_info=dict(azure_securitygroups=[])
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.name = None
|
self.name = None
|
||||||
|
@ -268,9 +267,15 @@ class AzureRMSecurityGroupInfo(AzureRMModuleBase):
|
||||||
setattr(self, key, kwargs[key])
|
setattr(self, key, kwargs[key])
|
||||||
|
|
||||||
if self.name is not None:
|
if self.name is not None:
|
||||||
self.results['ansible_info']['azure_securitygroups'] = self.get_item()
|
info = self.get_item()
|
||||||
else:
|
else:
|
||||||
self.results['ansible_info']['azure_securitygroups'] = self.list_items()
|
info = self.list_items()
|
||||||
|
|
||||||
|
if is_old_facts:
|
||||||
|
self.results['ansible_facts'] = {
|
||||||
|
'azure_securitygroups': info
|
||||||
|
}
|
||||||
|
self.results['securitygroups'] = info
|
||||||
|
|
||||||
return self.results
|
return self.results
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
- assert: { that: "{{ output.state.rules | length }} == 2" }
|
- assert: { that: "{{ output.state.rules | length }} == 2" }
|
||||||
|
|
||||||
- name: Gather facts by tags
|
- name: Gather facts by tags
|
||||||
azure_rm_securitygroup_facts:
|
azure_rm_securitygroup_info:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
tags:
|
tags:
|
||||||
- testing
|
- testing
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that: azure_securitygroups | length == 1
|
that: output.securitygroups | length == 1
|
||||||
|
|
||||||
- name: Add/Update rules on existing security group
|
- name: Add/Update rules on existing security group
|
||||||
azure_rm_securitygroup:
|
azure_rm_securitygroup:
|
||||||
|
@ -121,23 +121,23 @@
|
||||||
- output.state.tags.delete == 'on-exit'
|
- output.state.tags.delete == 'on-exit'
|
||||||
|
|
||||||
- name: Gather facts for one accounts
|
- name: Gather facts for one accounts
|
||||||
azure_rm_securitygroup_facts:
|
azure_rm_securitygroup_info:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ secgroupname }}"
|
name: "{{ secgroupname }}"
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- azure_securitygroups | length == 1
|
- output.securitygroups | length == 1
|
||||||
|
|
||||||
- name: Gather facts for all accounts
|
- name: Gather facts for all accounts
|
||||||
azure_rm_securitygroup_facts:
|
azure_rm_securitygroup_info:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
register: output
|
register: output_groups
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- azure_securitygroups | length > 0
|
- output_groups.securitygroups | length > 0
|
||||||
|
|
||||||
- name: Create security group with source_address_prefixes
|
- name: Create security group with source_address_prefixes
|
||||||
azure_rm_securitygroup:
|
azure_rm_securitygroup:
|
||||||
|
@ -290,13 +290,13 @@
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ item.name }}"
|
name: "{{ item.name }}"
|
||||||
state: absent
|
state: absent
|
||||||
with_items: "{{ azure_securitygroups }}"
|
with_items: "{{ output_groups.securitygroups }}"
|
||||||
|
|
||||||
- name: Should have no security groups remaining
|
- name: Should have no security groups remaining
|
||||||
azure_rm_securitygroup_facts:
|
azure_rm_securitygroup_info:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- azure_securitygroups | length == 0
|
- output.securitygroups | length == 0
|
||||||
|
|
|
@ -66,19 +66,19 @@
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Query auto created NIC
|
- name: Query auto created NIC
|
||||||
azure_rm_networkinterface_facts:
|
azure_rm_networkinterface_info:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ vm_name }}01"
|
name: "{{ vm_name }}01"
|
||||||
register: nic_result
|
register: nic_result
|
||||||
|
|
||||||
- name: Query auto created security group
|
- name: Query auto created security group
|
||||||
azure_rm_securitygroup_facts:
|
azure_rm_securitygroup_info:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ vm_name }}01"
|
name: "{{ vm_name }}01"
|
||||||
register: nsg_result
|
register: nsg_result
|
||||||
|
|
||||||
- name: Query auto created public IP
|
- name: Query auto created public IP
|
||||||
azure_rm_publicipaddress_facts:
|
azure_rm_publicipaddress_info:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ vm_name }}01"
|
name: "{{ vm_name }}01"
|
||||||
register: pip_result
|
register: pip_result
|
||||||
|
@ -87,9 +87,9 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
# what about the default storage group?
|
# what about the default storage group?
|
||||||
- nic_result.ansible_facts.azure_networkinterfaces | length == 0
|
- nic_result.networkinterfaces | length == 0
|
||||||
- nsg_result.ansible_facts.azure_securitygroups | length == 0
|
- nsg_result.securitygroups | length == 0
|
||||||
- pip_result.ansible_facts.azure_publicipaddresses | length == 0
|
- pip_result.publicipaddresses | length == 0
|
||||||
|
|
||||||
- name: Destroy subnet
|
- name: Destroy subnet
|
||||||
azure_rm_subnet:
|
azure_rm_subnet:
|
||||||
|
|
Loading…
Reference in a new issue