mirror of https://github.com/Aidaho12/haproxy-wi
parent
49867dc5f3
commit
146422410e
59
api/api.py
59
api/api.py
|
@ -55,27 +55,46 @@ def index():
|
|||
'haproxy/<id,hostname,ip>/action/stop': 'stop HAProxy service by id or hostname or ip. METHOD: GET',
|
||||
'haproxy/<id,hostname,ip>/action/restart': 'restart HAProxy service by id or hostname or ip. METHOD: GET',
|
||||
'haproxy/<id,hostname,ip>/config': 'get HAProxy config from a server by id or hostname or ip. METHOD: GET',
|
||||
'haproxy/<id,hostname,ip>/config': 'upload HAProxy config to a server by id or hostname or ip. Headers: action: save/reload/restart. Body must consist a whole HAProxy config. METHOD: POST',
|
||||
'haproxy/<id,hostname,ip>/log': 'show HAProxy logs by id or hostname or ip. May to have config next Headers: rows(format INT) default: 10 grep, waf(if needs WAF log) default: 0, start_hour(format: 24) default: 00, start_minute, end_hour(format: 24) default: 24, end_minute. METHOD: GET',
|
||||
'haproxy/<id,hostname,ip>/config': 'upload HAProxy config to a server by id or hostname or ip. Headers: action: '
|
||||
'save/reload/restart. Body must consist a whole HAProxy config. METHOD: POST',
|
||||
'haproxy/<id,hostname,ip>/log': 'show HAProxy logs by id or hostname or ip. May to have config next Headers: rows(format INT) '
|
||||
'default: 10 grep, waf(if needs WAF log) default: 0, start_hour(format: 24) default: 00, '
|
||||
'start_minute, end_hour(format: 24) default: 24, end_minute. METHOD: GET',
|
||||
'haproxy/<id,hostname,ip>/section': 'show a certain section, headers: section-name. METHOD: GET',
|
||||
'haproxy/<id,hostname,ip>/section/add': 'add a section to the HAProxy config by id or hostname or ip. Has to have config header with section and action header for action after upload. Section header must consist type: listen, frontend, etc. Action header accepts next value: save, test, reload and restart. Can be empty for just save. METHOD: POST',
|
||||
'haproxy/<id,hostname,ip>/section/edit': 'edit a section in the HAProxy config by id or hostname or ip. Has to have config header with section, action header for action after upload and body of a new section configuration. Section header must consist type: listen, frontend, etc. Action header accepts next value: save, test, reload and restart. Can be empty for just save. METHOD: POST',
|
||||
'haproxy/<id,hostname,ip>/acl': 'add an acl to certain section. Must be JSON body: "section-name", "if", "then", "if_value", "then_value" and "action" for action after upload. Action accepts next value: "save", "test", "reload" and "restart". METHOD: POST',
|
||||
'haproxy/<id,hostname,ip>/acl': 'delete an acl to certain section. Must be JSON body: "section-name", "if", "then", "if_value", "then_value" and "action" for action after upload. Action accepts next value: "save", "test", "reload" and "restart". METHOD: DELETE',
|
||||
'haproxy/<id,hostname,ip>/section/add': 'add a section to the HAProxy config by id or hostname or ip. Has to have '
|
||||
'config header with section and action header for action after upload. '
|
||||
'Section header must consist type: listen, frontend, etc. Action header '
|
||||
'accepts next value: save, test, reload and restart. Can be empty for just save. METHOD: POST',
|
||||
'haproxy/<id,hostname,ip>/section/edit': 'edit a section in the HAProxy config by id or hostname or ip. Has to have '
|
||||
'config header with section, action header for action after upload and body '
|
||||
'of a new section configuration. Section header must consist type: listen, '
|
||||
'frontend, etc. Action header accepts next value: save, test, reload and restart. Can be empty for just save. METHOD: POST',
|
||||
'haproxy/<id,hostname,ip>/acl': 'add an acl to certain section. Must be JSON body: "section-name", "if", "then", '
|
||||
'"if_value", "then_value" and "action" for action after upload. Action accepts next '
|
||||
'value: "save", "test", "reload" and "restart". METHOD: POST',
|
||||
'haproxy/<id,hostname,ip>/acl': 'delete an acl to certain section. Must be JSON body: "section-name", "if", "then", '
|
||||
'"if_value", "then_value" and "action" for action after upload. Action accepts next '
|
||||
'value: "save", "test", "reload" and "restart". METHOD: DELETE',
|
||||
'nginx/<id,hostname,ip>': 'show info about the NGINX by id or hostname or ip. METHOD: GET',
|
||||
'nginx/<id,hostname,ip>/status': 'show NGINX status by id or hostname or ip. METHOD: GET',
|
||||
'nginx/<id,hostname,ip>/action/start': 'start NGINX service by id or hostname or ip. METHOD: GET',
|
||||
'nginx/<id,hostname,ip>/action/stop': 'stop NGINX service by id or hostname or ip. METHOD: GET',
|
||||
'nginx/<id,hostname,ip>/action/restart': 'restart NGINX service by id or hostname or ip. METHOD: GET',
|
||||
'nginx/<id,hostname,ip>/config': 'get NGINX config from a server by id or hostname or ip. Headers: The full path to a config file, like: /etc/nginx/conf.d/default.conf. METHOD: GET',
|
||||
'nginx/<id,hostname,ip>/config': 'upload NGINX config to a server by id or hostname or ip. Headers: action: save/reload/restart, config-file: the full path to the config, like /etc/nginx/conf.d/example.com.conf. Body must consist a whole HAProxy config. METHOD: POST',
|
||||
'nginx/<id,hostname,ip>/config': 'get NGINX config from a server by id or hostname or ip. Headers: The full path to a config file, '
|
||||
'like: /etc/nginx/conf.d/default.conf. METHOD: GET',
|
||||
'nginx/<id,hostname,ip>/config': 'upload NGINX config to a server by id or hostname or ip. Headers: action: save/reload/restart, '
|
||||
'config-file: the full path to the config, like /etc/nginx/conf.d/example.com.conf. '
|
||||
'Body must consist a whole HAProxy config. METHOD: POST',
|
||||
'apache/<id,hostname,ip>': 'show info about the Apache by id or hostname or ip. METHOD: GET',
|
||||
'apache/<id,hostname,ip>/status': 'show Apache status by id or hostname or ip. METHOD: GET',
|
||||
'apache/<id,hostname,ip>/action/start': 'start Apache service by id or hostname or ip. METHOD: GET',
|
||||
'apache/<id,hostname,ip>/action/stop': 'stop Apache service by id or hostname or ip. METHOD: GET',
|
||||
'apache/<id,hostname,ip>/action/restart': 'restart Apache service by id or hostname or ip. METHOD: GET',
|
||||
'apache/<id,hostname,ip>/config': 'get Apache config from a server by id or hostname or ip. Headers: The full path to a config file, like: /etc/httpd/conf.d/default.conf. METHOD: GET',
|
||||
'apache/<id,hostname,ip>/config': 'upload Apache config to a server by id or hostname or ip. Headers: action: save/reload/restart, config-file: the full path to the config, like /etc/httpd/conf.d/example.com.conf. Body must consist a whole HAProxy config. METHOD: POST',
|
||||
'apache/<id,hostname,ip>/config': 'get Apache config from a server by id or hostname or ip. Headers: The full path to a config file, '
|
||||
'like: /etc/httpd/conf.d/default.conf. METHOD: GET',
|
||||
'apache/<id,hostname,ip>/config': 'upload Apache config to a server by id or hostname or ip. Headers: action: save/reload/restart, config-file: '
|
||||
'the full path to the config, like /etc/httpd/conf.d/example.com.conf. '
|
||||
'Body must consist a whole HAProxy config. METHOD: POST',
|
||||
}
|
||||
return dict(help=data)
|
||||
|
||||
|
@ -116,7 +135,7 @@ def get_servers():
|
|||
|
||||
|
||||
@route('/servers/status', method=['GET'])
|
||||
def callback():
|
||||
def servers_status():
|
||||
if not check_login():
|
||||
return dict(error=_error_auth)
|
||||
return api_funct.get_all_statuses()
|
||||
|
@ -124,7 +143,7 @@ def callback():
|
|||
|
||||
@route('/haproxy/<haproxy_id>/runtime', method=['POST'])
|
||||
@route('/haproxy/<haproxy_id:int>/runtime', method=['POST'])
|
||||
def callback(haproxy_id):
|
||||
def haproxy_runtime(haproxy_id):
|
||||
if not check_login(required_service=1):
|
||||
return dict(error=_error_auth)
|
||||
return api_funct.runtime(haproxy_id)
|
||||
|
@ -132,7 +151,7 @@ def callback(haproxy_id):
|
|||
|
||||
@route('/haproxy/<haproxy_id>/backends', method=['GET'])
|
||||
@route('/haproxy/<haproxy_id:int>/backends', method=['GET'])
|
||||
def callback(haproxy_id):
|
||||
def haproxy_backends(haproxy_id):
|
||||
if not check_login(required_service=1):
|
||||
return dict(error=_error_auth)
|
||||
return api_funct.show_backends(haproxy_id)
|
||||
|
@ -140,7 +159,7 @@ def callback(haproxy_id):
|
|||
|
||||
@route('/haproxy/<haproxy_id>/log', method=['GET'])
|
||||
@route('/haproxy/<haproxy_id:int>/log', method=['GET'])
|
||||
def callback(haproxy_id):
|
||||
def haproxy_log(haproxy_id):
|
||||
if not check_login(required_service=1):
|
||||
return dict(error=_error_auth)
|
||||
return api_funct.show_log(haproxy_id)
|
||||
|
@ -156,7 +175,7 @@ def get_section(haproxy_id):
|
|||
|
||||
@route('/haproxy/<haproxy_id>/section/add', method=['POST'])
|
||||
@route('/haproxy/<haproxy_id:int>/section/add', method=['POST'])
|
||||
def callback(haproxy_id):
|
||||
def haproxy_section_add(haproxy_id):
|
||||
if not check_login(required_service=1):
|
||||
return dict(error=_error_auth)
|
||||
return api_funct.add_to_config(haproxy_id)
|
||||
|
@ -164,7 +183,7 @@ def callback(haproxy_id):
|
|||
|
||||
@route('/haproxy/<haproxy_id>/section/edit', method=['POST'])
|
||||
@route('/haproxy/<haproxy_id:int>/section/edit', method=['POST'])
|
||||
def callback(haproxy_id):
|
||||
def haproxy_sectiond_edit(haproxy_id):
|
||||
if not check_login(required_service=1):
|
||||
return dict(error=_error_auth)
|
||||
return api_funct.edit_section(haproxy_id)
|
||||
|
@ -195,7 +214,7 @@ def callback(server_id, service):
|
|||
|
||||
@route('/<service>/<server_id>/status', method=['GET'])
|
||||
@route('/<service>/<server_id:int>/status', method=['GET'])
|
||||
def callback(server_id, service):
|
||||
def service_status(server_id, service):
|
||||
required_service = api_funct.return_requred_serivce(service)
|
||||
if not check_login(required_service=required_service):
|
||||
return dict(error=_error_auth)
|
||||
|
@ -204,7 +223,7 @@ def callback(server_id, service):
|
|||
|
||||
@route('/<service>/<server_id>/action/<action:re:[a-z]+>', method=['GET'])
|
||||
@route('/<service>/<server_id:int>/action/<action:re:[a-z]+>', method=['GET'])
|
||||
def callback(server_id, action, service):
|
||||
def service_action(server_id, action, service):
|
||||
required_service = api_funct.return_requred_serivce(service)
|
||||
if not check_login(required_service=required_service):
|
||||
return dict(error=_error_auth)
|
||||
|
@ -213,7 +232,7 @@ def callback(server_id, action, service):
|
|||
|
||||
@route('/<service>/<server_id>/config', method=['GET'])
|
||||
@route('/<service>/<server_id:int>/config', method=['GET'])
|
||||
def callback(server_id, service):
|
||||
def service_config_show(server_id, service):
|
||||
required_service = api_funct.return_requred_serivce(service)
|
||||
if not check_login(required_service=required_service):
|
||||
return dict(error=_error_auth)
|
||||
|
@ -223,7 +242,7 @@ def callback(server_id, service):
|
|||
|
||||
@route('/<service>/<server_id>/config', method=['POST'])
|
||||
@route('/<service>/<server_id:int>/config', method=['POST'])
|
||||
def callback(server_id, service):
|
||||
def service_config_edit(server_id, service):
|
||||
required_service = api_funct.return_requred_serivce(service)
|
||||
if not check_login(required_service=required_service):
|
||||
return dict(error=_error_auth)
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
file:
|
||||
path: "{{nginx_dir}}"
|
||||
state: directory
|
||||
mode: o=rx
|
||||
when: "'nginx' not in ansible_facts.packages"
|
||||
|
||||
|
||||
|
@ -39,6 +40,12 @@
|
|||
when: ansible_facts['distribution_major_version'] == '7'
|
||||
ignore_errors: True
|
||||
|
||||
- name: Set passlib version
|
||||
set_fact:
|
||||
passlib_ver: "passlib"
|
||||
when: ansible_facts['distribution_major_version'] == '9'
|
||||
ignore_errors: True
|
||||
|
||||
|
||||
- name: Install passlib
|
||||
package:
|
||||
|
@ -52,15 +59,6 @@
|
|||
https_proxy: "{{PROXY}}"
|
||||
|
||||
|
||||
- name: Install passlib for el9
|
||||
pip:
|
||||
name: passlib
|
||||
when: ansible_facts['distribution_major_version'] == '9'
|
||||
environment:
|
||||
http_proxy: "{{PROXY}}"
|
||||
https_proxy: "{{PROXY}}"
|
||||
|
||||
|
||||
- name: Copy Nginx configuration in place
|
||||
template:
|
||||
src: default.conf.j2
|
||||
|
|
Loading…
Reference in New Issue