Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ansible azure_rm_deployment module returns error but deployment i… #986

Merged
merged 2 commits into from
Nov 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions plugins/modules/azure_rm_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@
try:
from itertools import chain
from azure.common.exceptions import CloudError
from azure.core.exceptions import ResourceNotFoundError
from azure.mgmt.resource.resources import ResourceManagementClient
from azure.mgmt.network import NetworkManagementClient

Expand Down Expand Up @@ -681,9 +682,18 @@ def _get_ip_dict(self, ip):
return ip_dict

def _nic_to_public_ips_instance(self, nics):
nic_list = []
for nic in nics:
resp = None
try:
resp = self.network_client.network_interfaces.get(self.resource_group, nic['dep'].resource_name)
except ResourceNotFoundError:
pass
if resp is not None:
nic_list.append(resp)

return [self.network_client.public_ip_addresses.get(public_ip_id.split('/')[4], public_ip_id.split('/')[-1])
for nic_obj in (self.network_client.network_interfaces.get(self.resource_group,
nic['dep'].resource_name) for nic in nics)
for nic_obj in nic_list
for public_ip_id in [ip_conf_instance.public_ip_address.id
for ip_conf_instance in nic_obj.ip_configurations
if ip_conf_instance.public_ip_address]]
Expand Down