mirror of https://github.com/Aidaho12/haproxy-wi
v3.9.2
parent
f8cc5dbc1d
commit
b045b2aafc
|
@ -134,6 +134,7 @@ For Apache do virtualhost with cgi-bin. Like this:
|
|||
ScriptAlias /cgi-bin/ "/var/www/haproxy-wi/app/"
|
||||
|
||||
<Directory /var/www/haproxy-wi/app>
|
||||
DirectoryIndex overview.py
|
||||
Options +ExecCGI
|
||||
AddHandler cgi-script .py
|
||||
Order deny,allow
|
||||
|
@ -213,6 +214,11 @@ For Runtime API, Metrics and Alerting enable state file and stat socket on HApro
|
|||
load-server-state-from-file global
|
||||
|
||||
listen stats
|
||||
bind *:8085
|
||||
stats enable
|
||||
stats uri /stats
|
||||
stats realm HAProxy-04\ Statistics
|
||||
stats auth admin:password
|
||||
stats admin if TRUE
|
||||
```
|
||||
![alt text](image/haproxy-wi-logs.png "View logs page")
|
||||
|
|
|
@ -459,7 +459,7 @@ def update_db_v_3_8_1(**kwargs):
|
|||
|
||||
def update_ver(**kwargs):
|
||||
con, cur = get_cur()
|
||||
sql = """update version set version = '3.9.1'; """
|
||||
sql = """update version set version = '3.9.2'; """
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
|
|
28
app/funct.py
28
app/funct.py
|
@ -157,9 +157,8 @@ def page_for_admin(**kwargs):
|
|||
import sys
|
||||
sys.exit()
|
||||
|
||||
def ssh_connect(serv, **kwargs):
|
||||
import paramiko
|
||||
from paramiko import SSHClient
|
||||
|
||||
def return_ssh_keys_path(serv):
|
||||
import sql
|
||||
fullpath = get_config_var('main', 'fullpath')
|
||||
ssh_enable = ''
|
||||
|
@ -173,6 +172,16 @@ def ssh_connect(serv, **kwargs):
|
|||
ssh_user_password = sshs[5]
|
||||
ssh_key_name = fullpath+'/keys/%s.pem' % sshs[2]
|
||||
|
||||
return ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name
|
||||
|
||||
|
||||
def ssh_connect(serv, **kwargs):
|
||||
import paramiko
|
||||
from paramiko import SSHClient
|
||||
import sql
|
||||
|
||||
ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = return_ssh_keys_path(serv)
|
||||
|
||||
servers = sql.select_servers(server=serv)
|
||||
for server in servers:
|
||||
ssh_port = server[10]
|
||||
|
@ -339,17 +348,10 @@ def install_haproxy(serv, **kwargs):
|
|||
stats_password = sql.get_setting('stats_password')
|
||||
proxy = sql.get_setting('proxy')
|
||||
hapver = kwargs.get('hapver')
|
||||
fullpath = get_config_var('main', 'fullpath')
|
||||
ssh_enable = ''
|
||||
ssh_port = ''
|
||||
ssh_user_name = ''
|
||||
ssh_user_password = ''
|
||||
ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = return_ssh_keys_path(serv)
|
||||
|
||||
for sshs in sql.select_ssh(serv=serv):
|
||||
ssh_enable = sshs[3]
|
||||
ssh_user_name = sshs[4]
|
||||
ssh_user_password = sshs[5]
|
||||
ssh_key_name = fullpath+'/keys/%s.pem' % sshs[2]
|
||||
if ssh_enable == 0:
|
||||
ssh_key_name = ''
|
||||
|
||||
os.system("cp scripts/%s ." % script)
|
||||
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>HAProxy-WI</title>
|
||||
<link href="/inc/images/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="shortcut icon" href="/inc/images/favicon.ico" type="image/x-icon">
|
||||
<link href="/inc/style.css" rel="stylesheet">
|
||||
<link href="/inc/nprogress.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="/inc/jquery-ui.css">
|
||||
<script src="/inc/jquery-1.12.4.js"></script>
|
||||
<script src="/inc/jquery-ui.js"></script>
|
||||
<script src="/inc/nprogress.js"></script>
|
||||
<meta http-equiv="refresh" content="0; url=/app/overview.py" />
|
||||
</head>
|
||||
<body style="background-color: #239dee;">
|
||||
<script>
|
||||
$( function() {
|
||||
NProgress.start();
|
||||
$('#cover').fadeIn('fast');
|
||||
});
|
||||
</script>
|
||||
<div id="cover"></div>
|
||||
<center>
|
||||
<div style="color: white;">
|
||||
<h1 style="font-size: 100px;">Welcome to</h1>
|
||||
<img src="/inc/images/logo_index.png" alt="logo" style="margin-top: -50px;display: block;padding-bottom: 70px;" />
|
||||
<b style="font-size: 30px;">Redirecting... Please wait</b>
|
||||
</div>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
|
@ -582,19 +582,13 @@ if form.getvalue('master'):
|
|||
script = "install_keepalived.sh"
|
||||
fullpath = funct.get_config_var('main', 'fullpath')
|
||||
proxy = sql.get_setting('proxy')
|
||||
ssh_enable = ''
|
||||
ssh_port = ''
|
||||
ssh_user_name = ''
|
||||
ssh_user_password = ''
|
||||
ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = funct.return_ssh_keys_path(master)
|
||||
|
||||
if ssh_enable == 0:
|
||||
ssh_key_name = ''
|
||||
|
||||
proxy_serv = proxy if proxy is not None else ""
|
||||
|
||||
for sshs in sql.select_ssh(serv=master):
|
||||
ssh_enable = sshs[3]
|
||||
ssh_user_name = sshs[4]
|
||||
ssh_user_password = sshs[5]
|
||||
ssh_key_name = fullpath+'/keys/%s.pem' % sshs[2]
|
||||
|
||||
os.system("cp scripts/%s ." % script)
|
||||
|
||||
if form.getvalue('hap') == "1":
|
||||
|
@ -624,11 +618,10 @@ if form.getvalue('master'):
|
|||
else:
|
||||
print('success: Master Keepalived was installed<br>')
|
||||
|
||||
for sshs in sql.select_ssh(serv=slave):
|
||||
ssh_enable = sshs[3]
|
||||
ssh_user_name = sshs[4]
|
||||
ssh_user_password = sshs[5]
|
||||
ssh_key_name = fullpath+'/keys/%s.pem' % sshs[2]
|
||||
ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = funct.return_ssh_keys_path(slave)
|
||||
|
||||
if ssh_enable == 0:
|
||||
ssh_key_name = ''
|
||||
|
||||
commands = [ "chmod +x "+script +" && ./"+script +" PROXY=" +proxy_serv+
|
||||
" ETH="+ETH+" IP="+IP+" MASTER=BACKUP"+" HOST="+str(slave)+
|
||||
|
@ -664,20 +657,11 @@ if form.getvalue('masteradd'):
|
|||
IP = form.getvalue('vrrpipadd')
|
||||
kp = form.getvalue('kp')
|
||||
script = "install_keepalived.sh"
|
||||
fullpath = funct.get_config_var('main', 'fullpath')
|
||||
proxy = sql.get_setting('proxy')
|
||||
ssh_enable = ''
|
||||
ssh_port = ''
|
||||
ssh_user_name = ''
|
||||
ssh_user_password = ''
|
||||
ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = funct.return_ssh_keys_path(master)
|
||||
|
||||
proxy_serv = proxy if proxy is not None else ""
|
||||
|
||||
for sshs in sql.select_ssh(serv=master):
|
||||
ssh_enable = sshs[3]
|
||||
ssh_user_name = sshs[4]
|
||||
ssh_user_password = sshs[5]
|
||||
ssh_key_name = fullpath+'/keys/%s.pem' % sshs[2]
|
||||
if ssh_enable == 0:
|
||||
ssh_key_name = ''
|
||||
|
||||
os.system("cp scripts/%s ." % script)
|
||||
|
||||
|
@ -705,11 +689,10 @@ if form.getvalue('masteradd'):
|
|||
print('success: Master VRRP address was added<br>')
|
||||
|
||||
|
||||
for sshs in sql.select_ssh(serv=slave):
|
||||
ssh_enable = sshs[3]
|
||||
ssh_user_name = sshs[4]
|
||||
ssh_user_password = sshs[5]
|
||||
ssh_key_name = fullpath+'/keys/%s.pem' % sshs[2]
|
||||
ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = funct.return_ssh_keys_path(slave)
|
||||
|
||||
if ssh_enable == 0:
|
||||
ssh_key_name = ''
|
||||
|
||||
commands = [ "chmod +x "+script +" && ./"+script +" PROXY=" + proxy_serv+
|
||||
" ETH="+ETH+" IP="+str(IP)+" MASTER=BACKUP"+" RESTART="+kp+" ADD_VRRP=1 HOST="+str(slave)+
|
||||
|
@ -781,8 +764,6 @@ if form.getvalue('new_metrics'):
|
|||
for i in metric:
|
||||
label = str(i[5])
|
||||
label = label.split(' ')[1]
|
||||
#label = label.split(':')
|
||||
#labels += label[0]+':'+label[1]+','
|
||||
labels += label+','
|
||||
curr_con += str(i[1])+','
|
||||
curr_ssl_con += str(i[2])+','
|
||||
|
@ -811,7 +792,6 @@ if form.getvalue('new_waf_metrics'):
|
|||
for i in metric:
|
||||
label = str(i[2])
|
||||
label = label.split(' ')[1]
|
||||
# label = label.split(':')
|
||||
labels += label[0]+','
|
||||
curr_con += str(i[1])+','
|
||||
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
manager: "auto"
|
||||
|
||||
|
||||
- name: populate service facts
|
||||
service_facts:
|
||||
|
||||
|
||||
- name: install HAProxy {{HAPVER}}
|
||||
yum:
|
||||
name:
|
||||
|
@ -95,6 +99,27 @@
|
|||
haproxy_version: "{{ '1.5' if '1.5.' in haproxy_version_result.stdout else '1.6' }}"
|
||||
|
||||
|
||||
- name: Open stat port for firewalld
|
||||
firewalld:
|
||||
port: "{{ item }}/tcp"
|
||||
state: enabled
|
||||
permanent: yes
|
||||
immediate: yes
|
||||
ignore_errors: yes
|
||||
when: ansible_facts.services["firewalld.service"]['state'] == "running"
|
||||
with_items: [ "{{ STAT_PORT }}", "{{ SOCK_PORT }}" ]
|
||||
|
||||
|
||||
- name: Open stat port for iptables
|
||||
iptables:
|
||||
chain: INPUT
|
||||
destination_port: "{{ item }}"
|
||||
jump: ACCEPT
|
||||
protocol: tcp
|
||||
ignore_errors: yes
|
||||
with_items: [ "{{ STAT_PORT }}", "{{ SOCK_PORT }}" ]
|
||||
|
||||
|
||||
- name: Copy HAProxy configuration in place.
|
||||
template:
|
||||
src: haproxy.cfg.j2
|
||||
|
|
|
@ -27,7 +27,7 @@ then
|
|||
fi
|
||||
|
||||
if [ -f $HAPROXY_PATH/waf/modsecurity.conf ];then
|
||||
echo -e 'error: Haproxy WAF already installed. You can edit config<a href="/app/config.py" title="Edit HAProxy config">here</a> <br /><br />'
|
||||
echo -e 'error: Haproxy WAF already installed. <br /><br />'
|
||||
exit 1
|
||||
fi
|
||||
if hash apt-get 2>/dev/null; then
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
DocumentRoot /var/www/haproxy-wi
|
||||
ScriptAlias /cgi-bin/ "/var/www/haproxy-wi/app/"
|
||||
|
||||
|
||||
<Directory /var/www/haproxy-wi/app>
|
||||
DirectoryIndex overview.py
|
||||
Options +ExecCGI
|
||||
AddHandler cgi-script .py
|
||||
Order deny,allow
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 66 KiB |
20
index.html
20
index.html
|
@ -3,8 +3,24 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>HAProxy-WI</title>
|
||||
<link href="/inc/images/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="shortcut icon" href="/inc/images/favicon.ico" type="image/x-icon">
|
||||
<link href="/inc/images/favicon/favicon.ico" rel="icon" type="image/png" />
|
||||
<link rel="apple-touch-icon" sizes="57x57" href="/inc/images/favicon/inc/images/favicon/apple-icon-57x57.png">
|
||||
<link rel="apple-touch-icon" sizes="60x60" href="/inc/images/favicon/apple-icon-60x60.png">
|
||||
<link rel="apple-touch-icon" sizes="72x72" href="/inc/images/favicon/apple-icon-72x72.png">
|
||||
<link rel="apple-touch-icon" sizes="76x76" href="/inc/images/favicon/apple-icon-76x76.png">
|
||||
<link rel="apple-touch-icon" sizes="114x114" href="/inc/images/favicon/apple-icon-114x114.png">
|
||||
<link rel="apple-touch-icon" sizes="120x120" href="/inc/images/favicon/apple-icon-120x120.png">
|
||||
<link rel="apple-touch-icon" sizes="144x144" href="/inc/images/favicon/apple-icon-144x144.png">
|
||||
<link rel="apple-touch-icon" sizes="152x152" href="/inc/images/favicon/apple-icon-152x152.png">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/inc/images/favicon/apple-icon-180x180.png">
|
||||
<link rel="icon" type="image/png" sizes="192x192" href="/inc/images/favicon/android-icon-192x192.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/inc/images/favicon/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="96x96" href="/inc/images/favicon/favicon-96x96.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/inc/images/favicon/favicon-16x16.png">
|
||||
<link rel="manifest" href="/inc/images/favicon/manifest.json">
|
||||
<meta name="msapplication-TileColor" content="#ffffff">
|
||||
<meta name="msapplication-TileImage" content="/inc/images/favicon/ms-icon-144x144.png">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
<link href="/inc/style.css" rel="stylesheet">
|
||||
<link href="/inc/nprogress.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="/inc/jquery-ui.css">
|
||||
|
|
Loading…
Reference in New Issue