diff --git a/awx/ui/static/js/forms/Source.js b/awx/ui/static/js/forms/Source.js index dcbf0e7e02..121b2eb0c6 100644 --- a/awx/ui/static/js/forms/Source.js +++ b/awx/ui/static/js/forms/Source.js @@ -125,7 +125,7 @@ angular.module('SourceFormDefinition', []) rows: 6, 'default': '---', parseTypeName: 'envParseType', - dataTitle: "Environment Variables", //'

Source Variables

', + dataTitle: "Environment Variables", dataPlacement: 'right', awPopOver: "

Provide key/value pairs using either YAML or JSON.

" + "JSON:
\n" + @@ -157,6 +157,29 @@ angular.module('SourceFormDefinition', []) '

View YAML examples at docs.ansible.com

', dataContainer: 'body' }, + inventory_variables: { + label: 'Source Variables', //"{{vars_label}}" , + ngShow: "source && (source.value == 'vmware')", + type: 'textarea', + addRequired: false, + editRequird: false, + rows: 6, + 'default': '---', + parseTypeName: 'envParseType', + dataTitle: "Source Variables", + dataPlacement: 'right', + awPopOver: "

Override variables found in vmware.ini and used by the inventory update script. For a detailed description of these variables " + + "" + + "view ec2.ini in the Ansible github repo.

" + + "

Enter variables using either JSON or YAML syntax. Use the radio button to toggle between the two.

" + + "JSON:
\n" + + "
{
\"somevar\": \"somevalue\",
\"password\": \"magic\"
}
\n" + + "YAML:
\n" + + "
---
somevar: somevalue
password: magic
\n" + + '

View JSON examples at www.json.org

' + + '

View YAML examples at docs.ansible.com

', + dataContainer: 'body' + }, checkbox_group: { label: 'Update Options', type: 'checkbox_group', diff --git a/awx/ui/static/js/helpers/Groups.js b/awx/ui/static/js/helpers/Groups.js index 30ce61485c..94de7f17c7 100644 --- a/awx/ui/static/js/helpers/Groups.js +++ b/awx/ui/static/js/helpers/Groups.js @@ -273,6 +273,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' ParseTypeChange({ scope: scope, variable: 'extra_vars', parse_variable: form.fields.extra_vars.parseTypeName, field_id: 'source_extra_vars', onReady: callback }); } + if (scope.source.value === 'rax' || scope.source.value === 'ec2'|| scope.source.value==='gce' || scope.source.value === 'azure' || scope.source.value === 'vmware') { kind = (scope.source.value === 'rax') ? 'rax' : (scope.source.value==='gce') ? 'gce' : (scope.source.value==='azure') ? 'azure' : (scope.source.value === 'vmware') ? 'vmware' : 'aws' ; url = GetBasePath('credentials') + '?cloud=true&kind=' + kind; @@ -284,13 +285,20 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' field: 'credential', input_type: "radio" }); - if ($('#group_tabs .active a').text() === 'Source' && (scope.source.value === 'ec2' || scope.source.value === 'custom')) { + if ($('#group_tabs .active a').text() === 'Source' && (scope.source.value === 'ec2' )) { callback = function(){ Wait('stop'); }; Wait('start'); scope.source_vars = (Empty(scope.source_vars)) ? "---" : scope.source_vars; ParseTypeChange({ scope: scope, variable: 'source_vars', parse_variable: form.fields.source_vars.parseTypeName, field_id: 'source_source_vars', onReady: callback }); } + if ($('#group_tabs .active a').text() === 'Source' && (scope.source.value === 'vmware' )) { + callback = function(){ Wait('stop'); }; + Wait('start'); + scope.inventory_variables = (Empty(scope.source_vars)) ? "---" : scope.source_vars; + ParseTypeChange({ scope: scope, variable: 'inventory_variables', parse_variable: form.fields.inventory_variables.parseTypeName, + field_id: 'source_inventory_variables', onReady: callback }); + } } } }; @@ -850,6 +858,10 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched Wait('start'); ParseTypeChange({ scope: sources_scope, variable: 'source_vars', parse_variable: SourceForm.fields.source_vars.parseTypeName, field_id: 'source_source_vars', onReady: waitStop }); + } else if (sources_scope.source && (sources_scope.source.value === 'vmware')) { + Wait('start'); + ParseTypeChange({ scope: sources_scope, variable: 'inventory_variables', parse_variable: SourceForm.fields.inventory_variables.parseTypeName, + field_id: 'source_inventory_variables', onReady: waitStop }); } else if (sources_scope.source && (sources_scope.source.value === 'custom')) { Wait('start'); @@ -1206,7 +1218,7 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched data.group_by = r.join(); } - if (sources_scope.source && (sources_scope.source.value === 'ec2' || sources_scope.source.value === 'custom')) { + if (sources_scope.source && (sources_scope.source.value === 'ec2' )) { // for ec2, validate variable data data.source_vars = ToJSON(sources_scope.envParseType, sources_scope.source_vars, true); } @@ -1215,6 +1227,11 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched data.source_vars = ToJSON(sources_scope.envParseType, sources_scope.extra_vars, true); } + if (sources_scope.source && (sources_scope.source.value === 'vmware')) { + data.source_vars = ToJSON(sources_scope.envParseType, sources_scope.inventory_variables, true); + } + + // the API doesn't expect the credential to be passed with a custom inv script if(sources_scope.source.value === 'custom'){ delete(data.credential); }