mirror of https://github.com/Aidaho12/haproxy-wi
parent
6ec8df1ee5
commit
ec87633690
@ -0,0 +1,50 @@
|
||||
---
|
||||
- name: Install common role
|
||||
hosts: "{{ variable_host }}"
|
||||
become: yes
|
||||
become_method: sudo
|
||||
gather_facts: yes
|
||||
roles:
|
||||
- role: service_common
|
||||
environment:
|
||||
http_proxy: "{{PROXY}}"
|
||||
https_proxy: "{{PROXY}}"
|
||||
|
||||
tags:
|
||||
- system
|
||||
- docker
|
||||
|
||||
- name: Install docker
|
||||
hosts: "{{ variable_host }}"
|
||||
become: yes
|
||||
gather_facts: yes
|
||||
roles:
|
||||
- role: docker
|
||||
environment:
|
||||
http_proxy: "{{PROXY}}"
|
||||
https_proxy: "{{PROXY}}"
|
||||
- role: service_docker
|
||||
environment:
|
||||
http_proxy: "{{PROXY}}"
|
||||
https_proxy: "{{PROXY}}"
|
||||
vars:
|
||||
image_name: httpd
|
||||
cont_etc_dir: "/usr/local/apache2"
|
||||
tags:
|
||||
- docker
|
||||
|
||||
- name: Install system role
|
||||
hosts: "{{ variable_host }}"
|
||||
become: yes
|
||||
become_method: sudo
|
||||
tasks:
|
||||
- name: Add syn_flood tasks
|
||||
include: haproxy/tasks/syn_flood.yml
|
||||
when: (SYN_FLOOD is defined) and (SYN_FLOOD|length > 0)
|
||||
roles:
|
||||
- role: apache
|
||||
environment:
|
||||
http_proxy: "{{PROXY}}"
|
||||
https_proxy: "{{PROXY}}"
|
||||
tags:
|
||||
- system
|
@ -1,53 +0,0 @@
|
||||
---
|
||||
- name: Ensuring nginx directories exist
|
||||
file:
|
||||
path: "/etc/nginx"
|
||||
state: "directory"
|
||||
owner: "{{ansible_user}}"
|
||||
group: "{{ansible_user}}"
|
||||
mode: "0770"
|
||||
become: true
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Ensuring conf.d directories exist
|
||||
file:
|
||||
path: "{{ nginx_dir }}"
|
||||
state: "directory"
|
||||
owner: "{{ansible_user}}"
|
||||
group: "{{ansible_user}}"
|
||||
mode: "0770"
|
||||
become: true
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Ensuring sites-enabled directories exist
|
||||
file:
|
||||
path: "/etc/nginx/sites-enabled"
|
||||
state: "directory"
|
||||
owner: "{{ansible_user}}"
|
||||
group: "{{ansible_user}}"
|
||||
mode: "0770"
|
||||
become: true
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Ensuring log directories exist
|
||||
file:
|
||||
path: "/var/log/nginx/"
|
||||
state: "directory"
|
||||
owner: "{{ansible_user}}"
|
||||
group: "{{ansible_user}}"
|
||||
mode: "0770"
|
||||
become: true
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Create Nginx
|
||||
docker_container:
|
||||
name: "{{ CONT_NAME }}"
|
||||
image: "nginx"
|
||||
recreate: yes
|
||||
network_mode: host
|
||||
volumes:
|
||||
- "/etc/nginx/:/etc/nginx/:rw"
|
||||
- "/tmp:/tmp:ro"
|
||||
- "/var/log:/var/log:rw"
|
||||
vars:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
@ -0,0 +1,10 @@
|
||||
Listen {{ STAT_PORT }}
|
||||
<VirtualHost *:{{ STAT_PORT }}>
|
||||
<Location /{{ STAT_PAGE }}>
|
||||
SetHandler server-status
|
||||
AuthType basic
|
||||
AuthName "Apache status"
|
||||
AuthUserFile {{ service_dir }}/status_page_passwdfile
|
||||
Require valid-user
|
||||
</Location>
|
||||
</VirtualHost>
|
@ -1,14 +1,3 @@
|
||||
server {
|
||||
listen {{STAT_PORT}} ;
|
||||
server_name localhost;
|
||||
|
||||
location /{{STAT_PAGE}} {
|
||||
stub_status;
|
||||
auth_basic "Resticted Area";
|
||||
auth_basic_user_file /etc/nginx/status_page_passwdfile;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
@ -0,0 +1,10 @@
|
||||
server {
|
||||
listen {{STAT_PORT}} ;
|
||||
server_name localhost;
|
||||
|
||||
location /{{STAT_PAGE}} {
|
||||
stub_status;
|
||||
auth_basic "Resticted Area";
|
||||
auth_basic_user_file /etc/nginx/status_page_passwdfile;
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
service_user: httpd
|
||||
service_group: httpd
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
service_user: apache2
|
||||
service_group: apache2
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
service_user: httpd
|
||||
service_group: httpd
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
service_user: apache2
|
||||
service_group: apache2
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
service_user: nginx
|
||||
service_group: nginx
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
service_user: nginx
|
||||
service_group: nginx
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
service_user: nginx
|
||||
service_group: nginx
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
service_user: nginx
|
||||
service_group: nginx
|
@ -0,0 +1,28 @@
|
||||
---
|
||||
- name: Creates directorys
|
||||
file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: "0770"
|
||||
owner: "{{ service_user }}"
|
||||
group: "{{ service_group }}"
|
||||
become: true
|
||||
ignore_errors: yes
|
||||
with_items:
|
||||
- { path: "{{ service_dir }}"}
|
||||
- { path: "{{ service_dir }}/conf.d"}
|
||||
- { path: "{{ service_dir }}/sites-enabled"}
|
||||
- { path: "/var/log/{{ service }}/"}
|
||||
|
||||
- name: "Create {{ service }}"
|
||||
docker_container:
|
||||
name: "{{ CONT_NAME }}"
|
||||
image: "{{ image_name }}"
|
||||
recreate: yes
|
||||
network_mode: host
|
||||
volumes:
|
||||
- "/etc/{{ service }}/:{{ cont_etc_dir }}/:rw"
|
||||
- "/tmp:/tmp:ro"
|
||||
- "/var/log:/var/log:rw"
|
||||
vars:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
for ARGUMENT in "$@"
|
||||
do
|
||||
KEY=$(echo $ARGUMENT | cut -f1 -d=)
|
||||
VALUE=$(echo $ARGUMENT | cut -f2 -d=)
|
||||
|
||||
case "$KEY" in
|
||||
PROXY) PROXY=${VALUE} ;;
|
||||
HOST) HOST=${VALUE} ;;
|
||||
USER) USER=${VALUE} ;;
|
||||
PASS) PASS=${VALUE} ;;
|
||||
KEY) KEY=${VALUE} ;;
|
||||
SYN_FLOOD) SYN_FLOOD=${VALUE} ;;
|
||||
STAT_PORT) STAT_PORT=${VALUE} ;;
|
||||
STAT_PAGE) STAT_PAGE=${VALUE} ;;
|
||||
STATS_USER) STATS_USER=${VALUE} ;;
|
||||
STATS_PASS) STATS_PASS=${VALUE} ;;
|
||||
SSH_PORT) SSH_PORT=${VALUE} ;;
|
||||
CONFIG_PATH) CONFIG_PATH=${VALUE} ;;
|
||||
DOCKER) DOCKER=${VALUE} ;;
|
||||
CONT_NAME) CONT_NAME=${VALUE} ;;
|
||||
service_dir) service_dir=${VALUE} ;;
|
||||
*)
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $DOCKER == '1' ]]; then
|
||||
tags='docker'
|
||||
else
|
||||
tags='system'
|
||||
fi
|
||||
|
||||
export ANSIBLE_HOST_KEY_CHECKING=False
|
||||
export ANSIBLE_DISPLAY_SKIPPED_HOSTS=False
|
||||
export ACTION_WARNINGS=False
|
||||
export LOCALHOST_WARNING=False
|
||||
export COMMAND_WARNINGS=False
|
||||
|
||||
PWD=`pwd`
|
||||
PWD=$PWD/scripts/ansible/
|
||||
echo "$HOST ansible_port=$SSH_PORT" > $PWD/$HOST
|
||||
|
||||
if [[ $KEY == "" ]]; then
|
||||
ansible-playbook $PWD/roles/apache.yml -e "ansible_user=$USER ansible_ssh_pass='$PASS' variable_host=$HOST PROXY=$PROXY CONT_NAME=$CONT_NAME service_dir=$service_dir SYN_FLOOD=$SYN_FLOOD STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS CONFIG_PATH=$CONFIG_PATH SSH_PORT=$SSH_PORT service=apache" -i $PWD/$HOST -t $tags
|
||||
else
|
||||
ansible-playbook $PWD/roles/apache.yml --key-file $KEY -e "ansible_user=$USER variable_host=$HOST PROXY=$PROXY CONT_NAME=$CONT_NAME service_dir=$service_dir SYN_FLOOD=$SYN_FLOOD STAT_PAGE=$STAT_PAGE STAT_PORT=$STAT_PORT STATS_USER=$STATS_USER STATS_PASS=$STATS_PASS CONFIG_PATH=$CONFIG_PATH SSH_PORT=$SSH_PORT service=apache" -i $PWD/$HOST -t $tags
|
||||
fi
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
echo "error: Can't install Apache service <br /><br />"
|
||||
exit 1
|
||||
else
|
||||
echo "ok"
|
||||
fi
|
||||
rm -f $PWD/$HOST
|
@ -0,0 +1,201 @@
|
||||
<tr class="odd">
|
||||
<td class="padding10 first-collumn-wi">
|
||||
{% if metrics_master == 'active' %}
|
||||
<span class="serverUp server-status" title="running {{ metrics_master }} master processes"></span>
|
||||
{% if role <= 1 %}
|
||||
<a href="/app/viewlogs.py?viewlogs={{metrics_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View metrics master's logs" class="logs_link">
|
||||
Metrics master
|
||||
</a>
|
||||
{% else %}
|
||||
Metrics master
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if metrics_master == 'inactive' or metrics_master == 'failed' %}
|
||||
<span class="serverDown server-status" title="Metrics is stopped"></span>
|
||||
{% if role <= 1 %}
|
||||
<a href="/app/users.py#services" title="Start Metrics - Roxy-WI service" class="logs_link">
|
||||
Metrics master
|
||||
</a>
|
||||
{% else %}
|
||||
Metrics master
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="serverNone server-status" title="Metrics is not installed"></span>
|
||||
<a href="https://roxy-wi.org/services.py?service=metrics#installation" title="Metrics installation" target="_blank" class="logs_link">
|
||||
Metrics master
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="third-collumn-wi">
|
||||
{% if checker_master == 'active' %}
|
||||
<span class="serverUp server-status" title="running {{ checker_master }} master processes"></span>
|
||||
{% if role <= 1 %}
|
||||
<a href="/app/viewlogs.py?viewlogs={{checker_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View checker master's logs" class="logs_link">
|
||||
Checker master
|
||||
</a>
|
||||
{% else %}
|
||||
Checker master
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if checker_master == 'inactive' or checker_master == 'failed' %}
|
||||
<span class="serverDown server-status" title="Checker is stopped"></span>
|
||||
{% if role <= 1 %}
|
||||
<a href="/app/users.py#services" title="Start Checker - Roxy-WI service" class="logs_link">
|
||||
Checker master
|
||||
</a>
|
||||
{% else %}
|
||||
Checker master
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="serverNone server-status" title="Backends checker is not installed"></span>
|
||||
<a href="https://roxy-wi.org/services.py?service=checker#installation" title="Backends checker installation" target="_blank" class="logs_link">
|
||||
Checker master
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="third-collumn-wi">
|
||||
{% if keep_alive == 'active' %}
|
||||
<span class="serverUp server-status" title="running {{ keep_alive }} processe"></span>
|
||||
{% if role <= 1 %}
|
||||
<a href="/app/viewlogs.py?viewlogs={{keep_alive_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View Auto start logs" class="logs_link">
|
||||
Auto start
|
||||
</a>
|
||||
{% else %}
|
||||
Auto star
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if keep_alive == 'inactive' or keep_alive == 'failed' %}
|
||||
<span class="serverDown server-status" title="Auto start is stopped"></span>
|
||||
{% if role <= 1 %}
|
||||
<a href="/app/users.py#services" title="Start Auto star - Roxy-WI service" class="logs_link">
|
||||
Auto start
|
||||
</a>
|
||||
{% else %}
|
||||
Auto start
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="serverNone server-status" title="Auto start is not installed"></span>
|
||||
<a href="https://roxy-wi.org/services.py?service=auto_start#installation" title="Auto start installation" target="_blank" class="logs_link">
|
||||
Auto start
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td class="padding10 first-collumn-wi">
|
||||
{% if metrics_worker|int() >= 1 %}
|
||||
<span class="serverUp server-status" title="running {{metrics_worker}} worker processes"></span>
|
||||
{% else %}
|
||||
{% if is_metrics_worker|int() == 0 %}
|
||||
<span class="serverNone server-status" title="There is not job for metrics"></span>
|
||||
{% else %}
|
||||
<span class="serverDown server-status" title="running {{is_checker_worker}} worker processes"></span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if role <= 1 %}
|
||||
<a href="/app/viewlogs.py?viewlogs={{metrics_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View worker's logs" class="logs_link">
|
||||
Metrics workers
|
||||
</a>
|
||||
{% else %}
|
||||
Metrics workers
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if checker_worker|int() >= 1 %}
|
||||
<span class="serverUp server-status" title="running {{ checker_worker }} worker processes"></span>
|
||||
{% else %}
|
||||
{% if is_checker_worker|int() == 0 %}
|
||||
<span class="serverNone server-status" title="There is not job for checker"></span>
|
||||
{% else %}
|
||||
<span class="serverDown server-status" title="running {{ checker_worker }} worker processes"></span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if role <= 1 %}
|
||||
<a href="/app/viewlogs.py?viewlogs={{checker_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View checker's logs" class="logs_link">
|
||||
Checker workers
|
||||
</a>
|
||||
{% else %}
|
||||
Checker workers
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if smon == 'active' %}
|
||||
<span class="serverUp server-status" title="SMON is started"></span>
|
||||
<a href="/app/smon.py?action=view" title="SMON Dashboard" class="logs_link">
|
||||
SMON
|
||||
</a>
|
||||
{% else %}
|
||||
{% if smon == 'inactive' or smon == 'failed' %}
|
||||
<span class="serverDown server-status" title="SMON is stopped"></span>
|
||||
<a href="/app/users.py#services" title="Start SMON - Roxy-WI service" class="logs_link">
|
||||
SMON
|
||||
</a>
|
||||
{% else %}
|
||||
<span title="SMON is not installed"><span class="serverNone server-status"></span></span>
|
||||
<a href="https://roxy-wi.org/services.py?service=smon" title="Simple monitoring ports installation" target="_blank" class="logs_link">
|
||||
SMON
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
{% if role == 1 %}
|
||||
<td class="padding10 first-collumn-wi">
|
||||
{% if grafana|int() >= 1 %}
|
||||
<span class="serverUp server-status" title="running {{grafana}} process"></span>
|
||||
<a href="http://{{host}}:3000" target="_blank" title="Open Grafana" class="logs_link" rel="noopener noreferrer">Grafana</a>
|
||||
{% else %}
|
||||
<span class="serverNone server-status" title="The service is not installed or not running"></span>
|
||||
<span>Grafana</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td {% if role != 1 %}class="padding10 first-collumn-wi"{%endif%}>
|
||||
{% if socket == 'active' %}
|
||||
<span class="serverUp server-status" title="Socket service is started"></span>
|
||||
{% if role <= 1 %}
|
||||
<a href="/app/viewlogs.py?viewlogs={{socket_log_id}}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View Socket's logs" class="logs_link">
|
||||
Socket service
|
||||
</a>
|
||||
{% else %}
|
||||
Socket service
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if socket == 'inactive' or socket == 'failed' %}
|
||||
<span class="serverDown server-status" title="Socket service scanner is stopped"></span>
|
||||
<a href="/app/users.py#services" title="Socket service - Roxy-WI service" class="logs_link">
|
||||
Socket service
|
||||
</a>
|
||||
{% else %}
|
||||
<span title="Socket service is not installed"><span class="serverNone server-status"></span></span>
|
||||
<a href="https://roxy-wi.org/services.py?service=socket" title="Socket service" target="_blank" class="logs_link">
|
||||
Socket service
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if port_scanner == 'active' %}
|
||||
<span class="serverUp server-status" title="Port scanner is started"></span>
|
||||
<a href="/app/portscanner.py" title="Port scanner Dashboard" class="logs_link">
|
||||
Port scanner
|
||||
</a>
|
||||
{% else %}
|
||||
{% if port_scanner == 'inactive' or port_scanner == 'failed' %}
|
||||
<span class="serverDown server-status" title="Port scanner is stopped"></span>
|
||||
<a href="/app/users.py#services" title="Start Port scanner - Roxy-WI service" class="logs_link">
|
||||
Port scanner
|
||||
</a>
|
||||
{% else %}
|
||||
<span title="Port scanner is not installed"><span class="serverNone server-status"></span></span>
|
||||
<a href="https://roxy-wi.org/services.py?service=port_scanner" title="Port scanner" target="_blank" class="logs_link">
|
||||
Port scanner
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
Loading…
Reference in new issue