diff --git a/app/routes/install/routes.py b/app/routes/install/routes.py index 69882eb9..bab5df9b 100644 --- a/app/routes/install/routes.py +++ b/app/routes/install/routes.py @@ -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('//version/') diff --git a/app/scripts/ansible/roles/haproxy/tasks/configure.yml b/app/scripts/ansible/roles/haproxy/tasks/configure.yml index 7cfeb6c3..66691ab8 100644 --- a/app/scripts/ansible/roles/haproxy/tasks/configure.yml +++ b/app/scripts/ansible/roles/haproxy/tasks/configure.yml @@ -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" ] diff --git a/app/scripts/ansible/roles/haproxy/tasks/installation.yml b/app/scripts/ansible/roles/haproxy/tasks/installation.yml index e7356fcd..8dd25046 100644 --- a/app/scripts/ansible/roles/haproxy/tasks/installation.yml +++ b/app/scripts/ansible/roles/haproxy/tasks/installation.yml @@ -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}}" diff --git a/app/scripts/ansible/roles/haproxy/tasks/logs.yml b/app/scripts/ansible/roles/haproxy/tasks/logs.yml index a8388698..e7baf3c9 100644 --- a/app/scripts/ansible/roles/haproxy/tasks/logs.yml +++ b/app/scripts/ansible/roles/haproxy/tasks/logs.yml @@ -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