mirror of https://github.com/Aidaho12/haproxy-wi
parent
46cb2910eb
commit
3562e8a4f3
|
@ -121,7 +121,7 @@ def default_values():
|
||||||
{'param': 'apache_dir', 'value': '/etc/httpd/', 'section': 'apache',
|
{'param': 'apache_dir', 'value': '/etc/httpd/', 'section': 'apache',
|
||||||
'desc': 'Path to the Apache directory with config files', 'group': '1'},
|
'desc': 'Path to the Apache directory with config files', 'group': '1'},
|
||||||
{'param': 'apache_config_path', 'value': '/etc/httpd/conf/httpd.conf', 'section': 'apache',
|
{'param': 'apache_config_path', 'value': '/etc/httpd/conf/httpd.conf', 'section': 'apache',
|
||||||
'desc': 'Path to the main Nginx configuration file', 'group': '1'},
|
'desc': 'Path to the main Apache configuration file', 'group': '1'},
|
||||||
{'param': 'apache_container_name', 'value': 'apache', 'section': 'apache',
|
{'param': 'apache_container_name', 'value': 'apache', 'section': 'apache',
|
||||||
'desc': 'Docker container name for Apache service', 'group': '1'},
|
'desc': 'Docker container name for Apache service', 'group': '1'},
|
||||||
]
|
]
|
||||||
|
|
|
@ -1018,7 +1018,7 @@ def upload_and_restart(server_ip, cfg, **kwargs):
|
||||||
if is_docker == '1':
|
if is_docker == '1':
|
||||||
check_config = "sudo docker exec -it " + container_name + " haproxy -q -c -f " + tmp_file
|
check_config = "sudo docker exec -it " + container_name + " haproxy -q -c -f " + tmp_file
|
||||||
else:
|
else:
|
||||||
check_config = "sudo " + service_name + " -q -c -f " + tmp_file
|
check_config = "sudo " + service_name + " -c -f " + tmp_file
|
||||||
move_config = " && sudo mv -f " + tmp_file + " " + config_path
|
move_config = " && sudo mv -f " + tmp_file + " " + config_path
|
||||||
|
|
||||||
if action == "test":
|
if action == "test":
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
---
|
---
|
||||||
MASTER: MASTER
|
MASTER: MASTER
|
||||||
|
router_id: 1
|
|
@ -1,7 +1,7 @@
|
||||||
vrrp_instance VI_{{IP}} {
|
vrrp_instance VI_{{IP}} {
|
||||||
state {{MASTER}}
|
state {{MASTER}}
|
||||||
interface {{ETH}}
|
interface {{ETH}}
|
||||||
virtual_router_id {{ range(2, 255) | random }}
|
virtual_router_id {{ router_id }}
|
||||||
priority {% if RETURN_TO_MASTER == 1 and MASTER == 'MASTER' %}152{% elif MASTER == 'MASTER' and RETURN_TO_MASTER == 0 %}102{% else %}101{%endif%}
|
priority {% if RETURN_TO_MASTER == 1 and MASTER == 'MASTER' %}152{% elif MASTER == 'MASTER' and RETURN_TO_MASTER == 0 %}102{% else %}101{%endif%}
|
||||||
|
|
||||||
track_script {
|
track_script {
|
||||||
|
|
|
@ -3,14 +3,14 @@ global_defs {
|
||||||
}
|
}
|
||||||
#health-check for keepalive
|
#health-check for keepalive
|
||||||
vrrp_script chk_haproxy {
|
vrrp_script chk_haproxy {
|
||||||
script "/usr/bin/pgrep -f 'haproxy '"
|
script "killall -0 haproxy"
|
||||||
interval 2
|
interval 2
|
||||||
weight 3
|
weight 3
|
||||||
}
|
}
|
||||||
vrrp_instance VI_1 {
|
vrrp_instance VI_1 {
|
||||||
state {{MASTER}}
|
state {{MASTER}}
|
||||||
interface {{ETH}}
|
interface {{ETH}}
|
||||||
virtual_router_id 1
|
virtual_router_id {{router_id}}
|
||||||
priority {% if RETURN_TO_MASTER == '1' and MASTER == 'MASTER' %}152{% elif MASTER == 'MASTER' and RETURN_TO_MASTER == '0' %}102{% else %}101{%endif%}
|
priority {% if RETURN_TO_MASTER == '1' and MASTER == 'MASTER' %}152{% elif MASTER == 'MASTER' and RETURN_TO_MASTER == '0' %}102{% else %}101{%endif%}
|
||||||
|
|
||||||
#check if we are still running
|
#check if we are still running
|
||||||
|
|
|
@ -31,16 +31,17 @@ export COMMAND_WARNINGS=False
|
||||||
PWD=`pwd`
|
PWD=`pwd`
|
||||||
PWD=$PWD/scripts/ansible/
|
PWD=$PWD/scripts/ansible/
|
||||||
echo "$HOST ansible_port=$SSH_PORT" > $PWD/$HOST
|
echo "$HOST ansible_port=$SSH_PORT" > $PWD/$HOST
|
||||||
|
router_id=`echo $((1 + $RANDOM % 255))`
|
||||||
|
|
||||||
if [[ $KEY == "" ]]; then
|
if [[ $KEY == "" ]]; then
|
||||||
ansible-playbook $PWD/roles/keepalived.yml -e "ansible_user=$USER ansible_ssh_pass='$PASS' variable_host=$HOST SYN_FLOOD=$SYN_FLOOD PROXY=$PROXY MASTER=$MASTER ETH=$ETH IP=$IP RESTART=$RESTART RETURN_TO_MASTER=$RETURN_TO_MASTER ADD_VRRP=$ADD_VRRP SSH_PORT=$SSH_PORT" -i $PWD/$HOST
|
ansible-playbook $PWD/roles/keepalived.yml -e "ansible_user=$USER ansible_ssh_pass='$PASS' variable_host=$HOST SYN_FLOOD=$SYN_FLOOD PROXY=$PROXY MASTER=$MASTER ETH=$ETH IP=$IP RESTART=$RESTART RETURN_TO_MASTER=$RETURN_TO_MASTER ADD_VRRP=$ADD_VRRP router_id=$router_id SSH_PORT=$SSH_PORT" -i $PWD/$HOST
|
||||||
else
|
else
|
||||||
ansible-playbook $PWD/roles/keepalived.yml --key-file $KEY -e "ansible_user=$USER variable_host=$HOST SYN_FLOOD=$SYN_FLOOD PROXY=$PROXY MASTER=$MASTER ETH=$ETH IP=$IP RESTART=$RESTART RETURN_TO_MASTER=$RETURN_TO_MASTER ADD_VRRP=$ADD_VRRP SSH_PORT=$SSH_PORT" -i $PWD/$HOST
|
ansible-playbook $PWD/roles/keepalived.yml --key-file $KEY -e "ansible_user=$USER variable_host=$HOST SYN_FLOOD=$SYN_FLOOD PROXY=$PROXY MASTER=$MASTER ETH=$ETH IP=$IP RESTART=$RESTART RETURN_TO_MASTER=$RETURN_TO_MASTER ADD_VRRP=$ADD_VRRP router_id=$router_id SSH_PORT=$SSH_PORT" -i $PWD/$HOST
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $? -gt 0 ]
|
if [ $? -gt 0 ]
|
||||||
then
|
then
|
||||||
echo "error: Can't install keepalived service <br /><br />"
|
echo "error: Can't install keepalived service <br />"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
rm -f $PWD/$HOST
|
rm -f $PWD/$HOST
|
|
@ -204,7 +204,7 @@ def add_setting_for_new_group(group_id):
|
||||||
{'param': 'apache_dir', 'value': '/etc/httpd/', 'section': 'apache',
|
{'param': 'apache_dir', 'value': '/etc/httpd/', 'section': 'apache',
|
||||||
'desc': 'Path to the Apache directory with config files', 'group': group_id},
|
'desc': 'Path to the Apache directory with config files', 'group': group_id},
|
||||||
{'param': 'apache_config_path', 'value': '/etc/httpd/conf/httpd.conf', 'section': 'apache',
|
{'param': 'apache_config_path', 'value': '/etc/httpd/conf/httpd.conf', 'section': 'apache',
|
||||||
'desc': 'Path to the main Nginx configuration file', 'group': group_id},
|
'desc': 'Path to the main Apache configuration file', 'group': group_id},
|
||||||
{'param': 'apache_container_name', 'value': 'apache', 'section': 'apache',
|
{'param': 'apache_container_name', 'value': 'apache', 'section': 'apache',
|
||||||
'desc': 'Docker container name for Apache service', 'group': group_id},
|
'desc': 'Docker container name for Apache service', 'group': group_id},
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue