mirror of
https://github.com/ansible/awx.git
synced 2026-05-14 21:07:39 -02:30
Passing vars to API via extra_vars in job launch
We changed this at one point to have all vars passed on the root level, but for uniformity we have changed it back to using the extra_vars object
This commit is contained in:
@@ -25,25 +25,28 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
|||||||
extra_vars;
|
extra_vars;
|
||||||
|
|
||||||
|
|
||||||
if(!Empty(scope.passwords_needed_to_start) && scope.passwords_needed_to_start .length>0){
|
if(!Empty(scope.passwords_needed_to_start) && scope.passwords_needed_to_start.length>0){
|
||||||
scope.passwords.forEach(function(password) {
|
scope.passwords.forEach(function(password) {
|
||||||
job_launch_data[password] = scope[password];
|
job_launch_data[password] = scope[password];
|
||||||
|
scope.passwords_needed_to_start.push(password+'_confirm'); // i'm pushing these values into this array for use during the survey taker parsing
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(scope.prompt_for_vars===true){
|
if(scope.prompt_for_vars===true){
|
||||||
extra_vars = ToJSON(scope.parseType, scope.extra_vars, false);
|
extra_vars = ToJSON(scope.parseType, scope.extra_vars, false);
|
||||||
$.each(extra_vars, function(key,value){
|
// $.each(extra_vars, function(key,value){
|
||||||
job_launch_data[key] = value;
|
// job_launch_data[key] = value;
|
||||||
});
|
// });
|
||||||
|
job_launch_data.extra_vars = (extra_vars===null) ? {} : extra_vars;
|
||||||
}
|
}
|
||||||
if(scope.survey_enabled===true){
|
if(scope.survey_enabled===true){
|
||||||
|
job_launch_data.extra_vars = (!job_launch_data.extra_vars || job_launch_data.extra_vars===null) ? {} : job_launch_data.extra_vars;
|
||||||
for (fld in scope.job_launch_form){
|
for (fld in scope.job_launch_form){
|
||||||
if(scope[fld] || scope[fld] === 0){
|
if((scope[fld] || scope[fld] === 0) && scope.passwords_needed_to_start.indexOf(fld) === -1){
|
||||||
job_launch_data[fld] = scope[fld];
|
job_launch_data.extra_vars[fld] = scope[fld];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete(job_launch_data.extra_vars);
|
// delete(job_launch_data.extra_vars);
|
||||||
if(!Empty(scope.credential)){
|
if(!Empty(scope.credential)){
|
||||||
job_launch_data.credential_id = scope.credential;
|
job_launch_data.credential_id = scope.credential;
|
||||||
}
|
}
|
||||||
@@ -754,7 +757,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
|
|||||||
Rest.setUrl(GetBasePath('credentials')+credential);
|
Rest.setUrl(GetBasePath('credentials')+credential);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
if(data.ssh_key_unlock === "ASK"){
|
if((data.kind === "ssh" && data.password === "ASK" ) || data.ssh_key_unlock === "ASK"){
|
||||||
passwords.push("ssh_password");
|
passwords.push("ssh_password");
|
||||||
}
|
}
|
||||||
if(data.sudo_password === "ASK"){
|
if(data.sudo_password === "ASK"){
|
||||||
@@ -767,6 +770,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
|
|||||||
passwords.push("vault_password");
|
passwords.push("vault_password");
|
||||||
}
|
}
|
||||||
if(passwords.length>0){
|
if(passwords.length>0){
|
||||||
|
scope.passwords_needed_to_start = passwords;
|
||||||
scope.$emit('PromptForPasswords', passwords, html, url);
|
scope.$emit('PromptForPasswords', passwords, html, url);
|
||||||
}
|
}
|
||||||
else if (scope.ask_variables_on_launch){
|
else if (scope.ask_variables_on_launch){
|
||||||
@@ -796,7 +800,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
|
|||||||
scope.prompt_for_vars = data.ask_variables_on_launch;
|
scope.prompt_for_vars = data.ask_variables_on_launch;
|
||||||
scope.survey_enabled = data.survey_enabled;
|
scope.survey_enabled = data.survey_enabled;
|
||||||
scope.ask_variables_on_launch = data.ask_variables_on_launch;
|
scope.ask_variables_on_launch = data.ask_variables_on_launch;
|
||||||
|
scope.variables_needed_to_start = data.variables_needed_to_start;
|
||||||
html = '<form class="ng-valid ng-valid-required" name="job_launch_form" id="job_launch_form" autocomplete="off" nonvalidate>';
|
html = '<form class="ng-valid ng-valid-required" name="job_launch_form" id="job_launch_form" autocomplete="off" nonvalidate>';
|
||||||
|
|
||||||
if(data.credential_needed_to_start === true){
|
if(data.credential_needed_to_start === true){
|
||||||
|
|||||||
Reference in New Issue
Block a user