From 58ad214dcf1d01e354ae53ef41e7ec822adaf5f4 Mon Sep 17 00:00:00 2001 From: Aaron Tan Date: Fri, 1 Dec 2017 13:38:43 -0500 Subject: [PATCH] Follow up fix #542 Relates https://github.com/ansible/ansible-tower/issues/7737#issuecomment-348566452 Signed-off-by: Aaron Tan --- awx/main/tasks.py | 2 ++ awx/main/tests/unit/test_tasks.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 42d00e14d8..822e5b89f9 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -1080,6 +1080,8 @@ class RunJob(BaseTask): env['AZURE_SUBSCRIPTION_ID'] = cloud_cred.subscription env['AZURE_AD_USER'] = cloud_cred.username env['AZURE_PASSWORD'] = decrypt_field(cloud_cred, 'password') + if cloud_cred.inputs.get('cloud_environment', None): + env['AZURE_CLOUD_ENVIRONMENT'] = cloud_cred.inputs['cloud_environment'] elif cloud_cred and cloud_cred.kind == 'vmware': env['VMWARE_USER'] = cloud_cred.username env['VMWARE_PASSWORD'] = decrypt_field(cloud_cred, 'password') diff --git a/awx/main/tests/unit/test_tasks.py b/awx/main/tests/unit/test_tasks.py index 0b54b310d8..f5a8c309b6 100644 --- a/awx/main/tests/unit/test_tasks.py +++ b/awx/main/tests/unit/test_tasks.py @@ -635,7 +635,8 @@ class TestJobCredentials(TestJobExecution): inputs = { 'subscription': 'some-subscription', 'username': 'bob', - 'password': 'secret' + 'password': 'secret', + 'cloud_environment': 'foobar' } ) credential.inputs['password'] = encrypt_field(credential, 'password') @@ -650,6 +651,7 @@ class TestJobCredentials(TestJobExecution): assert env['AZURE_SUBSCRIPTION_ID'] == 'some-subscription' assert env['AZURE_AD_USER'] == 'bob' assert env['AZURE_PASSWORD'] == 'secret' + assert env['AZURE_CLOUD_ENVIRONMENT'] == 'foobar' def test_vmware_credentials(self): vmware = CredentialType.defaults['vmware']()