diff --git a/api/api.py b/api/api.py index 78fdb5c0..0becf4ea 100644 --- a/api/api.py +++ b/api/api.py @@ -55,27 +55,46 @@ def index(): 'haproxy//action/stop': 'stop HAProxy service by id or hostname or ip. METHOD: GET', 'haproxy//action/restart': 'restart HAProxy service by id or hostname or ip. METHOD: GET', 'haproxy//config': 'get HAProxy config from a server by id or hostname or ip. METHOD: GET', - 'haproxy//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//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//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//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//section': 'show a certain section, headers: section-name. METHOD: GET', - 'haproxy//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//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//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//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//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//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//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//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/': 'show info about the NGINX by id or hostname or ip. METHOD: GET', 'nginx//status': 'show NGINX status by id or hostname or ip. METHOD: GET', 'nginx//action/start': 'start NGINX service by id or hostname or ip. METHOD: GET', 'nginx//action/stop': 'stop NGINX service by id or hostname or ip. METHOD: GET', 'nginx//action/restart': 'restart NGINX service by id or hostname or ip. METHOD: GET', - 'nginx//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//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//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//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/': 'show info about the Apache by id or hostname or ip. METHOD: GET', 'apache//status': 'show Apache status by id or hostname or ip. METHOD: GET', 'apache//action/start': 'start Apache service by id or hostname or ip. METHOD: GET', 'apache//action/stop': 'stop Apache service by id or hostname or ip. METHOD: GET', 'apache//action/restart': 'restart Apache service by id or hostname or ip. METHOD: GET', - 'apache//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//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//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//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//runtime', method=['POST']) @route('/haproxy//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//backends', method=['GET']) @route('/haproxy//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//log', method=['GET']) @route('/haproxy//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//section/add', method=['POST']) @route('/haproxy//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//section/edit', method=['POST']) @route('/haproxy//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('///status', method=['GET']) @route('///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('///action/', method=['GET']) @route('///action/', 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('///config', method=['GET']) @route('///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('///config', method=['POST']) @route('///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) diff --git a/app/scripts/ansible/roles/nginx_common/tasks/main.yml b/app/scripts/ansible/roles/nginx_common/tasks/main.yml index 1e6602fd..4d7ef454 100644 --- a/app/scripts/ansible/roles/nginx_common/tasks/main.yml +++ b/app/scripts/ansible/roles/nginx_common/tasks/main.yml @@ -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