mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
Job Submission: prompt for credential
Added the prompt for credential during job submission if credentials_needed_to_start === true
This commit is contained in:
@@ -90,7 +90,8 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
|
|||||||
field: 'credential',
|
field: 'credential',
|
||||||
hdr: 'Credential Required',
|
hdr: 'Credential Required',
|
||||||
instructions: "Launching this job requires a machine credential. Please select your machine credential now or Cancel to quit.",
|
instructions: "Launching this job requires a machine credential. Please select your machine credential now or Cancel to quit.",
|
||||||
postAction: selectionMade
|
postAction: selectionMade,
|
||||||
|
input_type: 'radio'
|
||||||
});
|
});
|
||||||
scope.lookUpCredential();
|
scope.lookUpCredential();
|
||||||
});
|
});
|
||||||
@@ -674,7 +675,6 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
|
|||||||
system_job = params.system_job || false,
|
system_job = params.system_job || false,
|
||||||
base = $location.path().replace(/^\//, '').split('/')[0],
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
url,
|
url,
|
||||||
job_template,
|
|
||||||
extra_vars,
|
extra_vars,
|
||||||
new_job_id,
|
new_job_id,
|
||||||
launch_url,
|
launch_url,
|
||||||
@@ -813,10 +813,34 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
|
|||||||
scope.removeCredentialReady();
|
scope.removeCredentialReady();
|
||||||
}
|
}
|
||||||
scope.removeCredentialReady = scope.$on('CredentialReady', function(e, credential) {
|
scope.removeCredentialReady = scope.$on('CredentialReady', function(e, credential) {
|
||||||
|
var passwords = [];
|
||||||
if (!Empty(credential)) {
|
if (!Empty(credential)) {
|
||||||
job_template.credential = credential;
|
Rest.setUrl(GetBasePath('credentials')+credential);
|
||||||
scope.$emit('PostTheJob');
|
Rest.get()
|
||||||
|
.success(function (data) {
|
||||||
|
if(data.ssh_key_unlock === "ASK"){
|
||||||
|
passwords.push("ssh_password");
|
||||||
|
}
|
||||||
|
if(data.sudo_password === "ASK"){
|
||||||
|
passwords.push("sudo_password");
|
||||||
|
}
|
||||||
|
if(data.su_password === "ASK"){
|
||||||
|
passwords.push("su_password");
|
||||||
|
}
|
||||||
|
if(data.vault_password === "ASK"){
|
||||||
|
passwords.push("vault_password");
|
||||||
|
}
|
||||||
|
if(passwords.length>0){
|
||||||
|
scope.$emit('PromptForPasswords', passwords, html, url);
|
||||||
|
}
|
||||||
|
else scope.$emit('StartPlaybookRun', url);
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||||
|
msg: 'Failed to get job template details. GET returned status: ' + status });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get the job or job_template record
|
// Get the job or job_template record
|
||||||
@@ -831,14 +855,18 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
|
|||||||
// scope.extra_vars = data.variables_needed_to_start;
|
// scope.extra_vars = data.variables_needed_to_start;
|
||||||
scope.survey_enabled = data.survey_enabled;
|
scope.survey_enabled = data.survey_enabled;
|
||||||
|
|
||||||
// new_job = data;
|
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 (!Empty(data.passwords_needed_to_start) && data.passwords_needed_to_start.length > 0) {
|
if(data.credential_needed_to_start === true){
|
||||||
|
scope.$emit('PromptForCredential');
|
||||||
|
}
|
||||||
|
else if (!Empty(data.passwords_needed_to_start) && data.passwords_needed_to_start.length > 0) {
|
||||||
scope.$emit('PromptForPasswords', data.passwords_needed_to_start, html, url);
|
scope.$emit('PromptForPasswords', data.passwords_needed_to_start, html, url);
|
||||||
}
|
}
|
||||||
else if (data.ask_variables_on_launch) {
|
else if (data.ask_variables_on_launch) {
|
||||||
scope.$emit('PromptForVars', html, url);
|
scope.$emit('PromptForVars', html, url);
|
||||||
} else if (!Empty(data.survey_enabled) && data.survey_enabled===true) {
|
}
|
||||||
|
else if (!Empty(data.survey_enabled) && data.survey_enabled===true) {
|
||||||
scope.$emit('PromptForSurvey', html, url);
|
scope.$emit('PromptForSurvey', html, url);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user