pull/189/head
Pavel Loginov 2019-11-28 19:39:24 +03:00
parent 187b6e4e19
commit 0e44da5089
9 changed files with 116 additions and 59 deletions

View File

@ -12,7 +12,7 @@ Web interface(user-friendly web GUI, alerting, monitoring and secure) for managi
# Demo site # Demo site
[Demo site](https://demo.haproxy-wi.org) Login/password: admin/admin. Server resets every hour. [Demo site](https://demo.haproxy-wi.org) Login/password: admin/admin. Server resets every hour.
![alt text](image/haproxy-wi-config-show.jpeg "Show config page") ![alt text](image/haproxy-wi-config-show.png "Show config page")
# Features: # Features:
1. Configure HAProxy In a jiffy with haproxy-wi 1. Configure HAProxy In a jiffy with haproxy-wi
@ -20,17 +20,17 @@ Web interface(user-friendly web GUI, alerting, monitoring and secure) for managi
3. Enable/disable servers through stats page without rebooting HAProxy 3. Enable/disable servers through stats page without rebooting HAProxy
4. View/Analyse HAproxy logs straight from the haproxy-wi web interface 4. View/Analyse HAproxy logs straight from the haproxy-wi web interface
5. Create and visualise the HAproxy workflow from Web Ui. 5. Create and visualise the HAproxy workflow from Web Ui.
6. Push Your changes to your HAproxy servers with a single click through web interface. 6. Push Your changes to your HAproxy servers with a single click through web interface
7. Get info on past changes, Evaluate your config files and restore a previous stable config anytime with a single click straight from Web interface. 7. Get info on past changes, Evaluate your config files and restore a previous stable config anytime with a single click straight from Web interface
8. Add/Edit Frontend or backend servers via web interface with a click of a button. 8. Add/Edit Frontend or backend servers via web interface with a click of a button.
9. Edit config of HAproxy and push changes to All Master/Slave server with a single click. 9. Edit config of HAProxy and push changes to All Master/Slave server with a single click
10. Add Multiple server to ensure Config Sync between servers. 10. Add Multiple server to ensure Config Sync between servers.
11. Auto management of ports assigned to Fronted. 11. Auto management of ports assigned to Fronted.
12. Evaluate the changes of recent configs pushed to HAproxy instances straight from web ui 12. Evaluate the changes of recent configs pushed to HAproxy instances straight from web ui
13. Multiple User Roles support for privileged based Viewing and editing of Config. 13. Multiple User Roles support for privileged based Viewing and editing of Config
14. Create Groups and add /remove servers to ensure proper identification for your HAproxy Clusters 14. Create Groups and add /remove servers to ensure proper identification for your HAproxy Clusters
15. Send notifications to telegram directly from haproxy-wi. 15. Send notifications to telegram directly from HAProxy-WI
16. HAProxy-WI supports high Availability to ensure uptime to all Master slave servers configured. 16. HAProxy-WI supports high Availability to ensure uptime to all Master slave servers configured
17. SSL certificate support. 17. SSL certificate support.
18. SSH Key support for managing multiple HAproxy Servers straight from haproxy-wi 18. SSH Key support for managing multiple HAproxy Servers straight from haproxy-wi
19. SYN flood protect 19. SYN flood protect
@ -44,6 +44,7 @@ Web interface(user-friendly web GUI, alerting, monitoring and secure) for managi
27. Ability to hide parts of the config with tags for users with "guest" role: "HideBlockStart" and "HideBlockEnd" 27. Ability to hide parts of the config with tags for users with "guest" role: "HideBlockStart" and "HideBlockEnd"
28. Mobile-ready desing 28. Mobile-ready desing
29. REST API 29. REST API
30. Installation and Upgrading HAProxy service via HAProxy-WI
![alt text](image/haproxy-wi-metrics.png "Merics") ![alt text](image/haproxy-wi-metrics.png "Merics")
@ -73,6 +74,7 @@ $ chown -R apache:apache haproxy-wi/
Or if use Debian/Ubuntu: Or if use Debian/Ubuntu:
$ sudo apt-get install git net-tools lshw dos2unix apache2 gcc netcat python3.5 python3.5-mod_wsgi mod_ssl python3-pip g++ freetype2-demos libatlas-base-dev openldap-dev libpq-dev python-dev libxml2-dev libxslt1-dev libldap2-dev libsasl2-dev libffi-dev python3-dev libssl-dev ansible -y $ sudo apt-get install git net-tools lshw dos2unix apache2 gcc netcat python3.5 python3.5-mod_wsgi mod_ssl python3-pip g++ freetype2-demos libatlas-base-dev openldap-dev libpq-dev python-dev libxml2-dev libxslt1-dev libldap2-dev libsasl2-dev libffi-dev python3-dev libssl-dev ansible -y
$ git clone https://github.com/Aidaho12/haproxy-wi.git /var/www/haproxy-wi
$ chown -R www-data:www-data haproxy-wi/ $ chown -R www-data:www-data haproxy-wi/
Both Both

View File

@ -438,7 +438,7 @@ def update_db_v_3_5_3(**kwargs):
def update_ver(**kwargs): def update_ver(**kwargs):
con, cur = get_cur() con, cur = get_cur()
sql = """update version set version = '3.7.4'; """ sql = """update version set version = '3.8'; """
try: try:
cur.execute(sql) cur.execute(sql)
con.commit() con.commit()

View File

@ -614,10 +614,14 @@ if form.getvalue('master'):
else: else:
for l in output: for l in output:
if "msg" in l or "FAILED" in l: if "msg" in l or "FAILED" in l:
l = l.split(':')[1] try:
l = l.split('"')[1] l = l.split(':')[1]
print(l+"<br>") l = l.split('"')[1]
break print(l+"<br>")
break
except:
print(output)
break
else: else:
print('success: Master Keepalived was installed<br>') print('success: Master Keepalived was installed<br>')
@ -639,10 +643,14 @@ if form.getvalue('master'):
else: else:
for l in output: for l in output:
if "msg" in l or "FAILED" in l: if "msg" in l or "FAILED" in l:
l = l.split(':')[1] try:
l = l.split('"')[1] l = l.split(':')[1]
print(l+"<br>") l = l.split('"')[1]
break print(l+"<br>")
break
except:
print(output)
break
else: else:
print('success: Slave Keepalived was installed<br>') print('success: Slave Keepalived was installed<br>')
@ -686,10 +694,14 @@ if form.getvalue('masteradd'):
else: else:
for l in output: for l in output:
if "msg" in l or "FAILED" in l: if "msg" in l or "FAILED" in l:
l = l.split(':')[1] try:
l = l.split('"')[1] l = l.split(':')[1]
print(l+"<br>") l = l.split('"')[1]
break print(l+"<br>")
break
except:
print(output)
break
else: else:
print('success: Master VRRP address was added<br>') print('success: Master VRRP address was added<br>')
@ -712,10 +724,14 @@ if form.getvalue('masteradd'):
else: else:
for l in output: for l in output:
if "msg" in l or "FAILED" in l: if "msg" in l or "FAILED" in l:
l = l.split(':')[1] try:
l = l.split('"')[1] l = l.split(':')[1]
print(l+"<br>") l = l.split('"')[1]
break print(l+"<br>")
break
except:
print(output)
break
else: else:
print('success: Slave VRRP address was added<br>') print('success: Slave VRRP address was added<br>')

View File

@ -1,19 +1,9 @@
--- ---
- name: check if HAProxy is installed - name: check if HAProxy is installed Ubuntu
yum: package_facts:
list=haproxy manager: "auto"
register: is_installed
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS')
- name: HAProxy has already installed
debug:
msg: "HAProxy has already installed"
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and is_installed.results|selectattr("yumstate", "match", "installed")|list|length != 0
- name: Exiting
meta: end_play
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and is_installed.results|selectattr("yumstate", "match", "installed")|list|length != 0
- name: install HAProxy {{HAPVER}} - name: install HAProxy {{HAPVER}}
yum: yum:
name: name:
@ -69,15 +59,41 @@
https_proxy: "{{PROXY}}" https_proxy: "{{PROXY}}"
- name: Change wrong HAProxy service file
template:
src: haproxy.service.j2
dest: /usr/lib/systemd/system/haproxy.service
mode: 0644
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and haproxy_from_wi is defined
- name: Enable and start service HAProxy
systemd:
name: haproxy
daemon_reload: yes
state: started
enabled: yes
force: no
ignore_errors: yes
when: "'haproxy' in ansible_facts.packages"
- name: Exiting
meta: end_play
when: "'haproxy' in ansible_facts.packages"
- name: Get HAProxy version. - name: Get HAProxy version.
command: haproxy -v command: haproxy -v
register: haproxy_version_result register: haproxy_version_result
changed_when: false changed_when: false
check_mode: false check_mode: false
- name: Set HAProxy version. - name: Set HAProxy version.
set_fact: set_fact:
haproxy_version: "{{ '1.5' if '1.5.' in haproxy_version_result.stdout else '1.6' }}" haproxy_version: "{{ '1.5' if '1.5.' in haproxy_version_result.stdout else '1.6' }}"
- name: Copy HAProxy configuration in place. - name: Copy HAProxy configuration in place.
template: template:
@ -88,14 +104,6 @@
notify: restart haproxy notify: restart haproxy
- name: Change wrong HAProxy service file
template:
src: haproxy.service.j2
dest: /usr/lib/systemd/system/haproxy.service
mode: 0644
when: haproxy_from_wi is defined
- name: Enable and start service HAProxy - name: Enable and start service HAProxy
systemd: systemd:
name: haproxy name: haproxy
@ -105,7 +113,8 @@
force: no force: no
ignore_errors: yes ignore_errors: yes
- name: Add syn_flood tasks - name: Add syn_flood tasks
include: syn_flood.yml include: syn_flood.yml
when: (SYN_FLOOD is defined) and (SYN_FLOOD|length > 0) when: (SYN_FLOOD is defined) and (SYN_FLOOD|length > 0)

View File

@ -1,18 +1,17 @@
--- ---
- name: check if Keepalived is installed - name: check if Keepalived is installed
yum: package_facts:
list=keepalived manager: "auto"
register: is_installed
when: (ansible_facts['os_family'] == "RedHat") or (ansible_facts['os_family'] == 'CentOS')
- name: Keepalived has already installed - name: Keepalived has already installed
debug: debug:
msg: "Keepalived has already installed" msg: "Keepalived has already installed"
when: is_installed.results|selectattr("yumstate", "match", "installed")|list|length != 0 when: "'keepalived' in ansible_facts.packages"
- name: Exiting - name: Exiting
meta: end_play meta: end_play
when: (ansible_facts['os_family'] == "RedHat") or (ansible_facts['os_family'] == 'CentOS') and is_installed.results|selectattr("yumstate", "match", "installed")|list|length != 0 when: "'keepalived' in ansible_facts.packages"
- name: install the latest version of Keepalived - name: install the latest version of Keepalived
@ -65,4 +64,4 @@
- name: Add syn_flood tasks - name: Add syn_flood tasks
include: ../../haproxy/tasks/syn_flood.yml include: ../../haproxy/tasks/syn_flood.yml
when: (SYN_FLOOD is defined) and (SYN_FLOOD|length > 0) when: (SYN_FLOOD is defined) and (SYN_FLOOD|length > 0)

View File

@ -273,16 +273,19 @@
<div id="installhaproxy"> <div id="installhaproxy">
<table class="overview"> <table class="overview">
<tr class="overviewHead"> <tr class="overviewHead">
<td class="padding10 first-collumn" style="width: 35%;">Version</td> <td class="padding10 first-collumn">Current version</td>
<td class="padding10 first-collumn" style="width: 25%;">Available Versions</td>
<td class="padding10 first-collumn" style="width: 35%;">Server</td> <td class="padding10 first-collumn" style="width: 35%;">Server</td>
<td>SYN flood protect</td> <td>SYN flood protect</td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td id="cur_hap_ver" class="padding10 first-collumn">
</td>
<td class="padding10 first-collumn" style="width: 20%;"> <td class="padding10 first-collumn" style="width: 20%;">
{% set values = dict() %} {% set values = dict() %}
{% set values = {'2.0.5-1':'2.0.5-1','2.0.6-1':'2.0.6-1', '2.0.7-1':'2.0.7-1'} %} {% set values = {'2.0.5-1':'2.0.5-1','2.0.6-1':'2.0.6-1', '2.0.7-1':'2.0.7-1', '2.0.9-1':'2.0.9-1'} %}
{{ select('hapver', values=values, selected='2.0.7-1', required='required') }} {{ select('hapver', values=values, selected='2.0.9-1', required='required') }}
</td> </td>
<td class="padding10 first-collumn"> <td class="padding10 first-collumn">
<select autofocus required name="haproxyaddserv" id="haproxyaddserv"> <select autofocus required name="haproxyaddserv" id="haproxyaddserv">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

View File

@ -824,6 +824,36 @@ $( function() {
} ); } );
} }
} }
$( "#haproxyaddserv" ).on('selectmenuchange',function() {
$.ajax( {
url: "options.py",
data: {
get_hap_v: 1,
serv: $('#haproxyaddserv option:selected').val(),
token: $('#token').val()
},
type: "GET",
success: function( data ) {
data = data.replace(/^\s+|\s+$/g,'');
if(data != '') {
data = data+'-1';
$('#cur_hap_ver').text(data);
$('#install').text('Update');
$('#install').attr('title', 'Update HAProxy');
$('#syn_flood').checkboxradio('disable');
$('#syn_flood').prop( "checked", false );
$('#syn_flood').checkboxradio('refresh');
} else {
$('#cur_hap_ver').text('HAProxy has not installed');
$('#install').text('Install');
$('#install').attr('title', 'Install HAProxy');
$('#syn_flood').checkboxradio('enable');
$('#syn_flood').prop( "checked", true );
$('#syn_flood').checkboxradio('refresh');
}
}
} );
});
}); });
function sleep(ms) { function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms)); return new Promise(resolve => setTimeout(resolve, ms));
@ -858,7 +888,6 @@ function change_select_acceleration(id) {
}, },
type: "GET", type: "GET",
success: function( data ) { success: function( data ) {
console.log(data)
if(parseFloat(data) < parseFloat('1.8')) { if(parseFloat(data) < parseFloat('1.8')) {
$("#cache"+id).checkboxradio( "disable" ); $("#cache"+id).checkboxradio( "disable" );
} else { } else {
@ -877,7 +906,6 @@ function change_select_waf(id) {
}, },
type: "GET", type: "GET",
success: function( data ) { success: function( data ) {
console.log(data)
if(parseFloat(data) < parseFloat('1.8')) { if(parseFloat(data) < parseFloat('1.8')) {
$("#waf"+id).checkboxradio( "disable" ); $("#waf"+id).checkboxradio( "disable" );
} else { } else {