1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 01:21:21 +03:00

support AZURE_CLOUD_ENVIRONMENT

Relates #7737 of ansible-tower.

Signed-off-by: Aaron Tan <jangsutsr@gmail.com>
This commit is contained in:
Aaron Tan 2017-10-23 15:23:06 -04:00
parent 70919638ba
commit f28b48a473
No known key found for this signature in database
GPG Key ID: B0B709D324AE4963
4 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
# AWX
from awx.main.migrations import _credentialtypes as credentialtypes
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('main', '0011_v322_encrypt_survey_passwords'),
]
operations = [
migrations.RunPython(credentialtypes.add_azure_cloud_environment_field),
]

View File

@ -176,3 +176,13 @@ def migrate_job_credentials(apps, schema_editor):
def create_ovirt4_credtype(apps, schema_editor):
CredentialType.setup_tower_managed_defaults()
def add_azure_cloud_environment_field(apps, schema_editor):
azure_rm_credtype = CredentialType.defaults.get('azure_rm', None)
if azure_rm_credtype:
azure_rm_credtype = azure_rm_credtype()
azure_rm_credtype.pk = CredentialType.objects.get(
kind='cloud', name='Microsoft Azure Resource Manager'
).pk
azure_rm_credtype.save()

View File

@ -977,6 +977,12 @@ def azure_rm(cls):
'id': 'tenant',
'label': 'Tenant ID',
'type': 'string'
}, {
'id': 'cloud_environment',
'label': 'Azure Cloud Environment',
'type': 'string',
'help_text': ('Environment variable AZURE_CLOUD_ENVIRONMENT when'
' using Azure GovCloud or Azure stack.')
}],
'required': ['subscription'],
}

View File

@ -1887,6 +1887,9 @@ class RunInventoryUpdate(BaseTask):
env['AZURE_AD_USER'] = passwords.get('source_username', '')
env['AZURE_PASSWORD'] = passwords.get('source_password', '')
env['AZURE_INI_PATH'] = cloud_credential
if inventory_update.credential and \
inventory_update.credential.inputs.get('cloud_environment', None):
env['AZURE_CLOUD_ENVIRONMENT'] = inventory_update.credential.inputs['cloud_environment']
elif inventory_update.source == 'gce':
env['GCE_EMAIL'] = passwords.get('source_username', '')
env['GCE_PROJECT'] = passwords.get('source_project', '')