Additionally, import paths were corrected in the Python file 'app/routes/install/routes.py'. Error handling was improved in the 'install_service' function to return details of any encountered exceptions.
pull/375/head
Aidaho 2024-02-16 20:47:02 +03:00
parent cb03546ca2
commit 8030a69a05
4 changed files with 23 additions and 20 deletions

View File

@ -3,19 +3,19 @@ from flask_login import login_required
from app.routes.install import bp
from middleware import get_user_params, check_services
import modules.db.sql as sql
import modules.common.common as common
import modules.roxywi.auth as roxywi_auth
import modules.server.server as server_mod
import modules.service.common as service_common
import app.modules.db.sql as sql
import app.modules.common.common as common
import app.modules.roxywi.auth as roxywi_auth
import app.modules.server.server as server_mod
import app.modules.service.common as service_common
import app.modules.service.installation as service_mod
import modules.service.exporter_installation as exp_installation
import app.modules.service.exporter_installation as exp_installation
@bp.before_request
@login_required
def before_request():
""" Protect all of the admin endpoints. """
""" Protect all the admin endpoints. """
pass
@ -35,7 +35,10 @@ def install_monitoring():
@check_services
def install_service(service):
json_data = request.form.get('jsonData')
return service_mod.install_service(service, json_data)
try:
return service_mod.install_service(service, json_data)
except Exception as e:
return f'{e}'
@bp.route('/<service>/version/<server_ip>')

View File

@ -3,12 +3,12 @@
src: haproxy.service.j2
dest: /usr/lib/systemd/system/haproxy.service
mode: 0644
when: ansible_os_family == "RedHat" and haproxy_from_wi is defined
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and haproxy_from_wi is defined
- name: test to see if selinux is running
command: getenforce
register: sestatus
when: ansible_os_family == "RedHat"
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS')
changed_when: false
ignore_errors: yes
debugger: never
@ -41,7 +41,7 @@
debugger: never
when:
- '"firewalld" in ansible_facts.packages'
- ansible_os_family == "RedHat"
- ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS'
- ansible_facts.services["firewalld.service"]['state'] == "running"
with_items: [ "{{ STAT_PORT }}", "{{ SOCK_PORT }}", "10000" ]

View File

@ -3,7 +3,7 @@
name: epel-release
state: latest
disable_gpg_check: yes
when: ansible_os_family == "RedHat" and HAPVER|length > 0
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and HAPVER|length > 0
ignore_errors: yes
environment:
http_proxy: "{{PROXY}}"
@ -12,7 +12,7 @@
- name: Set dist short name if EL
set_fact:
distr_short_name: "el"
when: ansible_os_family == "RedHat"
when: ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS'
- name: Set dist short name if Amazon Linux
set_fact:
@ -27,7 +27,7 @@
- rsyslog
state: present
disable_gpg_check: yes
when: ansible_os_family == "RedHat" and HAPVER|length > 0
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and HAPVER|length > 0
ignore_errors: yes
register: install_result
retries: 5
@ -45,7 +45,7 @@
- rsyslog
- bind-utils
state: present
when: (ansible_os_family == "RedHat") and ("'timed out' in install_result.stderr")
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and ("'timed out' in install_result.stderr")
ignore_errors: yes
register: install_result1
retries: 5
@ -59,7 +59,7 @@
- name: set_fact from wi
set_fact:
haproxy_from_wi: "yes"
when: (ansible_os_family == "RedHat"' or ansible_distribution == 'Amazon') and HAPVER|length > 0
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS' or ansible_distribution == 'Amazon') and HAPVER|length > 0
- name: install the latest version of HAProxy
@ -69,7 +69,7 @@
- socat
- rsyslog
state: latest
when: (ansible_os_family == "RedHat") and (install_result.rc != 0 and install_result1.rc != 0)
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and (install_result.rc != 0 and install_result1.rc != 0)
register: install_result
retries: 5
until: install_result.rc == 0
@ -86,7 +86,7 @@
- socat
- rsyslog
state: present
when: ansible_os_family == "Debian"
when: ansible_facts['os_family'] == 'Debian' or ansible_facts['os_family'] == 'Ubuntu'
environment:
http_proxy: "{{PROXY}}"
https_proxy: "{{PROXY}}"

View File

@ -11,7 +11,7 @@
src: /var/www/haproxy-wi/app/scripts/ansible/roles/haproxy/templates/logrotate.conf.j2
dest: /etc/logrotate.d/haproxy.conf
force: no
when: ansible_os_family == "RedHat"
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS')
ignore_errors: yes
- name: Installing HAProxy conf for logrotate on Debian
@ -19,5 +19,5 @@
src: /var/www/haproxy-wi/app/scripts/ansible/roles/haproxy/templates/logrotate-debian.conf.j2
dest: /etc/logrotate.d/haproxy-roxy-wi
force: no
when: ansible_os_family == "Debian"
when: (ansible_facts['os_family'] == "Debian" or ansible_facts['os_family'] == 'Ubuntu')
ignore_errors: yes