Commit d2500140 authored by Aleksey Shirokih's avatar Aleksey Shirokih

refactor

parent 00a8c947
......@@ -7,4 +7,5 @@ syntax: glob
.idea
.vscode
additional_roles/
ansible.cfg
\ No newline at end of file
ansible.cfg
towergen.yml
\ No newline at end of file
- import_playbook: pre.yml
- name: Install NOC
hosts: noc-svc-*
become: yes
......@@ -9,7 +11,7 @@
vars_files:
- "vars/main.yml"
roles:
- role: node
- role: noc
- role: login
- role: mrt
- role: escalator
......@@ -36,3 +38,5 @@
run_once: true
tags:
- migrate
- import_playbook: post.yml
\ No newline at end of file
......@@ -9,14 +9,19 @@ services:
<strong>Placement constraint</strong>: On separate node<br/>
level: pool
category: internal
command: "./services/activator/service.py"
process_name: "%(program_name)s-%(process_num)02d"
priority: 100
oom_score_adj: 300
startretries: 999
stopwaitsecs: 3
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
supervisord:
command: "./services/activator/service.py"
process_name: "%(program_name)s-%(process_num)02d"
priority: 100
oom_score_adj: 300
startretries: 999
stopwaitsecs: 3
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
depends:
- noc
- sae
- discovery
config:
activator:
......
......@@ -21,13 +21,17 @@ services:
<strong>Placement constraint</strong>: On node with Clickhouse<br/>
level: global
category: internal
command: "./services/bi/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 50
priority: 300
startretries: 999
stopwaitsecs: 2
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
supervisord:
command: "./services/bi/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 50
priority: 300
startretries: 999
stopwaitsecs: 2
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
required_assets:
- bi
\ No newline at end of file
- bi
depends:
- noc
- clickhouse
\ No newline at end of file
......@@ -21,14 +21,18 @@ services:
<strong>Placement constraint</strong>: On node with nginx<br/>
level: global
category: internal
command: "./services/card/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 100
priority: 300
startretries: 999
stopwaitsecs: 1
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
supervisord:
command: "./services/card/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 100
priority: 300
startretries: 999
stopwaitsecs: 1
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
required_assets:
- card
- web
\ No newline at end of file
- web
depends:
- noc
- nginx
\ No newline at end of file
......@@ -12,11 +12,15 @@ services:
<strong>Placement constraint</strong>: On node with clickhouse<br/>
level: global
category: internal
command: "./services/datasource/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 999
priority: 100
startretries: 999
stopwaitsecs: 3
stdout_logfile_maxbytes: 1MB
stdout_logfile_backups: 3
\ No newline at end of file
supervisord:
command: "./services/datasource/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 999
priority: 100
startretries: 999
stopwaitsecs: 3
stdout_logfile_maxbytes: 1MB
stdout_logfile_backups: 3
depends:
- noc
- mongod
\ No newline at end of file
......@@ -27,11 +27,16 @@ services:
<strong>Placement constraint</strong>: On node with Clickhouse<br/>
level: global
category: internal
command: "./services/chwriter/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 10
priority: 300
startretries: 999
stopwaitsecs: 2
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
\ No newline at end of file
supervisord:
command: "./services/chwriter/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 10
priority: 300
startretries: 999
stopwaitsecs: 2
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
depends:
- noc
- nsqlookupd
- nsqd
\ No newline at end of file
......@@ -20,11 +20,15 @@ services:
<strong>Placement constraint</strong>: On node with correlator<br/>
level: pool
category: internal
command: "./services/classifier/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 50
priority: 300
startretries: 999
stopwaitsecs: 3
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
\ No newline at end of file
supervisord:
command: "./services/classifier/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 50
priority: 300
startretries: 999
stopwaitsecs: 3
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
depends:
- noc
- mongod
\ No newline at end of file
......@@ -15,11 +15,14 @@ services:
<strong>Placement constraint</strong>: No special recommendations.<br/>
level: pool
category: internal
command: "./services/correlator/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 20
priority: 150
startretries: 999
stopwaitsecs: 5
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
\ No newline at end of file
supervisord:
command: "./services/correlator/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 20
priority: 150
startretries: 999
stopwaitsecs: 5
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
depends:
- noc
\ No newline at end of file
......@@ -16,11 +16,14 @@ services:
<strong>Placement constraint</strong>: High cpu/memory usage.<br/>
level: pool
category: internal
command: "./services/discovery/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 500
priority: 100
startretries: 999
stopwaitsecs: 3
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
\ No newline at end of file
supervisord:
command: "./services/discovery/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 500
priority: 100
startretries: 999
stopwaitsecs: 3
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
depends:
- noc
\ No newline at end of file
......@@ -16,11 +16,14 @@ services:
<strong>Placement constraint</strong>: No special recommendations.<br/>
level: global
category: internal
command: "./services/escalator/service.py"
process_name: "%(program_name)s"
oom_score_adj: 5
priority: 50
startretries: 999
stopwaitsecs: 3
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 10
\ No newline at end of file
supervisord:
command: "./services/escalator/service.py"
process_name: "%(program_name)s"
oom_score_adj: 5
priority: 50
startretries: 999
stopwaitsecs: 3
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 10
depends:
- noc
\ No newline at end of file
......@@ -16,11 +16,16 @@ services:
<strong>Placement constraint</strong>: On node with nginx<br/>
level: global
category: internal
command: "./services/grafanads/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 900
priority: 500
startretries: 999
stopwaitsecs: 1
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 1
\ No newline at end of file
supervisord:
command: "./services/grafanads/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 900
priority: 500
startretries: 999
stopwaitsecs: 1
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 1
depends:
- noc
- grafana
- nginx
\ No newline at end of file
......@@ -40,12 +40,15 @@ services:
<strong>Placement constraint</strong>: On node with nginx<br/>
level: global
category: internal
command: "./services/login/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 10
priority: 40
startretries: 999
stopwaitsecs: 3
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 5
promote: system
\ No newline at end of file
supervisord:
command: "./services/login/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 10
priority: 40
startretries: 999
stopwaitsecs: 3
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 5
promote: system
depends:
- noc
\ No newline at end of file
......@@ -36,11 +36,14 @@ services:
<strong>Placement constraint</strong>: No special recommendations.<br/>
level: global
category: internal
command: "./services/mailsender/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 100
priority: 600
startretries: 999
stopwaitsecs: 3
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
\ No newline at end of file
supervisord:
command: "./services/mailsender/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 100
priority: 600
startretries: 999
stopwaitsecs: 3
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
depends:
- noc
\ No newline at end of file
......@@ -5,22 +5,14 @@
service:
name: consul
state: restarted
when: "'FreeBSD' in ansible_system"
- name: pause for 10 sec on freebsd. wait for consul
pause:
seconds: 12
sleep: 10
when: "'FreeBSD' in ansible_system"
- name: restart consul-template on freebsd
service:
name: consul-template
state: restarted
when: "'FreeBSD' in ansible_system"
- name: pause for 5 sec on freebsd. wait for consul-template
pause:
seconds: 5
sleep: 10
when: "'FreeBSD' in ansible_system"
- name: Migrate
......
......@@ -15,11 +15,14 @@ services:
<strong>Placement constraint</strong>: On node with nginx<br/>
level: global
category: internal
command: "./services/mrt/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 100
priority: 110
startretries: 999
stopwaitsecs: 3
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
\ No newline at end of file
supervisord:
command: "./services/mrt/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 100
priority: 110
startretries: 999
stopwaitsecs: 3
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
depends:
- noc
\ No newline at end of file
......@@ -42,4 +42,9 @@ services:
<strong>Placement constraint</strong>: Any <br/>
level: system
category: config
promote: system
\ No newline at end of file
promote: system
depends:
- postgres
- mongod
- nsqd
- nginx
- name: Install NOC
hosts: noc-svc-*
become: yes
strategy: free
gather_facts: True
tags:
- node
- noc
vars_files:
- "../../vars/main.yml"
pre_tasks:
- meta: flush_handlers
roles:
- role: node
- role: login
- role: mrt
- role: escalator
- role: web
- role: card
- role: ch_datasource
- role: omap
- role: activator
- role: grafanads
- role: mailsender
- role: tgsender
- role: chwriter
- role: classifier
- role: correlator
- role: syslogcollector
- role: trapcollector
- role: ping
- role: sae
- role: scheduler
- role: discovery
- role: bi
- name: migrate
hosts: svc-postgres-master
become: yes
gather_facts: True
tags:
- node
- noc
roles:
- role: migrate
become: yes
run_once: true
tags:
- migrate
- block:
- name: Clone NOC
shell: git clone "{{noc_repo}}" "{{noc_root}}"
command: git clone "{{noc_repo}}" "{{noc_root}}"
environment:
https_proxy: "{{http_proxy}}"
......@@ -23,7 +23,7 @@
when: noc_root_state.stat.exists is defined and not noc_root_state.stat.exists
- name: Fetch changes from upstream
shell: git fetch origin
command: git fetch origin
args:
chdir: "{{noc_root}}"
environment:
......
......@@ -33,12 +33,12 @@
state: absent
- name: init venv
shell: "{{ pypy_path }}/bin/virtualenv-pypy {{noc_root}}"
command: "{{ pypy_path }}/bin/virtualenv-pypy {{noc_root}}"
args:
chdir: "{{noc_root | dirname }}"
- name: refetch actual source
shell: "git checkout {{noc_root}}/lib"
command: "git checkout {{noc_root}}/lib"
args:
chdir: "{{noc_root }}"
when: venv_init.stat.exists is defined and not venv_init.stat.exists
......
......@@ -5,7 +5,7 @@
format: bz2
- name: add everything to mercurial
shell: hg add .
command: hg add .
args:
chdir: "{{noc_root}}"
......@@ -28,7 +28,7 @@
state: absent
- name: git init
shell: git init "{{noc_root}}"
command: git init "{{noc_root}}"
- block:
- name: set up dummy git user email
......@@ -47,14 +47,14 @@
when: not git_user_email.config_value
- name: add correct origin
shell: "git remote add origin {{noc_repo}}"
command: git remote add origin {{noc_repo}}
args:
chdir: "{{noc_root}}"
environment:
https_proxy: "{{http_proxy}}"
- name: git reset branch
shell: git pull origin
command: git pull origin
args:
chdir: "{{noc_root}}"
ignore_errors: yes
......@@ -62,7 +62,7 @@
https_proxy: "{{http_proxy}}"
- name: git reset branch
shell: git checkout {{noc_version}} -f
command: git checkout {{noc_version}} -f
args:
chdir: "{{noc_root}}"
environment:
......
---
# ignore erros will be even here or later
- name: check firewalld state
shell: systemctl is-active firewalld
command: systemctl is-active firewalld
register: firewalld_state
changed_when: false
ignore_errors: yes
......
---
# ignore erros will be even here or later
- name: check firewalld state
shell: systemctl is-active firewalld
command: systemctl is-active firewalld
register: firewalld_state
changed_when: false
ignore_errors: yes
......
{% for service in noc_services %}
[program:{{service.name}}]
command = {{ service.environment.command | mandatory }}
process_name = {{ service.environment.process_name | default("%(program_name)s-%(process_num)02d", True) }}
command = {{ service.environment.supervisord.command | mandatory }}
process_name = {{ service.environment.supervisord.process_name | default("%(program_name)s-%(process_num)02d", True) }}
numprocs = {{service.n_instances + service.n_backup_instances | default(0, True)}}
umask = 022
priority = {{ service.environment.priority | default(50, True) }}
priority = {{ service.environment.supervisord.priority | default(50, True) }}
autostart = true
autorestart = unexpected
startsecs = {{ service.environment.startsecs | default(2, True)}}
startsecs = {{ service.environment.supervisord.startsecs | default(2, True)}}
startretries = 999
exitcodes = 0
stopsignal = TERM
stopwaitsecs = {{ service.environment.stopwaitsecs | default(50, True)}}
stopwaitsecs = {{ service.environment.supervisord.stopwaitsecs | default(50, True)}}
stopasgroup = false
killasgroup = true
{% if 'user' in service.environment %}
user = {{ service.environment.user }}
{% if 'user' in service.environment.supervisord %}
user = {{ service.environment.supervisord.user }}
{% else %}
user = {{ noc_user }}
{% endif -%}
{% if not 'FreeBSD' in ansible_system -%}
oom_score_adj = {{ service.environment.oom_score_adj | default(50, True) }}
oom_score_adj = {{ service.environment.supervisord.oom_score_adj | default(50, True) }}
{% endif -%}
redirect_stderr = true
stdout_logfile = {{noc_logs}}/{{ service.environment.process_name | default("%(program_name)s-%(process_num)02d", True) }}.log
stdout_logfile_maxbytes = {{ service.environment.stdout_logfile_maxbytes | default('10MB', True)}}
stdout_logfile_backups = {{ service.environment.stdout_logfile_backups | default(3, True)}}
stdout_logfile = {{noc_logs}}/{{ service.environment.supervisord.process_name | default("%(program_name)s-%(process_num)02d", True) }}.log
stdout_logfile_maxbytes = {{ service.environment.supervisord.stdout_logfile_maxbytes | default('10MB', True)}}
stdout_logfile_backups = {{ service.environment.supervisord.stdout_logfile_backups | default(3, True)}}
stdout_events_enabled = false
stderr_logfile = {{noc_logs}}/{{ service.environment.process_name | default("%(program_name)s-%(process_num)02d", True) }}.err
stderr_logfile_maxbytes = {{ service.environment.stderr_logfile_maxbytes | default('10MB', True)}}
stderr_logfile_backups = {{ service.environment.stderr_logfile_backups | default(3, True)}}
stderr_logfile = {{noc_logs}}/{{ service.environment.supervisord.process_name | default("%(program_name)s-%(process_num)02d", True) }}.err
stderr_logfile_maxbytes = {{ service.environment.supervisord.stderr_logfile_maxbytes | default('10MB', True)}}
stderr_logfile_backups = {{ service.environment.supervisord.stderr_logfile_backups | default(3, True)}}
stderr_events_enabled = false
environment=NOC_CONFIG="{{ service.config_order }}",NOC_NODE="{{ ansible_nodename }}",NOC_DC="{{ noc_dc }}",NOC_USER="{{ noc_user }}",NOC_ROOT="{{ noc_root }}",NOC_ENV="{{ noc_env }}",NOC_LOGLEVEL="{{service.loglevel }}"
......
......@@ -12,11 +12,14 @@ services:
<strong>Placement constraint</strong>: No special recommendations.<br/>
level: global
category: internal
command: "./services/omap/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 100
priority: 120
startretries: 999
stopwaitsecs: 1
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 1
supervisord:
command: "./services/omap/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 100
priority: 120
startretries: 999
stopwaitsecs: 1
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 1
depends:
- noc
\ No newline at end of file
......@@ -23,12 +23,18 @@ services:
<strong>Placement constraint</strong>: On node with activator<br/>
level: pool
category: internal
command: "./services/ping/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 200
priority: 90
startretries: 999
stopwaitsecs: 1
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3
user: root
\ No newline at end of file
supervisord:
command: "./services/ping/service.py"
process_name: "%(program_name)s-%(process_num)02d"
oom_score_adj: 200
priority: 90
startretries: 999
stopwaitsecs: 1
stdout_logfile_maxbytes: 10MB
stdout_logfile_backups: 3