|
|
@ -1,19 +1,12 @@
|
|
|
|
#!/usr/bin/python
|
|
|
|
#!/usr/bin/python
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# This file is part of Ansible
|
|
|
|
# Copyright (c) Ansible Project
|
|
|
|
#
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
# Ansible is free software: you can redistribute it and/or modify
|
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
__metaclass__ = type
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# Ansible is distributed in the hope that it will be useful,
|
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
|
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
|
|
|
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
|
|
|
'status': ['preview'],
|
|
|
|
'status': ['preview'],
|
|
|
|
'supported_by': 'curated'}
|
|
|
|
'supported_by': 'curated'}
|
|
|
@ -374,18 +367,9 @@ deployment:
|
|
|
|
returned: always
|
|
|
|
returned: always
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
PREREQ_IMPORT_ERROR = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
import time
|
|
|
|
import time
|
|
|
|
import yaml
|
|
|
|
|
|
|
|
except ImportError as exc:
|
|
|
|
|
|
|
|
IMPORT_ERROR = "Error importing module prerequisites: %s" % exc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from ansible.module_utils.azure_rm_common import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
from itertools import chain
|
|
|
|
|
|
|
|
from azure.common.credentials import ServicePrincipalCredentials
|
|
|
|
from azure.common.credentials import ServicePrincipalCredentials
|
|
|
|
from azure.common.exceptions import CloudError
|
|
|
|
from azure.common.exceptions import CloudError
|
|
|
|
from azure.mgmt.resource.resources.models import (DeploymentProperties,
|
|
|
|
from azure.mgmt.resource.resources.models import (DeploymentProperties,
|
|
|
@ -401,6 +385,8 @@ except ImportError:
|
|
|
|
# This is handled in azure_rm_common
|
|
|
|
# This is handled in azure_rm_common
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from ansible.module_utils.azure_rm_common import AzureRMModuleBase
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AzureRMDeploymentManager(AzureRMModuleBase):
|
|
|
|
class AzureRMDeploymentManager(AzureRMModuleBase):
|
|
|
|
|
|
|
|
|
|
|
@ -448,9 +434,6 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
|
|
|
|
|
|
|
|
|
|
|
def exec_module(self, **kwargs):
|
|
|
|
def exec_module(self, **kwargs):
|
|
|
|
|
|
|
|
|
|
|
|
if PREREQ_IMPORT_ERROR:
|
|
|
|
|
|
|
|
self.fail(PREREQ_IMPORT_ERROR)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for key in list(self.module_arg_spec.keys()) + ['tags']:
|
|
|
|
for key in list(self.module_arg_spec.keys()) + ['tags']:
|
|
|
|
setattr(self, key, kwargs[key])
|
|
|
|
setattr(self, key, kwargs[key])
|
|
|
|
|
|
|
|
|
|
|
@ -654,8 +637,8 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
|
|
|
|
|
|
|
|
|
|
|
def _nic_to_public_ips_instance(self, nics):
|
|
|
|
def _nic_to_public_ips_instance(self, nics):
|
|
|
|
return [self.network_client.public_ip_addresses.get(public_ip_id.split('/')[4], public_ip_id.split('/')[-1])
|
|
|
|
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_name,
|
|
|
|
for nic_obj in (self.network_client.network_interfaces.get(self.resource_group_name,
|
|
|
|
nic['dep'].resource_name) for nic in nics]
|
|
|
|
nic['dep'].resource_name) for nic in nics)
|
|
|
|
for public_ip_id in [ip_conf_instance.public_ip_address.id
|
|
|
|
for public_ip_id in [ip_conf_instance.public_ip_address.id
|
|
|
|
for ip_conf_instance in nic_obj.ip_configurations
|
|
|
|
for ip_conf_instance in nic_obj.ip_configurations
|
|
|
|
if ip_conf_instance.public_ip_address]]
|
|
|
|
if ip_conf_instance.public_ip_address]]
|
|
|
@ -664,7 +647,6 @@ class AzureRMDeploymentManager(AzureRMModuleBase):
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
AzureRMDeploymentManager()
|
|
|
|
AzureRMDeploymentManager()
|
|
|
|
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import *
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|
|
|
|
main()
|
|
|
|
|
|
|
|
|
|
|
|