Pavel Loginov 2020-04-07 20:16:12 +02:00
parent 4258623548
commit 76995b3f1f
10 changed files with 100 additions and 11 deletions

View File

@ -432,7 +432,7 @@ def update_db_v_42(**kwargs):
def update_ver(**kwargs): def update_ver(**kwargs):
con, cur = get_cur() con, cur = get_cur()
sql = """update version set version = '4.2.1.0'; """ sql = """update version set version = '4.2.2.0'; """
try: try:
cur.execute(sql) cur.execute(sql)
con.commit() con.commit()

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import funct, sql import funct, sql
import create_db import create_db
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
@ -28,6 +29,10 @@ try:
keep_alive, stderr = funct.subprocess_execute(cmd) keep_alive, stderr = funct.subprocess_execute(cmd)
cmd = "ps ax |grep '(wsgi:api)'|grep -v grep|wc -l" cmd = "ps ax |grep '(wsgi:api)'|grep -v grep|wc -l"
api, stderr = funct.subprocess_execute(cmd) api, stderr = funct.subprocess_execute(cmd)
cmd = "ps ax |grep grafana|grep -v grep|wc -l"
grafana, stderr = funct.subprocess_execute(cmd)
cmd = "ps ax |grep prometheus |grep -v grep|wc -l"
prometheus, stderr = funct.subprocess_execute(cmd)
except: except:
role = '' role = ''
user = '' user = ''
@ -40,11 +45,12 @@ except:
checker_worker = '' checker_worker = ''
keep_alive = '' keep_alive = ''
api = '' api = ''
date = '' grafana = ''
error = '' prometheus = ''
versions = '' versions = ''
haproxy_wi_log = '' haproxy_wi_log = ''
servers = '' servers = ''
stderr = ''
template = template.render(h2 = 1, template = template.render(h2 = 1,
@ -61,6 +67,8 @@ template = template.render(h2 = 1,
checker_worker = ''.join(checker_worker), checker_worker = ''.join(checker_worker),
keep_alive = ''.join(keep_alive), keep_alive = ''.join(keep_alive),
api = ''.join(api), api = ''.join(api),
grafana = ''.join(grafana),
prometheus = ''.join(prometheus),
haproxy_wi_log_id = funct.haproxy_wi_log(log_id=1, file="haproxy-wi-", with_date=1), haproxy_wi_log_id = funct.haproxy_wi_log(log_id=1, file="haproxy-wi-", with_date=1),
metrics_log_id = funct.haproxy_wi_log(log_id=1, file="metrics-", with_date=1), metrics_log_id = funct.haproxy_wi_log(log_id=1, file="metrics-", with_date=1),
checker_log_id = funct.haproxy_wi_log(log_id=1, file="checker-", with_date=1), checker_log_id = funct.haproxy_wi_log(log_id=1, file="checker-", with_date=1),

View File

@ -6,6 +6,28 @@
set_fact: set_fact:
ansible_port: "{{SSH_PORT}}" ansible_port: "{{SSH_PORT}}"
- name: Open stat port for firewalld
firewalld:
port: "9101/tcp"
state: enabled
permanent: yes
immediate: yes
ignore_errors: yes
no_log: True
debugger: never
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and ansible_facts.services["firewalld.service"]['state'] == "running"
- name: Open stat port for iptables
iptables:
chain: INPUT
destination_port: 9101
jump: ACCEPT
protocol: tcp
ignore_errors: yes
roles: roles:
- role: bdellegrazie.haproxy_exporter - role: bdellegrazie.haproxy_exporter
vars: vars:

View File

@ -47,6 +47,23 @@
https_proxy: "{{PROXY}}" https_proxy: "{{PROXY}}"
- name: Ensure group "keepalived_script" exists
group:
name: keepalived_script
state: present
system: yes
- name: Add the user 'keepalived_script'
user:
name: keepalived_script
comment: User for keepalived_script
group: keepalived_script
shell: /sbin/nologin
create_home: no
system: yes
- name: Copy keepalived configuration in place. - name: Copy keepalived configuration in place.
template: template:
src: keepalived.conf.j2 src: keepalived.conf.j2

View File

@ -3,7 +3,7 @@ global_defs {
} }
#health-check for keepalive #health-check for keepalive
vrrp_script chk_haproxy { vrrp_script chk_haproxy {
script "pgrep haproxy" script "/usr/bin/pgrep haproxy"
interval 2 interval 2
weight 3 weight 3
} }

View File

@ -6,25 +6,30 @@
set_fact: set_fact:
ansible_port: "{{SSH_PORT}}" ansible_port: "{{SSH_PORT}}"
- name: check if Nginx is installed - name: check if Nginx is installed
package_facts: package_facts:
manager: "auto" manager: "auto"
- name: populate service facts - name: populate service facts
service_facts: service_facts:
- name: Creates directory - name: Creates directory
file: file:
path: /etc/nginx path: /etc/nginx
state: directory state: directory
when: "'nginx' not in ansible_facts.packages" when: "'nginx' not in ansible_facts.packages"
- name: Creates directory - name: Creates directory
file: file:
path: /etc/nginx/conf.d path: /etc/nginx/conf.d
state: directory state: directory
when: "'nginx' not in ansible_facts.packages" when: "'nginx' not in ansible_facts.packages"
- name: Install passlib - name: Install passlib
package: package:
name: python-passlib name: python-passlib
@ -34,6 +39,7 @@
http_proxy: "{{PROXY}}" http_proxy: "{{PROXY}}"
https_proxy: "{{PROXY}}" https_proxy: "{{PROXY}}"
- name: Copy Nginx configuration in place. - name: Copy Nginx configuration in place.
template: template:
src: ./default.conf.j2 src: ./default.conf.j2
@ -42,6 +48,7 @@
when: "'nginx' not in ansible_facts.packages" when: "'nginx' not in ansible_facts.packages"
ignore_errors: yes ignore_errors: yes
- name: Open stat port for firewalld - name: Open stat port for firewalld
firewalld: firewalld:
port: "{{ STAT_PORT }}/tcp" port: "{{ STAT_PORT }}/tcp"
@ -51,6 +58,17 @@
ignore_errors: yes ignore_errors: yes
no_log: True no_log: True
debugger: never debugger: never
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and ansible_facts.services["firewalld.service"]['state'] == "running"
- name: Open stat port for iptables
iptables:
chain: INPUT
destination_port: "{{ STAT_PORT }}"
jump: ACCEPT
protocol: tcp
ignore_errors: yes
- htpasswd: - htpasswd:
path: /etc/nginx/status_page_passwdfile path: /etc/nginx/status_page_passwdfile

View File

@ -6,6 +6,28 @@
set_fact: set_fact:
ansible_port: "{{SSH_PORT}}" ansible_port: "{{SSH_PORT}}"
- name: Open stat port for firewalld
firewalld:
port: "9113/tcp"
state: enabled
permanent: yes
immediate: yes
ignore_errors: yes
no_log: True
debugger: never
when: (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS') and ansible_facts.services["firewalld.service"]['state'] == "running"
- name: Open stat port for iptables
iptables:
chain: INPUT
destination_port: 9113
jump: ACCEPT
protocol: tcp
ignore_errors: yes
roles: roles:
- role: bdellegrazie.nginx_exporter - role: bdellegrazie.nginx_exporter
environment: environment:

View File

@ -338,7 +338,7 @@
{{ input(id, value=telegram.1, style="margin-bottom: 23px;") }} {{ input(id, value=telegram.1, style="margin-bottom: 23px;") }}
</td> </td>
<td> <td>
{% set id = 'telegram-token-' + telegram.0|string() %} {% set id = 'telegram-chanel-' + telegram.0|string() %}
{{ input(id, value=telegram.2) }} {{ input(id, value=telegram.2) }}
</td> </td>
<td> <td>

View File

@ -17,8 +17,10 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</select> </select>
{% if service != 'keepalived' %}
<a class="ui-button ui-widget ui-corner-all" title="Show running config" onclick="showConfig()">Open</a> <a class="ui-button ui-widget ui-corner-all" title="Show running config" onclick="showConfig()">Open</a>
<a class="ui-button ui-widget ui-corner-all" title="View stat" onclick="openStats()">Stat</a> <a class="ui-button ui-widget ui-corner-all" title="View stat" onclick="openStats()">Stat</a>
{% endif %}
{% if service != 'keepalived' and service != 'nginx'%} {% if service != 'keepalived' and service != 'nginx'%}
<a class="ui-button ui-widget ui-corner-all" title="Show map" onclick="showMap()">Map</a> <a class="ui-button ui-widget ui-corner-all" title="Show map" onclick="showMap()">Map</a>
{% endif %} {% endif %}

View File

@ -44,7 +44,7 @@ def main():
sys.exit() sys.exit()
else: else:
cur_stat_service = "Ok" cur_stat_service = "Ok"
time.sleep(30)
if __name__ == "__main__": if __name__ == "__main__":
funct.logging("localhost", " Keep alive service is started", keep_alive=1) funct.logging("localhost", " Keep alive service is started", keep_alive=1)