Bugs fixed
pull/19/head
Aidaho12 2018-04-28 13:34:45 +06:00
parent 5cdf827e1d
commit aafd430cb2
9 changed files with 47 additions and 15 deletions

View File

@ -76,16 +76,17 @@ MariaDB [(none)]> grant all on haproxywi.* to 'haproxy-wi'@'localhost' IDENTIFIE
``` ```
Edit $HOME_HAPROXY-WI/cgi-bin/haproxy-webintarface.config with your env Edit $HOME_HAPROXY-WI/cgi-bin/haproxy-webintarface.config with your env
``` ```
Copy ssh key on all HAproxy servers
Login http://haproxy-wi-server/users.py, and add: users, groups and servers. Default: admin/admin Login http://haproxy-wi-server/users.py, and add: users, groups and servers. Default: admin/admin
![alt text](image/haproxy-wi-admin-area.jpeg "Admin area") ![alt text](image/haproxy-wi-admin-area.jpeg "Admin area")
Copy ssh key on all HAproxy servers For Runtime API enable state file on HAproxt servers and need install socat on all haproxy servers, and configre HAProxy:
For Runtime API enable state file on HAproxt servers and need install socat on all haproxy servers:
``` ```
global global
stats socket *:1999 level admin stats socket *:1999 level admin
stats socket /var/run/haproxy.sock mode 600 level admin
server-state-file /etc/haproxy/haproxy/haproxy.state server-state-file /etc/haproxy/haproxy/haproxy.state
defaults defaults
load-server-state-from-file global load-server-state-from-file global
@ -97,6 +98,25 @@ For Runtime API enable state file on HAproxt servers and need install socat on a
$ cd /var/www/haproxy-wi/cgi-bin $ cd /var/www/haproxy-wi/cgi-bin
$ ./update_db.py $ ./update_db.py
``` ```
# Troubleshooting
If you have error:
```
Forbidden
You don't have permission to access /cgi-bin/overview.py on this server.
```
Check owner(must be apache, or another user for apache)
If at first login you have:
```
Internal Server Error
```
Do this:
```
$ cd /var/www/haproxy-wi
$ ./update_db.py
```
# Further development and support # Further development and support

View File

@ -40,13 +40,13 @@ def check_db():
try: try:
cur.execute(sql) cur.execute(sql)
except sqltool.Error as err: except sqltool.Error as err:
#print('<div class="alert alert-danger">') print('<div class="alert alert-danger">')
#if err.errno == errorcode.ER_ACCESS_DENIED_ERROR: if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
# print("Something is wrong with your user name or password") print("Something is wrong with your user name or password")
#elif err.errno == errorcode.ER_BAD_DB_ERROR: elif err.errno == errorcode.ER_BAD_DB_ERROR:
# print("Database does not exist") print("Database does not exist")
#else: else:
# print(err) print(err)
print('</div>') print('</div>')
return True return True
else: else:

View File

@ -319,7 +319,7 @@ def ssh_connect(serv):
def get_config(serv, cfg, **kwargs): def get_config(serv, cfg, **kwargs):
if kwargs.get("keepalived"): if kwargs.get("keepalived"):
os.chdir("/var/www/haproxy-wi/cgi-bin/kp_config/") os.chdir("/var/www/haproxy-wi/cgi-bin/kp_config/")
config_path = "/etc/keepalived/keepalived.conf" config_path = config.get('configs', 'kp_save_configs_dir')
else: else:
os.chdir(hap_configs_dir) os.chdir(hap_configs_dir)
config_path = haproxy_config_path config_path = haproxy_config_path

View File

@ -45,7 +45,7 @@ print('</select>'
'<input type="text" id="vrrp-ip" class="form-control">' '<input type="text" id="vrrp-ip" class="form-control">'
'</td>' '</td>'
'<td>' '<td>'
'<label for="hap"></label><input type="checkbox" checked id="hap">' '<label for="hap"></label><input type="checkbox" id="hap">'
'</td>' '</td>'
'<td>' '<td>'
'<a class="ui-button ui-widget ui-corner-all" id="create" title="Create HA configuration">Create</a>' '<a class="ui-button ui-widget ui-corner-all" id="create" title="Create HA configuration">Create</a>'

View File

@ -11,6 +11,7 @@ time_zone = UTC
haproxy_configs_server = localhost haproxy_configs_server = localhost
#Dir where configs will be save #Dir where configs will be save
haproxy_save_configs_dir = ${main:fullpath}/cgi-bin/hap_config/ haproxy_save_configs_dir = ${main:fullpath}/cgi-bin/hap_config/
kp_save_configs_dir = ${main:fullpath}/cgi-bin/kp_config/
[mysql] [mysql]
#Enable MySQL DB. If default will be used Sqlite DB. Default disable #Enable MySQL DB. If default will be used Sqlite DB. Default disable

View File

@ -23,7 +23,7 @@ config = ConfigParser(interpolation=ExtendedInterpolation())
config.read(path_config) config.read(path_config)
log_path = config.get('main', 'log_path') log_path = config.get('main', 'log_path')
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir') kp_save_configs_dir = config.get('configs', 'kp_save_configs_dir')
print('<h2>Edit Running Keepalived config</h2>' print('<h2>Edit Running Keepalived config</h2>'
'<center>' '<center>'
@ -49,7 +49,7 @@ funct.get_button("Open", value="open")
print('</form>') print('</form>')
if serv is not None: if serv is not None:
cfg = '/var/www/haproxy-wi/cgi-bin/kp_config/'+ serv + '-' + funct.get_data('config') + '.conf' cfg = kp_save_configs_dir+ serv + '-' + funct.get_data('config') + '.conf'
if form.getvalue('serv') is not None and form.getvalue('open') is not None : if form.getvalue('serv') is not None and form.getvalue('open') is not None :

View File

@ -1,6 +1,10 @@
#!/bin/bash #!/bin/bash
yum install haproxy -y > /dev/null yum install haproxy socat -y > /dev/null
if [ -f /etc/haproxy/haproxy.cfg ];then
echo -e "error: Haproxy alredy installed"
exit 1
fi
echo "" > /etc/haproxy/haproxy.cfg echo "" > /etc/haproxy/haproxy.cfg
cat << EOF > /etc/haproxy/haproxy.cfg cat << EOF > /etc/haproxy/haproxy.cfg
global global
@ -13,6 +17,7 @@ global
daemon daemon
stats socket /var/lib/haproxy/stats stats socket /var/lib/haproxy/stats
stats socket *:1999 level admin stats socket *:1999 level admin
stats socket /var/run/haproxy.sock mode 600 level admin
defaults defaults
mode http mode http

View File

@ -1,6 +1,11 @@
#!/bin/bash #!/bin/bash
CONF=/etc/keepalived/keepalived.conf CONF=/etc/keepalived/keepalived.conf
if [ -f $CONF ];then
echo -e "error: Keepalived alredy installed"
exit 1
fi
yum install keepalived -y > /dev/null yum install keepalived -y > /dev/null
if [ $? -eq 1 ] if [ $? -eq 1 ]
then then

View File

@ -16,4 +16,5 @@ else:
db = "haproxy-wi.db" db = "haproxy-wi.db"
import sqlite3 as sqltool import sqlite3 as sqltool
create_db.create_table()
create_db.update_all() create_db.update_all()