Fix SSH port in Ansible
pull/372/head
Aidaho 2023-12-17 15:02:20 +03:00
parent 7c899092cc
commit 1cb12d12e6
5 changed files with 12 additions and 13 deletions

View File

@ -6,6 +6,7 @@ import modules.db.sql as sql
import modules.server.ssh as mod_ssh
import modules.common.common as common
import modules.roxywi.auth as roxywi_auth
import modules.roxywi.logs as roxywi_logs
import modules.roxywi.common as roxywi_common
@ -35,8 +36,6 @@ def ssh_command(server_ip: str, commands: list, **kwargs):
if kwargs.get('raw'):
return stdout.readlines()
elif kwargs.get("show_log") == "1":
import modules.roxywi.logs as roxywi_logs
return roxywi_logs.show_log(stdout, grep=kwargs.get("grep"))
elif kwargs.get('return_err') == 1:
return stderr.read().decode(encoding='UTF-8')
@ -44,6 +43,7 @@ def ssh_command(server_ip: str, commands: list, **kwargs):
return stdout.read().decode(encoding='UTF-8')
except Exception as e:
roxywi_common.logging('Roxy-WI server', f' Something wrong with SSH connection. Probably sudo with password {e}', roxywi=1)
raise Exception(f'error: Cannot run SSH: {e}')
except Exception as e:
roxywi_common.logging('Roxy-WI server', f' Something wrong with SSH connection: {e}', roxywi=1)
raise Exception(f'error: Cannot run SSH: {e}')

View File

@ -229,7 +229,7 @@ def get_stat_page(server_ip: str, service: str) -> str:
return data.decode('utf-8')
def show_service_version(server_ip: str, service: str) -> None:
def show_service_version(server_ip: str, service: str) -> str:
if service == 'haproxy':
return check_haproxy_version(server_ip)
@ -248,4 +248,8 @@ def show_service_version(server_ip: str, service: str) -> None:
cmd = [f'docker exec -it {container_name} /usr/sbin/{service_name} -v 2>&1|head -1|awk -F":" \'{{print $2}}\'']
else:
cmd = [f'sudo /usr/sbin/{service_name} -v|head -1|awk -F":" \'{{print $2}}\'']
return server_mod.ssh_command(server_ip, cmd)
try:
return server_mod.ssh_command(server_ip, cmd, timeout=5)
except Exception as e:
return f'{e}'

View File

@ -1,8 +1,4 @@
---
#- name: Set SSH port
# set_fact:
# ansible_port: "{{SSH_PORT}}"
- name: check if HAProxy is installed
package_facts:
manager: "auto"

View File

@ -2,10 +2,6 @@
- name: Include Service-OS-specific variables.
include_vars: "{{ service }}-{{ ansible_os_family }}.yml"
- name: Set SSH port
set_fact:
ansible_port: "{{SSH_PORT}}"
- name: "Ensure group {{ service_group }} exists"
ansible.builtin.group:
name: "{{ service_group }}"

View File

@ -2895,7 +2895,10 @@ function showServiceVersion(service) {
// type: "POST",
success: function (data) {
data = data.replace(/^\s+|\s+$/g, '');
if (data.indexOf('bash') != '-1' || data.indexOf('such') != '-1' || data.indexOf('command not found') != '-1' || data.indexOf('from') != '-1') {
if (data.indexOf('error: ') != '-1') {
toastr.warning(data);
$('#cur_' + service + '_ver').text('');
} else if(data.indexOf('bash') != '-1' || data.indexOf('such') != '-1' || data.indexOf('command not found') != '-1' || data.indexOf('from') != '-1') {
$('#cur_' + service + '_ver').text(service + ' has not installed');
$('#' + service + '_install').text('Install');
$('#' + service + '_install').attr('title', 'Install');