v8.0.2: Exclude localhost from SSH configuration

Updated the logic to skip setting SSH configuration for localhost. This change ensures that SSH settings are only applied to remote servers, preventing potential conflicts or unnecessary configurations for the local machine. Additionally, simplified the SSH key name without including the group name in the UI for better clarity.
pull/399/head
Aidaho 2024-09-16 16:08:53 +03:00
parent 85d745f7dd
commit 94e7a23383
2 changed files with 15 additions and 15 deletions

View File

@ -225,20 +225,21 @@ def run_ansible(inv: dict, server_ips: list, ansible_role: str) -> dict:
raise Exception(f'{e}') raise Exception(f'{e}')
for server_ip in server_ips: for server_ip in server_ips:
ssh_settings = return_ssh_keys_path(server_ip) if server_ip != 'localhost':
if ssh_settings['enabled']: ssh_settings = return_ssh_keys_path(server_ip)
inv['server']['hosts'][server_ip]['ansible_ssh_private_key_file'] = ssh_settings['key'] if ssh_settings['enabled']:
inv['server']['hosts'][server_ip]['ansible_password'] = ssh_settings['password'] inv['server']['hosts'][server_ip]['ansible_ssh_private_key_file'] = ssh_settings['key']
inv['server']['hosts'][server_ip]['ansible_user'] = ssh_settings['user'] inv['server']['hosts'][server_ip]['ansible_password'] = ssh_settings['password']
inv['server']['hosts'][server_ip]['ansible_port'] = ssh_settings['port'] inv['server']['hosts'][server_ip]['ansible_user'] = ssh_settings['user']
inv['server']['hosts'][server_ip]['ansible_become'] = True inv['server']['hosts'][server_ip]['ansible_port'] = ssh_settings['port']
inv['server']['hosts'][server_ip]['ansible_become'] = True
if ssh_settings['enabled']: if ssh_settings['enabled']:
try: try:
server_mod.add_key_to_agent(ssh_settings, agent_pid) server_mod.add_key_to_agent(ssh_settings, agent_pid)
except Exception as e: except Exception as e:
server_mod.stop_ssh_agent(agent_pid) server_mod.stop_ssh_agent(agent_pid)
raise Exception(f'{e}') raise Exception(f'{e}')
if proxy is not None and proxy != '' and proxy != 'None': if proxy is not None and proxy != '' and proxy != 'None':
proxy_serv = proxy proxy_serv = proxy

View File

@ -88,11 +88,10 @@ function addCreds(dialog_id) {
if (data.status === 'failed') { if (data.status === 'failed') {
toastr.error(data.error); toastr.error(data.error);
} else { } else {
let group_name = getGroupNameById($('#new-sshgroup').val());
let id = data.id; let id = data.id;
common_ajax_action_after_success(dialog_id, 'ssh-table-' + id, 'ssh_enable_table', data.data); common_ajax_action_after_success(dialog_id, 'ssh-table-' + id, 'ssh_enable_table', data.data);
$('select:regex(id, credentials)').append('<option value=' + id + '>' + ssh_add_div.val() + '</option>').selectmenu("refresh"); $('select:regex(id, credentials)').append('<option value=' + id + '>' + ssh_add_div.val() + '</option>').selectmenu("refresh");
$('select:regex(id, ssh-key-name)').append('<option value=' + id + '>' + ssh_add_div.val() + '_' + group_name + '</option>').selectmenu("refresh"); $('select:regex(id, ssh-key-name)').append('<option value=' + id + '>' + ssh_add_div.val() + '</option>').selectmenu("refresh");
$("input[type=submit], button").button(); $("input[type=submit], button").button();
$("input[type=checkbox]").checkboxradio(); $("input[type=checkbox]").checkboxradio();
$("select").selectmenu(); $("select").selectmenu();