diff --git a/app/create_db.py b/app/create_db.py
index 15befd45..663fa988 100644
--- a/app/create_db.py
+++ b/app/create_db.py
@@ -966,7 +966,7 @@ def update_db_v_6_2_1():
def update_ver():
try:
- Version.update(version='6.3.2.0').execute()
+ Version.update(version='6.3.3.0').execute()
except Exception:
print('Cannot update version')
diff --git a/app/modules/db/sql.py b/app/modules/db/sql.py
index 773a75f2..e0af5bb4 100755
--- a/app/modules/db/sql.py
+++ b/app/modules/db/sql.py
@@ -2106,6 +2106,7 @@ def select_service_table_metrics(service: str, group_id: int):
def update_setting(param: str, val: str, user_group: int) -> bool:
+ print(val)
query = Setting.update(value=val).where((Setting.param == param) & (Setting.group == user_group))
try:
query.execute()
@@ -2315,7 +2316,7 @@ def select_nginx(serv):
return query_res
-def update_nginx(serv):
+def update_nginx(serv: str) -> bool:
query = Server.update(nginx=1).where(Server.ip == serv)
try:
query.execute()
@@ -2325,6 +2326,16 @@ def update_nginx(serv):
return False
+def update_apache(serv: str) -> bool:
+ query = Server.update(apache=1).where(Server.ip == serv)
+ try:
+ query.execute()
+ return True
+ except Exception as e:
+ out_error(e)
+ return False
+
+
def select_haproxy(serv):
try:
query_res = Server.get(Server.ip == serv).haproxy
diff --git a/app/modules/roxy_wi_tools.py b/app/modules/roxy_wi_tools.py
index 540ee359..9e2e6234 100644
--- a/app/modules/roxy_wi_tools.py
+++ b/app/modules/roxy_wi_tools.py
@@ -1,22 +1,22 @@
from datetime import datetime, timedelta
from pytz import timezone
-from configparser import ConfigParser, ExtendedInterpolation
+import configparser
class GetConfigVar:
def __init__(self):
self.path_config = "/etc/roxy-wi/roxy-wi.cfg"
- self.config = ConfigParser(interpolation=ExtendedInterpolation())
+ self.config = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
self.config.read(self.path_config)
def get_config_var(self, sec, var):
try:
return self.config.get(sec, var)
+ except configparser.Error as e:
+ print(f'error: in the config file: {self.path_config}: {e}')
except Exception as e:
- print('Content-type: text/html\n')
- print(
- f'
Check the config file. Presence section {sec} and parameter {var}
')
+ print(f'Check the config file. Presence section {sec} and parameter {var}')
print(e)
return
diff --git a/app/modules/roxywi/overview.py b/app/modules/roxywi/overview.py
index 29b145ca..97a28f0c 100644
--- a/app/modules/roxywi/overview.py
+++ b/app/modules/roxywi/overview.py
@@ -6,6 +6,7 @@ from jinja2 import Environment, FileSystemLoader
import modules.db.sql as sql
import modules.common.common as common
+import modules.roxywi.logs as roxy_logs
import modules.roxywi.common as roxywi_common
import modules.server.server as server_mod
import modules.service.common as service_common
@@ -195,3 +196,76 @@ def show_apache_bytes(server_ip: str) -> None:
print(template)
else:
print('error: cannot connect to Apache stat page')
+
+
+def show_services_overview() -> None:
+ import psutil
+ from jinja2 import Environment, FileSystemLoader
+
+ env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
+ template = env.get_template('ajax/show_services_ovw.html')
+ user_params = roxywi_common.get_users_params()
+ grafana = 0
+ metrics_worker = 0
+ checker_worker = 0
+ servers_group = []
+ host = os.environ.get('HTTP_HOST', '')
+ user_group = roxywi_common.get_user_group(id=1)
+
+ if (user_params['role'] == 2 or user_params['role'] == 3) and int(user_group) != 1:
+ for s in user_params['servers']:
+ servers_group.append(s[2])
+
+ is_checker_worker = len(sql.select_all_alerts(group=user_group))
+ is_metrics_worker = len(sql.select_servers_metrics_for_master(group=user_group))
+
+ for pids in psutil.pids():
+ if pids < 300:
+ continue
+ try:
+ pid = psutil.Process(pids)
+ cmdline_out = pid.cmdline()
+ if len(cmdline_out) > 2:
+ if 'checker_' in cmdline_out[1]:
+ if len(servers_group) > 0:
+ if cmdline_out[2] in servers_group:
+ checker_worker += 1
+ else:
+ checker_worker += 1
+ elif 'metrics_' in cmdline_out[1]:
+ if len(servers_group) > 0:
+ if cmdline_out[2] in servers_group:
+ metrics_worker += 1
+ else:
+ metrics_worker += 1
+ if len(servers_group) == 0:
+ if 'grafana' in cmdline_out[1]:
+ grafana += 1
+ except psutil.NoSuchProcess:
+ pass
+
+ cmd = "systemctl is-active roxy-wi-metrics"
+ metrics_master, stderr = server_mod.subprocess_execute(cmd)
+ cmd = "systemctl is-active roxy-wi-checker"
+ checker_master, stderr = server_mod.subprocess_execute(cmd)
+ cmd = "systemctl is-active roxy-wi-keep_alive"
+ keep_alive, stderr = server_mod.subprocess_execute(cmd)
+ cmd = "systemctl is-active roxy-wi-smon"
+ smon, stderr = server_mod.subprocess_execute(cmd)
+ cmd = "systemctl is-active roxy-wi-portscanner"
+ port_scanner, stderr = server_mod.subprocess_execute(cmd)
+ cmd = "systemctl is-active roxy-wi-socket"
+ socket, stderr = server_mod.subprocess_execute(cmd)
+
+ rendered_template = template.render(
+ role=user_params['role'], metrics_master=''.join(metrics_master), metrics_worker=metrics_worker,
+ checker_master=''.join(checker_master), checker_worker=checker_worker, keep_alive=''.join(keep_alive),
+ smon=''.join(smon), port_scanner=''.join(port_scanner), grafana=grafana, socket=''.join(socket),
+ is_checker_worker=is_checker_worker, is_metrics_worker=is_metrics_worker, host=host,
+ roxy_wi_log_id=roxy_logs.roxy_wi_log(log_id=1, file="roxy-wi-"),
+ metrics_log_id=roxy_logs.roxy_wi_log(log_id=1, file="metrics"),
+ checker_log_id=roxy_logs.roxy_wi_log(log_id=1, file="checker"),
+ keep_alive_log_id=roxy_logs.roxy_wi_log(log_id=1, file="keep_alive"),
+ socket_log_id=roxy_logs.roxy_wi_log(log_id=1, file="socket"), error=stderr
+ )
+ print(rendered_template)
diff --git a/app/modules/service/common.py b/app/modules/service/common.py
index d6593740..b6d5fc4e 100644
--- a/app/modules/service/common.py
+++ b/app/modules/service/common.py
@@ -282,3 +282,30 @@ def get_stat_page(server_ip: str, service: str) -> None:
print(template)
else:
print(data.decode('utf-8'))
+
+
+def show_service_version(server_ip: str, service: str) -> None:
+ if service not in ('nginx', 'apache', 'haproxy'):
+ print('warning: wrong service')
+ return None
+
+ if service == 'haproxy':
+ print(check_haproxy_version(server_ip))
+ return None
+
+ server_id = sql.select_server_id_by_ip(server_ip)
+ service_name = service
+ is_dockerized = sql.select_service_setting(server_id, service, 'dockerized')
+
+ if service == 'apache':
+ service_name = get_correct_apache_service_name(None, server_id)
+
+ if is_dockerized == '1':
+ container_name = sql.get_setting(f'{service}_container_name')
+ if service == 'apache':
+ cmd = [f'docker exec -it {container_name} /usr/local/apache2/bin/httpd -v 2>&1|head -1|awk -F":" \'{{print $2}}\'']
+ else:
+ 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}}\'']
+ print(server_mod.ssh_command(server_ip, cmd))
diff --git a/app/modules/service/installation.py b/app/modules/service/installation.py
index ab218b90..08bc24a0 100644
--- a/app/modules/service/installation.py
+++ b/app/modules/service/installation.py
@@ -138,18 +138,17 @@ def waf_nginx_install(server_ip: str):
os.remove(script)
-def install_nginx(server_ip: str, **kwargs):
- script = "install_nginx.sh"
- stats_user = sql.get_setting('nginx_stats_user')
- stats_password = sql.get_setting('nginx_stats_password')
- stats_port = str(sql.get_setting('nginx_stats_port'))
- stats_page = sql.get_setting('nginx_stats_page')
- config_path = sql.get_setting('nginx_config_path')
- nginx_dir = sql.get_setting('nginx_dir')
+def install_service(server_ip: str, service: str, docker: str, **kwargs) -> None:
+ script = f"install_{service}.sh"
+ stats_user = sql.get_setting(f'{service}_stats_user')
+ stats_password = sql.get_setting(f'{service}_stats_password')
+ stats_port = str(sql.get_setting(f'{service}_stats_port'))
+ stats_page = sql.get_setting(f'{service}_stats_page')
+ config_path = sql.get_setting(f'{service}_config_path')
+ service_dir = sql.get_setting(f'{service}_dir')
server_for_installing = kwargs.get('server')
proxy = sql.get_setting('proxy')
- docker = kwargs.get('docker')
- container_name = sql.get_setting('nginx_container_name')
+ container_name = sql.get_setting(f'{service}_container_name')
proxy_serv = ''
ssh_settings = return_ssh_keys_path(server_ip)
@@ -163,22 +162,27 @@ def install_nginx(server_ip: str, **kwargs):
commands = [
f"chmod +x {script} && ./{script} PROXY={proxy_serv} STATS_USER={stats_user} STATS_PASS='{stats_password}' "
f"SSH_PORT={ssh_settings['port']} CONFIG_PATH={config_path} CONT_NAME={container_name} STAT_PORT={stats_port} "
- f"STAT_PAGE={stats_page} SYN_FLOOD={syn_flood_protect} DOCKER={docker} nginx_dir={nginx_dir} HOST={server_ip} "
+ f"STAT_PAGE={stats_page} SYN_FLOOD={syn_flood_protect} DOCKER={docker} service_dir={service_dir} HOST={server_ip} "
f"USER={ssh_settings['user']} PASS='{ssh_settings['password']}' KEY={ssh_settings['key']}"
]
output, error = server_mod.subprocess_execute(commands[0])
+
if server_for_installing:
- service = server_for_installing + ' Nginx'
+ service_name = f'{server_for_installing} {service.title()}'
else:
- service = ' Nginx'
- if show_installation_output(error, output, service):
- sql.update_nginx(server_ip)
+ service_name = service.title
+
+ if show_installation_output(error, output, service_name):
+ if service == 'nginx':
+ sql.update_nginx(server_ip)
+ elif service == 'apache':
+ sql.update_apache(server_ip)
if docker == '1':
server_id = sql.select_server_id_by_ip(server_ip)
- sql.insert_or_update_service_setting(server_id, 'nginx', 'dockerized', '1')
- sql.insert_or_update_service_setting(server_id, 'nginx', 'restart', '1')
+ sql.insert_or_update_service_setting(server_id, service, 'dockerized', '1')
+ sql.insert_or_update_service_setting(server_id, service, 'restart', '1')
os.remove(script)
diff --git a/app/options.py b/app/options.py
index 8b7e12a1..ac7804c6 100644
--- a/app/options.py
+++ b/app/options.py
@@ -276,6 +276,11 @@ if act == "overviewServers":
service_common.overview_service(serv, server_id, name, service)
+if act == "overviewServices":
+ import modules.roxywi.overview as roxy_overview
+
+ roxy_overview.show_services_overview()
+
if form.getvalue('action'):
import modules.service.haproxy as service_haproxy
@@ -552,8 +557,15 @@ if form.getvalue('git_backup'):
print('Ok')
os.remove(script)
-if form.getvalue('install_nginx'):
- service_mod.install_nginx(form.getvalue('install_nginx'), docker=form.getvalue('docker'))
+if form.getvalue('install_service'):
+ server_ip = common.is_ip_or_dns(form.getvalue('install_service'))
+ service = common.checkAjaxInput(form.getvalue('service'))
+ docker = common.checkAjaxInput(form.getvalue('docker'))
+
+ if service in ('nginx', 'apache'):
+ service_mod.install_service(server_ip, service, docker)
+ else:
+ print('warning: wrong service')
if form.getvalue('haproxyaddserv'):
service_mod.install_haproxy(form.getvalue('haproxyaddserv'), syn_flood=form.getvalue('syn_flood'),
@@ -758,16 +770,11 @@ if any((form.getvalue('new_nginx_metrics'), form.getvalue('new_apache_metrics'),
if form.getvalue('get_hap_v'):
print(service_common.check_haproxy_version(serv))
-if form.getvalue('get_nginx_v'):
- server_id = sql.select_server_id_by_ip(serv)
- is_dockerized = sql.select_service_setting(server_id, 'nginx', 'dockerized')
+if form.getvalue('get_service_v'):
+ service = common.checkAjaxInput(form.getvalue('get_service_v'))
+ server_ip = common.is_ip_or_dns(serv)
- if is_dockerized == '1':
- container_name = sql.get_setting('nginx_container_name')
- cmd = [f"docker exec -it {container_name} /usr/sbin/nginx -v 2>&1|awk '{{print $3}}'"]
- else:
- cmd = ['sudo /usr/sbin/nginx -v']
- print(server_mod.ssh_command(serv, cmd))
+ service_common.show_service_version(server_ip, service)
if form.getvalue('get_keepalived_v'):
cmd = ["sudo /usr/sbin/keepalived -v 2>&1|head -1|awk '{print $2}'"]
diff --git a/app/overview.py b/app/overview.py
index c0169bae..8270f6f9 100644
--- a/app/overview.py
+++ b/app/overview.py
@@ -3,28 +3,18 @@
import os
import sys
-import psutil
from jinja2 import Environment, FileSystemLoader
import modules.db.sql as sql
import modules.roxywi.logs as roxy_logs
import modules.roxywi.auth as roxywi_auth
import modules.roxywi.common as roxywi_common
-import modules.server.server as server_mod
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
template = env.get_template('ovw.html')
print('Content-type: text/html\n')
-grafana = 0
-metrics_worker = 0
-checker_worker = 0
-is_checker_worker = 0
-is_metrics_worker = 0
-servers_group = []
-host = os.environ.get('HTTP_HOST', '')
-
user_params = roxywi_common.get_users_params()
try:
@@ -35,76 +25,13 @@ except Exception as e:
try:
groups = sql.select_groups()
- user_group = roxywi_common.get_user_group(id=1)
-
- if (user_params['role'] == 2 or user_params['role'] == 3) and int(user_group) != 1:
- for s in user_params['servers']:
- servers_group.append(s[2])
-
- is_checker_worker = len(sql.select_all_alerts(group=user_group))
- is_metrics_worker = len(sql.select_servers_metrics_for_master(group=user_group))
-
- for pids in psutil.pids():
- if pids < 300:
- continue
- try:
- pid = psutil.Process(pids)
- cmdline_out = pid.cmdline()
- if len(cmdline_out) > 2:
- if 'checker_' in cmdline_out[1]:
- if len(servers_group) > 0:
- if cmdline_out[2] in servers_group:
- checker_worker += 1
- else:
- checker_worker += 1
- elif 'metrics_' in cmdline_out[1]:
- if len(servers_group) > 0:
- if cmdline_out[2] in servers_group:
- metrics_worker += 1
- else:
- metrics_worker += 1
- if len(servers_group) == 0:
- if 'grafana' in cmdline_out[1]:
- grafana += 1
- except psutil.NoSuchProcess:
- pass
-
- cmd = "systemctl is-active roxy-wi-metrics"
- metrics_master, stderr = server_mod.subprocess_execute(cmd)
- cmd = "systemctl is-active roxy-wi-checker"
- checker_master, stderr = server_mod.subprocess_execute(cmd)
- cmd = "systemctl is-active roxy-wi-keep_alive"
- keep_alive, stderr = server_mod.subprocess_execute(cmd)
- cmd = "systemctl is-active roxy-wi-smon"
- smon, stderr = server_mod.subprocess_execute(cmd)
- cmd = "systemctl is-active roxy-wi-portscanner"
- port_scanner, stderr = server_mod.subprocess_execute(cmd)
- cmd = "systemctl is-active roxy-wi-socket"
- socket, stderr = server_mod.subprocess_execute(cmd)
-
except Exception as e:
groups = ''
- roles = ''
- metrics_master = ''
- checker_master = ''
- keep_alive = ''
- smon = ''
- socket = ''
- stderr = ''
print(e)
rendered_template = template.render(
h2=1, autorefresh=1, title="Overview", role=user_params['role'], user=user_params['user'], groups=groups,
- roles=sql.select_roles(), metrics_master=''.join(metrics_master), metrics_worker=metrics_worker,
- checker_master=''.join(checker_master), checker_worker=checker_worker, keep_alive=''.join(keep_alive),
- smon=''.join(smon), port_scanner=''.join(port_scanner), grafana=grafana, socket=''.join(socket),
- roxy_wi_log_id=roxy_logs.roxy_wi_log(log_id=1, file="roxy-wi-"),
- metrics_log_id=roxy_logs.roxy_wi_log(log_id=1, file="metrics"),
- checker_log_id=roxy_logs.roxy_wi_log(log_id=1, file="checker"),
- keep_alive_log_id=roxy_logs.roxy_wi_log(log_id=1, file="keep_alive"),
- socket_log_id=roxy_logs.roxy_wi_log(log_id=1, file="socket"), error=stderr,
- roxy_wi_log=roxy_logs.roxy_wi_log(), servers=user_params['servers'], is_checker_worker=is_checker_worker,
- is_metrics_worker=is_metrics_worker, host=host, user_services=user_params['user_services'],
- token=user_params['token'], guide_me=1
+ roles=sql.select_roles(), servers=user_params['servers'], user_services=user_params['user_services'],
+ roxy_wi_log=roxy_logs.roxy_wi_log(), token=user_params['token'], guide_me=1
)
print(rendered_template)
diff --git a/app/scripts/ansible/roles/apache.yml b/app/scripts/ansible/roles/apache.yml
new file mode 100644
index 00000000..8d698718
--- /dev/null
+++ b/app/scripts/ansible/roles/apache.yml
@@ -0,0 +1,50 @@
+---
+- name: Install common role
+ hosts: "{{ variable_host }}"
+ become: yes
+ become_method: sudo
+ gather_facts: yes
+ roles:
+ - role: service_common
+ environment:
+ http_proxy: "{{PROXY}}"
+ https_proxy: "{{PROXY}}"
+
+ tags:
+ - system
+ - docker
+
+- name: Install docker
+ hosts: "{{ variable_host }}"
+ become: yes
+ gather_facts: yes
+ roles:
+ - role: docker
+ environment:
+ http_proxy: "{{PROXY}}"
+ https_proxy: "{{PROXY}}"
+ - role: service_docker
+ environment:
+ http_proxy: "{{PROXY}}"
+ https_proxy: "{{PROXY}}"
+ vars:
+ image_name: httpd
+ cont_etc_dir: "/usr/local/apache2"
+ tags:
+ - docker
+
+- name: Install system role
+ hosts: "{{ variable_host }}"
+ become: yes
+ become_method: sudo
+ tasks:
+ - name: Add syn_flood tasks
+ include: haproxy/tasks/syn_flood.yml
+ when: (SYN_FLOOD is defined) and (SYN_FLOOD|length > 0)
+ roles:
+ - role: apache
+ environment:
+ http_proxy: "{{PROXY}}"
+ https_proxy: "{{PROXY}}"
+ tags:
+ - system
diff --git a/app/scripts/ansible/roles/nginx.yml b/app/scripts/ansible/roles/nginx.yml
index ac7e0733..6d42e73e 100644
--- a/app/scripts/ansible/roles/nginx.yml
+++ b/app/scripts/ansible/roles/nginx.yml
@@ -5,7 +5,7 @@
become_method: sudo
gather_facts: yes
roles:
- - role: nginx_common
+ - role: service_common
environment:
http_proxy: "{{PROXY}}"
https_proxy: "{{PROXY}}"
@@ -23,10 +23,13 @@
environment:
http_proxy: "{{PROXY}}"
https_proxy: "{{PROXY}}"
- - role: nginx_docker
+ - role: service_docker
environment:
http_proxy: "{{PROXY}}"
https_proxy: "{{PROXY}}"
+ vars:
+ image_name: nginx
+ cont_etc_dir: "/etc/nginx"
tags:
- docker
@@ -59,5 +62,5 @@
become: yes
tasks:
- name: Set
- shell: "chown nginx:nginx -R {{ nginx_dir }}"
+ shell: "chown nginx:nginx -R {{ service_dir }}"
diff --git a/app/scripts/ansible/roles/nginx_docker/tasks/main.yml b/app/scripts/ansible/roles/nginx_docker/tasks/main.yml
deleted file mode 100644
index 54b4403a..00000000
--- a/app/scripts/ansible/roles/nginx_docker/tasks/main.yml
+++ /dev/null
@@ -1,53 +0,0 @@
----
-- name: Ensuring nginx directories exist
- file:
- path: "/etc/nginx"
- state: "directory"
- owner: "{{ansible_user}}"
- group: "{{ansible_user}}"
- mode: "0770"
- become: true
- ignore_errors: yes
-
-- name: Ensuring conf.d directories exist
- file:
- path: "{{ nginx_dir }}"
- state: "directory"
- owner: "{{ansible_user}}"
- group: "{{ansible_user}}"
- mode: "0770"
- become: true
- ignore_errors: yes
-
-- name: Ensuring sites-enabled directories exist
- file:
- path: "/etc/nginx/sites-enabled"
- state: "directory"
- owner: "{{ansible_user}}"
- group: "{{ansible_user}}"
- mode: "0770"
- become: true
- ignore_errors: yes
-
-- name: Ensuring log directories exist
- file:
- path: "/var/log/nginx/"
- state: "directory"
- owner: "{{ansible_user}}"
- group: "{{ansible_user}}"
- mode: "0770"
- become: true
- ignore_errors: yes
-
-- name: Create Nginx
- docker_container:
- name: "{{ CONT_NAME }}"
- image: "nginx"
- recreate: yes
- network_mode: host
- volumes:
- - "/etc/nginx/:/etc/nginx/:rw"
- - "/tmp:/tmp:ro"
- - "/var/log:/var/log:rw"
- vars:
- ansible_python_interpreter: /usr/bin/python3
diff --git a/app/scripts/ansible/roles/nginx_common/tasks/main.yml b/app/scripts/ansible/roles/service_common/tasks/main.yml
similarity index 66%
rename from app/scripts/ansible/roles/nginx_common/tasks/main.yml
rename to app/scripts/ansible/roles/service_common/tasks/main.yml
index 999f61f3..0027774d 100644
--- a/app/scripts/ansible/roles/nginx_common/tasks/main.yml
+++ b/app/scripts/ansible/roles/service_common/tasks/main.yml
@@ -1,19 +1,22 @@
---
+- 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 "nginx" exists
+- name: "Ensure group {{ service_group }} exists"
ansible.builtin.group:
- name: nginx
+ name: "{{ service_group }}"
state: present
-- name: Add NGINX User
+- name: Add {{ service_group }} User
ansible.builtin.user:
- name: nginx
- group: nginx
+ name: "{{ service_user }}"
+ group: "{{ service_group }}"
-- name: check if Nginx is installed
+- name: "check if {{ service_group }} is installed"
package_facts:
manager: "auto"
@@ -21,21 +24,17 @@
service_facts:
-- name: Creates directory
+- name: Creates directorys
file:
- path: "{{nginx_dir}}"
+ path: "{{ item.path }}"
state: directory
mode: o=rx
- owner: nginx
- group: nginx
- when: "'nginx' not in ansible_facts.packages"
-
-
-- name: Creates directory
- file:
- path: "{{nginx_dir}}/conf.d"
- state: directory
- when: "'nginx' not in ansible_facts.packages"
+ owner: "{{ service_user }}"
+ group: "{{ service_group }}"
+ with_items:
+ - { path: "{{ service_dir }}"}
+ - { path: "{{ service_dir }}/conf.d"}
+ when: service not in ansible_facts.packages
- name: Set passlib version
@@ -63,40 +62,30 @@
name: "{{passlib_ver}}"
state: present
when:
- - "'nginx' not in ansible_facts.packages"
+ - service not in ansible_facts.packages
- ansible_facts['distribution_major_version'] != '9'
environment:
http_proxy: "{{PROXY}}"
https_proxy: "{{PROXY}}"
-
-- name: Copy Nginx configuration in place
- template:
- src: default.conf.j2
- dest: "{{nginx_dir}}/conf.d/default.conf"
- mode: 0644
- force: no
- when: "'nginx' not in ansible_facts.packages"
- ignore_errors: yes
-
- name: Copying over nginx.conf
- template:
- src: nginx.conf.j2
- dest: "{{nginx_dir}}/nginx.conf"
- mode: "0666"
- force: no
- remote_src: true
+ template: src={{item.src}} dest={{item.dest}} mode="0666" force="no"
+ with_items:
+ - { src: 'mime.types.j2', dest: '{{ service_dir }}/mime.types' }
+ - { src: 'nginx.conf.j2', dest: '{{CONFIG_PATH}}' }
+ - { src: '{{ service }}_default.conf.j2', dest: '{{ service_dir }}/conf.d/default.conf' }
become: true
ignore_errors: yes
+ when: service == "nginx"
-- name: Copying over mime.types
+- name: Copy status page configuration in place
template:
- src: mime.types.j2
- dest: "{{nginx_dir}}/mime.types"
- mode: "0666"
+ src: "{{ service }}_status.conf.j2"
+ dest: "{{ service_dir }}/conf.d/status_page.conf"
+ mode: 0644
force: no
- remote_src: true
- become: true
+ when:
+ - service not in ansible_facts.packages
ignore_errors: yes
- name: Open stat port for firewalld
@@ -124,10 +113,9 @@
- htpasswd:
- path: "{{nginx_dir}}/status_page_passwdfile"
+ path: "{{ service_dir }}/status_page_passwdfile"
name: "{{STATS_USER}}"
password: "{{STATS_PASS}}"
- when: "'nginx' not in ansible_facts.packages"
- name: test to see if selinux is running
diff --git a/app/scripts/ansible/roles/service_common/templates/apache_status.conf.j2 b/app/scripts/ansible/roles/service_common/templates/apache_status.conf.j2
new file mode 100644
index 00000000..d4c9b884
--- /dev/null
+++ b/app/scripts/ansible/roles/service_common/templates/apache_status.conf.j2
@@ -0,0 +1,10 @@
+Listen {{ STAT_PORT }}
+
+
+ SetHandler server-status
+ AuthType basic
+ AuthName "Apache status"
+ AuthUserFile {{ service_dir }}/status_page_passwdfile
+ Require valid-user
+
+
diff --git a/app/scripts/ansible/roles/nginx_common/templates/mime.types.j2 b/app/scripts/ansible/roles/service_common/templates/mime.types.j2
similarity index 100%
rename from app/scripts/ansible/roles/nginx_common/templates/mime.types.j2
rename to app/scripts/ansible/roles/service_common/templates/mime.types.j2
diff --git a/app/scripts/ansible/roles/nginx_common/templates/nginx.conf.j2 b/app/scripts/ansible/roles/service_common/templates/nginx.conf.j2
similarity index 100%
rename from app/scripts/ansible/roles/nginx_common/templates/nginx.conf.j2
rename to app/scripts/ansible/roles/service_common/templates/nginx.conf.j2
diff --git a/app/scripts/ansible/roles/nginx_common/templates/default.conf.j2 b/app/scripts/ansible/roles/service_common/templates/nginx_default.conf.j2
similarity index 81%
rename from app/scripts/ansible/roles/nginx_common/templates/default.conf.j2
rename to app/scripts/ansible/roles/service_common/templates/nginx_default.conf.j2
index 08267826..299c622a 100644
--- a/app/scripts/ansible/roles/nginx_common/templates/default.conf.j2
+++ b/app/scripts/ansible/roles/service_common/templates/nginx_default.conf.j2
@@ -1,14 +1,3 @@
-server {
- listen {{STAT_PORT}} ;
- server_name localhost;
-
- location /{{STAT_PAGE}} {
- stub_status;
- auth_basic "Resticted Area";
- auth_basic_user_file /etc/nginx/status_page_passwdfile;
- }
-}
-
server {
listen 80;
server_name localhost;
diff --git a/app/scripts/ansible/roles/service_common/templates/nginx_status.conf.j2 b/app/scripts/ansible/roles/service_common/templates/nginx_status.conf.j2
new file mode 100644
index 00000000..bb18b82f
--- /dev/null
+++ b/app/scripts/ansible/roles/service_common/templates/nginx_status.conf.j2
@@ -0,0 +1,10 @@
+server {
+ listen {{STAT_PORT}} ;
+ server_name localhost;
+
+ location /{{STAT_PAGE}} {
+ stub_status;
+ auth_basic "Resticted Area";
+ auth_basic_user_file /etc/nginx/status_page_passwdfile;
+ }
+}
diff --git a/app/scripts/ansible/roles/service_common/vars/apache-AmazonLinux.yml b/app/scripts/ansible/roles/service_common/vars/apache-AmazonLinux.yml
new file mode 100644
index 00000000..21e0f727
--- /dev/null
+++ b/app/scripts/ansible/roles/service_common/vars/apache-AmazonLinux.yml
@@ -0,0 +1,3 @@
+---
+service_user: httpd
+service_group: httpd
\ No newline at end of file
diff --git a/app/scripts/ansible/roles/service_common/vars/apache-Debian.yml b/app/scripts/ansible/roles/service_common/vars/apache-Debian.yml
new file mode 100644
index 00000000..e795c26d
--- /dev/null
+++ b/app/scripts/ansible/roles/service_common/vars/apache-Debian.yml
@@ -0,0 +1,3 @@
+---
+service_user: apache2
+service_group: apache2
\ No newline at end of file
diff --git a/app/scripts/ansible/roles/service_common/vars/apache-RedHat.yml b/app/scripts/ansible/roles/service_common/vars/apache-RedHat.yml
new file mode 100644
index 00000000..21e0f727
--- /dev/null
+++ b/app/scripts/ansible/roles/service_common/vars/apache-RedHat.yml
@@ -0,0 +1,3 @@
+---
+service_user: httpd
+service_group: httpd
\ No newline at end of file
diff --git a/app/scripts/ansible/roles/service_common/vars/apache-Suse.yml b/app/scripts/ansible/roles/service_common/vars/apache-Suse.yml
new file mode 100644
index 00000000..e795c26d
--- /dev/null
+++ b/app/scripts/ansible/roles/service_common/vars/apache-Suse.yml
@@ -0,0 +1,3 @@
+---
+service_user: apache2
+service_group: apache2
\ No newline at end of file
diff --git a/app/scripts/ansible/roles/service_common/vars/nginx-AmazonLinux.yml b/app/scripts/ansible/roles/service_common/vars/nginx-AmazonLinux.yml
new file mode 100644
index 00000000..62a627e5
--- /dev/null
+++ b/app/scripts/ansible/roles/service_common/vars/nginx-AmazonLinux.yml
@@ -0,0 +1,3 @@
+---
+service_user: nginx
+service_group: nginx
\ No newline at end of file
diff --git a/app/scripts/ansible/roles/service_common/vars/nginx-Debian.yml b/app/scripts/ansible/roles/service_common/vars/nginx-Debian.yml
new file mode 100644
index 00000000..62a627e5
--- /dev/null
+++ b/app/scripts/ansible/roles/service_common/vars/nginx-Debian.yml
@@ -0,0 +1,3 @@
+---
+service_user: nginx
+service_group: nginx
\ No newline at end of file
diff --git a/app/scripts/ansible/roles/service_common/vars/nginx-RedHat.yml b/app/scripts/ansible/roles/service_common/vars/nginx-RedHat.yml
new file mode 100644
index 00000000..62a627e5
--- /dev/null
+++ b/app/scripts/ansible/roles/service_common/vars/nginx-RedHat.yml
@@ -0,0 +1,3 @@
+---
+service_user: nginx
+service_group: nginx
\ No newline at end of file
diff --git a/app/scripts/ansible/roles/service_common/vars/nginx-Suse.yml b/app/scripts/ansible/roles/service_common/vars/nginx-Suse.yml
new file mode 100644
index 00000000..62a627e5
--- /dev/null
+++ b/app/scripts/ansible/roles/service_common/vars/nginx-Suse.yml
@@ -0,0 +1,3 @@
+---
+service_user: nginx
+service_group: nginx
\ No newline at end of file
diff --git a/app/scripts/ansible/roles/service_docker/tasks/main.yml b/app/scripts/ansible/roles/service_docker/tasks/main.yml
new file mode 100644
index 00000000..9c2848ed
--- /dev/null
+++ b/app/scripts/ansible/roles/service_docker/tasks/main.yml
@@ -0,0 +1,28 @@
+---
+- name: Creates directorys
+ file:
+ path: "{{ item.path }}"
+ state: directory
+ mode: "0770"
+ owner: "{{ service_user }}"
+ group: "{{ service_group }}"
+ become: true
+ ignore_errors: yes
+ with_items:
+ - { path: "{{ service_dir }}"}
+ - { path: "{{ service_dir }}/conf.d"}
+ - { path: "{{ service_dir }}/sites-enabled"}
+ - { path: "/var/log/{{ service }}/"}
+
+- name: "Create {{ service }}"
+ docker_container:
+ name: "{{ CONT_NAME }}"
+ image: "{{ image_name }}"
+ recreate: yes
+ network_mode: host
+ volumes:
+ - "/etc/{{ service }}/:{{ cont_etc_dir }}/:rw"
+ - "/tmp:/tmp:ro"
+ - "/var/log:/var/log:rw"
+ vars:
+ ansible_python_interpreter: /usr/bin/python3
diff --git a/app/scripts/ansible/roles/nginx_docker/templates/nginx.conf.j2 b/app/scripts/ansible/roles/service_docker/templates/nginx.conf.j2
similarity index 100%
rename from app/scripts/ansible/roles/nginx_docker/templates/nginx.conf.j2
rename to app/scripts/ansible/roles/service_docker/templates/nginx.conf.j2
diff --git a/app/scripts/install_apache.sh b/app/scripts/install_apache.sh
new file mode 100644
index 00000000..4c7c3560
--- /dev/null
+++ b/app/scripts/install_apache.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+for ARGUMENT in "$@"
+do
+ KEY=$(echo $ARGUMENT | cut -f1 -d=)
+ VALUE=$(echo $ARGUMENT | cut -f2 -d=)
+
+ case "$KEY" in
+ PROXY) PROXY=${VALUE} ;;
+ HOST) HOST=${VALUE} ;;
+ USER) USER=${VALUE} ;;
+ PASS) PASS=${VALUE} ;;
+ KEY) KEY=${VALUE} ;;
+ SYN_FLOOD) SYN_FLOOD=${VALUE} ;;
+ STAT_PORT) STAT_PORT=${VALUE} ;;
+ STAT_PAGE) STAT_PAGE=${VALUE} ;;
+ STATS_USER) STATS_USER=${VALUE} ;;
+ STATS_PASS) STATS_PASS=${VALUE} ;;
+ SSH_PORT) SSH_PORT=${VALUE} ;;
+ CONFIG_PATH) CONFIG_PATH=${VALUE} ;;
+ DOCKER) DOCKER=${VALUE} ;;
+ CONT_NAME) CONT_NAME=${VALUE} ;;
+ service_dir) service_dir=${VALUE} ;;
+ *)
+ esac
+done
+
+if [[ $DOCKER == '1' ]]; then
+ tags='docker'
+else
+ tags='system'
+fi
+
+export ANSIBLE_HOST_KEY_CHECKING=False
+export ANSIBLE_DISPLAY_SKIPPED_HOSTS=False
+export ACTION_WARNINGS=False
+export LOCALHOST_WARNING=False
+export COMMAND_WARNINGS=False
+
+PWD=`pwd`
+PWD=$PWD/scripts/ansible/
+echo "$HOST ansible_port=$SSH_PORT" > $PWD/$HOST
+
+if [[ $KEY == "" ]]; then
+ ansible-playbook $PWD/roles/apache.yml -e "ansible_user=$USER ansible_ssh_pass='$PASS' variable_host=$HOST PROXY=$PROXY CONT_NAME=$CONT_NAME service_dir=$service_dir SYN_FLOOD=$SYN_FLOOD STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS CONFIG_PATH=$CONFIG_PATH SSH_PORT=$SSH_PORT service=apache" -i $PWD/$HOST -t $tags
+else
+ ansible-playbook $PWD/roles/apache.yml --key-file $KEY -e "ansible_user=$USER variable_host=$HOST PROXY=$PROXY CONT_NAME=$CONT_NAME service_dir=$service_dir SYN_FLOOD=$SYN_FLOOD STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS CONFIG_PATH=$CONFIG_PATH SSH_PORT=$SSH_PORT service=apache" -i $PWD/$HOST -t $tags
+fi
+
+if [ $? -gt 0 ]
+then
+ echo "error: Can't install Apache service
"
+ exit 1
+else
+ echo "ok"
+fi
+rm -f $PWD/$HOST
diff --git a/app/scripts/install_nginx.sh b/app/scripts/install_nginx.sh
index dd153648..472cbebd 100644
--- a/app/scripts/install_nginx.sh
+++ b/app/scripts/install_nginx.sh
@@ -9,17 +9,17 @@ do
HOST) HOST=${VALUE} ;;
USER) USER=${VALUE} ;;
PASS) PASS=${VALUE} ;;
- KEY) KEY=${VALUE} ;;
+ KEY) KEY=${VALUE} ;;
SYN_FLOOD) SYN_FLOOD=${VALUE} ;;
- STAT_PORT) STAT_PORT=${VALUE} ;;
- STAT_PAGE) STAT_PAGE=${VALUE} ;;
- STATS_USER) STATS_USER=${VALUE} ;;
- STATS_PASS) STATS_PASS=${VALUE} ;;
- SSH_PORT) SSH_PORT=${VALUE} ;;
- CONFIG_PATH) CONFIG_PATH=${VALUE} ;;
- DOCKER) DOCKER=${VALUE} ;;
+ STAT_PORT) STAT_PORT=${VALUE} ;;
+ STAT_PAGE) STAT_PAGE=${VALUE} ;;
+ STATS_USER) STATS_USER=${VALUE} ;;
+ STATS_PASS) STATS_PASS=${VALUE} ;;
+ SSH_PORT) SSH_PORT=${VALUE} ;;
+ CONFIG_PATH) CONFIG_PATH=${VALUE} ;;
+ DOCKER) DOCKER=${VALUE} ;;
CONT_NAME) CONT_NAME=${VALUE} ;;
- nginx_dir) nginx_dir=${VALUE} ;;
+ service_dir) service_dir=${VALUE} ;;
*)
esac
done
@@ -49,14 +49,14 @@ PWD=$PWD/scripts/ansible/
echo "$HOST ansible_port=$SSH_PORT" > $PWD/$HOST
if [[ $KEY == "" ]]; then
- ansible-playbook $PWD/roles/nginx.yml -e "ansible_user=$USER ansible_ssh_pass='$PASS' variable_host=$HOST PROXY=$PROXY CONT_NAME=$CONT_NAME nginx_dir=$nginx_dir SYN_FLOOD=$SYN_FLOOD STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS CONFIG_PATH=$CONFIG_PATH SSH_PORT=$SSH_PORT" -i $PWD/$HOST -t $tags
+ ansible-playbook $PWD/roles/nginx.yml -e "ansible_user=$USER ansible_ssh_pass='$PASS' variable_host=$HOST PROXY=$PROXY CONT_NAME=$CONT_NAME service_dir=$service_dir SYN_FLOOD=$SYN_FLOOD STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS CONFIG_PATH=$CONFIG_PATH SSH_PORT=$SSH_PORT service=nginx" -i $PWD/$HOST -t $tags
else
- ansible-playbook $PWD/roles/nginx.yml --key-file $KEY -e "ansible_user=$USER variable_host=$HOST PROXY=$PROXY CONT_NAME=$CONT_NAME nginx_dir=$nginx_dir SYN_FLOOD=$SYN_FLOOD STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS CONFIG_PATH=$CONFIG_PATH SSH_PORT=$SSH_PORT" -i $PWD/$HOST -t $tags
+ ansible-playbook $PWD/roles/nginx.yml --key-file $KEY -e "ansible_user=$USER variable_host=$HOST PROXY=$PROXY CONT_NAME=$CONT_NAME service_dir=$service_dir SYN_FLOOD=$SYN_FLOOD STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS CONFIG_PATH=$CONFIG_PATH SSH_PORT=$SSH_PORT service=nginx" -i $PWD/$HOST -t $tags
fi
if [ $? -gt 0 ]
then
- echo "error: Can't install Nginx service
"
+ echo "error: Can't install NGINX service
"
exit 1
else
echo "ok"
diff --git a/app/templates/ajax/show_services_ovw.html b/app/templates/ajax/show_services_ovw.html
new file mode 100644
index 00000000..7f951d65
--- /dev/null
+++ b/app/templates/ajax/show_services_ovw.html
@@ -0,0 +1,201 @@
+
+
+ {% if metrics_master == 'active' %}
+
+ {% if role <= 1 %}
+
+ Metrics master
+
+ {% else %}
+ Metrics master
+ {% endif %}
+ {% else %}
+ {% if metrics_master == 'inactive' or metrics_master == 'failed' %}
+
+ {% if role <= 1 %}
+
+ Metrics master
+
+ {% else %}
+ Metrics master
+ {% endif %}
+ {% else %}
+
+
+ Metrics master
+
+ {% endif %}
+ {% endif %}
+ |
+
+ {% if checker_master == 'active' %}
+
+ {% if role <= 1 %}
+
+ Checker master
+
+ {% else %}
+ Checker master
+ {% endif %}
+ {% else %}
+ {% if checker_master == 'inactive' or checker_master == 'failed' %}
+
+ {% if role <= 1 %}
+
+ Checker master
+
+ {% else %}
+ Checker master
+ {% endif %}
+ {% else %}
+
+
+ Checker master
+
+ {% endif %}
+ {% endif %}
+ |
+
+ {% if keep_alive == 'active' %}
+
+ {% if role <= 1 %}
+
+ Auto start
+
+ {% else %}
+ Auto star
+ {% endif %}
+ {% else %}
+ {% if keep_alive == 'inactive' or keep_alive == 'failed' %}
+
+ {% if role <= 1 %}
+
+ Auto start
+
+ {% else %}
+ Auto start
+ {% endif %}
+ {% else %}
+
+
+ Auto start
+
+ {% endif %}
+ {% endif %}
+ |
+
+
+
+ {% if metrics_worker|int() >= 1 %}
+
+ {% else %}
+ {% if is_metrics_worker|int() == 0 %}
+
+ {% else %}
+
+ {% endif %}
+ {% endif %}
+ {% if role <= 1 %}
+
+ Metrics workers
+
+ {% else %}
+ Metrics workers
+ {% endif %}
+ |
+
+ {% if checker_worker|int() >= 1 %}
+
+ {% else %}
+ {% if is_checker_worker|int() == 0 %}
+
+ {% else %}
+
+ {% endif %}
+ {% endif %}
+ {% if role <= 1 %}
+
+ Checker workers
+
+ {% else %}
+ Checker workers
+ {% endif %}
+ |
+
+ {% if smon == 'active' %}
+
+
+ SMON
+
+ {% else %}
+ {% if smon == 'inactive' or smon == 'failed' %}
+
+
+ SMON
+
+ {% else %}
+
+
+ SMON
+
+ {% endif %}
+ {% endif %}
+ |
+
+
+ {% if role == 1 %}
+
+ {% if grafana|int() >= 1 %}
+
+ Grafana
+ {% else %}
+
+ Grafana
+ {% endif %}
+ {% endif %}
+ |
+
+ {% if socket == 'active' %}
+
+ {% if role <= 1 %}
+
+ Socket service
+
+ {% else %}
+ Socket service
+ {% endif %}
+ {% else %}
+ {% if socket == 'inactive' or socket == 'failed' %}
+
+
+ Socket service
+
+ {% else %}
+
+
+ Socket service
+
+ {% endif %}
+ {% endif %}
+ |
+
+ {% if port_scanner == 'active' %}
+
+
+ Port scanner
+
+ {% else %}
+ {% if port_scanner == 'inactive' or port_scanner == 'failed' %}
+
+
+ Port scanner
+
+ {% else %}
+
+
+ Port scanner
+
+ {% endif %}
+ {% endif %}
+ |
+
diff --git a/app/templates/base.html b/app/templates/base.html
index 49ac6d9b..5b578ddd 100644
--- a/app/templates/base.html
+++ b/app/templates/base.html
@@ -159,8 +159,8 @@
-
+
{% endif %}
diff --git a/app/templates/ovw.html b/app/templates/ovw.html
index 0f4b3185..43e3060e 100644
--- a/app/templates/ovw.html
+++ b/app/templates/ovw.html
@@ -92,218 +92,25 @@
-
-
- {% if role <= 1 %}
-
- Roxy-WI services status
-
- {% else %}
- Roxy-WI services status
- {% endif %}
- |
-
-
-
- {% if metrics_master == 'active' %}
-
- {% if role <= 1 %}
-
- Metrics master
-
- {% else %}
- Metrics master
- {% endif %}
- {% else %}
- {% if metrics_master == 'inactive' or metrics_master == 'failed' %}
-
- {% if role <= 1 %}
-
- Metrics master
-
- {% else %}
- Metrics master
- {% endif %}
- {% else %}
-
-
- Metrics master
-
- {% endif %}
- {% endif %}
- |
-
- {% if checker_master == 'active' %}
-
- {% if role <= 1 %}
-
- Checker master
-
- {% else %}
- Checker master
- {% endif %}
- {% else %}
- {% if checker_master == 'inactive' or checker_master == 'failed' %}
-
- {% if role <= 1 %}
-
- Checker master
-
- {% else %}
- Checker master
- {% endif %}
- {% else %}
-
-
- Checker master
-
- {% endif %}
- {% endif %}
- |
-
- {% if keep_alive == 'active' %}
-
- {% if role <= 1 %}
-
- Auto start
-
- {% else %}
- Auto star
- {% endif %}
- {% else %}
- {% if keep_alive == 'inactive' or keep_alive == 'failed' %}
-
- {% if role <= 1 %}
-
- Auto start
-
- {% else %}
- Auto start
- {% endif %}
- {% else %}
-
-
- Auto start
-
- {% endif %}
- {% endif %}
- |
-
-
-
- {% if metrics_worker|int() >= 1 %}
-
- {% else %}
- {% if is_metrics_worker|int() == 0 %}
-
- {% else %}
-
- {% endif %}
- {% endif %}
- {% if role <= 1 %}
-
- Metrics workers
-
- {% else %}
- Metrics workers
- {% endif %}
- |
-
- {% if checker_worker|int() >= 1 %}
-
- {% else %}
- {% if is_checker_worker|int() == 0 %}
-
- {% else %}
-
- {% endif %}
- {% endif %}
- {% if role <= 1 %}
-
- Checker workers
-
- {% else %}
- Checker workers
- {% endif %}
- |
-
- {% if smon == 'active' %}
-
-
- SMON
-
- {% else %}
- {% if smon == 'inactive' or smon == 'failed' %}
-
-
- SMON
-
- {% else %}
-
-
- SMON
-
- {% endif %}
- {% endif %}
- |
-
-
- {% if role == 1 %}
-
- {% if grafana|int() >= 1 %}
-
- Grafana
- {% else %}
-
- Grafana
- {% endif %}
- {% endif %}
- |
-
- {% if socket == 'active' %}
-
+
+
+
{% if role <= 1 %}
-
- Socket service
+
+ Roxy-WI services status
{% else %}
- Socket service
- {% endif %}
- {% else %}
- {% if socket == 'inactive' or socket == 'failed' %}
-
-
- Socket service
-
- {% else %}
-
-
- Socket service
-
+ Roxy-WI services status
{% endif %}
- {% endif %}
- |
-
- {% if port_scanner == 'active' %}
-
-
- Port scanner
+ |
+
+
+
- {% else %}
- {% if port_scanner == 'inactive' or port_scanner == 'failed' %}
-
-
- Port scanner
-
- {% else %}
-
-
- Port scanner
-
- {% endif %}
- {% endif %}
- |
-
+
+
+
+ |
{% if role <= 2 %}
{% if role == 2 %}
diff --git a/app/templates/servers.html b/app/templates/servers.html
index 8572a619..325ffd4a 100644
--- a/app/templates/servers.html
+++ b/app/templates/servers.html
@@ -63,7 +63,7 @@
|
-
+ |
|
{% set values = dict() %}
@@ -125,6 +125,41 @@
|
+
+ Install Apache
+
+ Current version |
+ Available Versions |
+ Server |
+ Use Docker |
+ SYN-flood protection |
+ |
+
+
+
+ |
+
+ Roxy-WI will try to install the latest Apache version from an official Apache repository
+ |
+
+
+ |
+
+ {{ checkbox('apache_docker', title="Install Apache service as a Docker container") }}
+ |
+
+ {{ checkbox('apache_syn_flood', title="Enable SYN-flood protection", checked='checked') }}
+ |
+
+ Install
+ |
+
+
{% endif %}
diff --git a/inc/overview.js b/inc/overview.js
index 9cac1533..0d3f8509 100644
--- a/inc/overview.js
+++ b/inc/overview.js
@@ -65,6 +65,7 @@ function showOverview(serv, hostnamea) {
showOverviewCallBack(serv[i], hostnamea[i])
}
showSubOverview();
+ showServicesOverview();
}
function showOverviewCallBack(serv, hostnamea) {
$.ajax( {
@@ -88,6 +89,28 @@ function showOverviewCallBack(serv, hostnamea) {
}
} );
}
+function showServicesOverview() {
+ $.ajax( {
+ url: "options.py",
+ data: {
+ act: "overviewServices",
+ token: $('#token').val()
+ },
+ beforeSend: function() {
+ $("#services_ovw").html('');
+
+ },
+ type: "POST",
+ success: function( data ) {
+ if (data.indexOf('error:') != '-1') {
+ toastr.error(data);
+ } else {
+ $("#services_ovw").empty();
+ $("#services_ovw").html(data);
+ }
+ }
+ } );
+}
function showOverviewServer(name, ip, id, service) {
$.ajax( {
url: "options.py",
diff --git a/inc/script.js b/inc/script.js
index b83cfd1d..0d133fab 100644
--- a/inc/script.js
+++ b/inc/script.js
@@ -1104,7 +1104,7 @@ $( function() {
$(this).children(".installmon").css('padding-left', '30px');
$(this).children(".installmon").css('border-left', '4px solid var(--right-menu-blue-rolor)');
});
- $( "#tabs" ).tabs( "option", "active", 6 );
+ $( "#tabs" ).tabs( "option", "active", 7 );
} );
$( ".backup" ).on( "click", function() {
$('.menu li ul li').each(function () {
@@ -1113,7 +1113,7 @@ $( function() {
$(this).children(".backup").css('padding-left', '30px');
$(this).children(".backup").css('border-left', '4px solid var(--right-menu-blue-rolor)');
});
- $( "#tabs" ).tabs( "option", "active", 7 );
+ $( "#tabs" ).tabs( "option", "active", 6 );
} );
}
}
diff --git a/inc/users.js b/inc/users.js
index 3bbebf14..30ef00c2 100644
--- a/inc/users.js
+++ b/inc/users.js
@@ -47,49 +47,10 @@ $( function() {
} );
});
$('#nginx_install').click(function() {
- $("#ajax").html('')
- var syn_flood = 0;
- var docker = 0;
- if ($('#nginx_syn_flood').is(':checked')) {
- syn_flood = '1';
- }
- if ($('#nginx_docker').is(':checked')) {
- docker = '1';
- }
- if ($('#nginxaddserv').val() == '------') {
- toastr.warning('Select a server');
- return false
- }
- $("#ajax").html(wait_mess);
- $.ajax( {
- url: "options.py",
- data: {
- install_nginx: $('#nginxaddserv').val(),
- syn_flood: syn_flood,
- docker: docker,
- token: $('#token').val()
- },
- type: "POST",
- success: function( data ) {
- data = data.replace(/\s+/g,' ');
- $("#ajax").html('')
- if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1' || data.indexOf('UNREACHABLE') != '-1') {
- toastr.clear();
- var p_err = show_pretty_ansible_error(data);
- toastr.error(p_err);
- } else if (data.indexOf('success') != '-1' ){
- toastr.clear();
- toastr.success(data);
- $("#nginxaddserv").trigger( "selectmenuchange" );
- } else if (data.indexOf('Info') != '-1' ){
- toastr.clear();
- toastr.info(data);
- } else {
- toastr.clear();
- toastr.info(data);
- }
- }
- } );
+ installService('apache');
+ });
+ $('#apache_install').click(function() {
+ installService('apache');
});
$('#grafna_install').click(function() {
$("#ajaxmon").html('');
@@ -273,53 +234,13 @@ $( function() {
} );
});
$( "#haproxyaddserv" ).on('selectmenuchange',function() {
- $.ajax( {
- url: "options.py",
- data: {
- get_hap_v: 1,
- serv: $('#haproxyaddserv option:selected').val(),
- token: $('#token').val()
- },
- type: "POST",
- success: function( data ) {
- data = data.replace(/^\s+|\s+$/g,'');
- if(data != '') {
- data = data+'-1';
- $('#cur_hap_ver').text(data);
- $('#cur_hap_ver').css('font-weight', 'bold');
- $('#install').text('Update');
- $('#install').attr('title', 'Update HAProxy');
- } else {
- $('#cur_hap_ver').text('HAProxy has not installed');
- $('#install').text('Install');
- $('#install').attr('title', 'Install HAProxy');
- }
- }
- } );
+ showServiceVersion('haproxy');
});
$( "#nginxaddserv" ).on('selectmenuchange',function() {
- $.ajax( {
- url: "options.py",
- data: {
- get_nginx_v: 1,
- serv: $('#nginxaddserv option:selected').val(),
- token: $('#token').val()
- },
- 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') {
- $('#cur_nginx_ver').text('Nginx has not installed');
- $('#nginx_install').text('Install');
- $('#nginx_install').attr('title', 'Install Nginx');
- } else {
- $('#cur_nginx_ver').text(data);
- $('#cur_nginx_ver').css('font-weight', 'bold');
- $('#nginx_install').text('Update');
- $('#nginx_install').attr('title', 'Update Nginx');
- }
- }
- } );
+ showServiceVersion('nginx');
+ });
+ $( "#apacheaddserv" ).on('selectmenuchange',function() {
+ showServiceVersion('apache');
});
$( "#haproxy_exp_addserv" ).on('selectmenuchange',function() {
$.ajax( {
@@ -2931,3 +2852,74 @@ function checkGeoipInstallation() {
}
} );
}
+function installService(service){
+ $("#ajax").html('')
+ var syn_flood = 0;
+ var docker = 0;
+ if ($('#'+service+'_syn_flood').is(':checked')) {
+ syn_flood = '1';
+ }
+ if ($('#'+service+'_docker').is(':checked')) {
+ docker = '1';
+ }
+ if ($('#'+service+'addserv').val() == '------') {
+ toastr.warning('Select a server');
+ return false
+ }
+ $("#ajax").html(wait_mess);
+ $.ajax( {
+ url: "options.py",
+ data: {
+ install_service: $('#' + service + 'ddserv').val(),
+ syn_flood: syn_flood,
+ docker: docker,
+ token: $('#token').val()
+ },
+ type: "POST",
+ success: function( data ) {
+ data = data.replace(/\s+/g,' ');
+ $("#ajax").html('')
+ if (data.indexOf('error:') != '-1' || data.indexOf('FAILED') != '-1' || data.indexOf('UNREACHABLE') != '-1') {
+ toastr.clear();
+ var p_err = show_pretty_ansible_error(data);
+ toastr.error(p_err);
+ } else if (data.indexOf('success') != '-1' ){
+ toastr.clear();
+ toastr.success(data);
+ $('#'+service+'addserv').trigger( "selectmenuchange" );
+ } else if (data.indexOf('Info') != '-1' ){
+ toastr.clear();
+ toastr.info(data);
+ } else {
+ toastr.clear();
+ toastr.info(data);
+ }
+ }
+ } );
+}
+function showServiceVersion(service) {
+ $.ajax({
+ url: "options.py",
+ data: {
+ get_service_v: service,
+ serv: $('#'+service+'addserv option:selected').val(),
+ token: $('#token').val()
+ },
+ 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') {
+ $('#cur_'+service+'_ver').text(service+' has not installed');
+ $('#'+service+'_install').text('Install');
+ $('#'+service+'_install').attr('title', 'Install');
+ } else if (data.indexOf('warning: ') != '-1') {
+ toastr.warning(data);
+ } else {
+ $('#cur_'+service+'_ver').text(data);
+ $('#cur_'+service+'_ver').css('font-weight', 'bold');
+ $('#'+service+'_install').text('Update');
+ $('#'+service+'_install').attr('title', 'Update');
+ }
+ }
+ } );
+}