Skip to content

Commit

Permalink
Add advert_int, weight and thresholds
Browse files Browse the repository at this point in the history
This allows more configuration items for the real_server.
Courtesy of @thehawkes .
  • Loading branch information
thehawkes authored and evrardjp committed Jan 17, 2020
1 parent 5cba18f commit 7e069ff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
16 changes: 14 additions & 2 deletions templates/keepalived.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ vrrp_instance {{ name }} {
{% if instance.preempt_delay is defined %}
preempt_delay {{ instance.preempt_delay }} # Seconds after startup until preemption. 0 (default) to 1,000.
{% endif %}
{% if instance.advert_int is defined %}
advert_int {{ instance.advert_int }}
{% endif %}
{% if instance.authentication_password is defined %}
authentication {
auth_type PASS
Expand Down Expand Up @@ -167,6 +170,15 @@ virtual_server {{ vserver.ip }} {{ vserver.port }} {

{% for rserver in vserver.real_servers %}
real_server {{ rserver.ip }} {{ rserver.port }} {
{% if rserver.weight is defined %}
weight {{ rserver.weight | int }}
{% endif %}
{% if rserver.uthreshold is defined %}
uthreshold {{ rserver.uthreshold | int }}
{% endif %}
{% if rserver.lthreshold is defined %}
lthreshold {{ rserver.lthreshold | int }}
{% endif %}
{% if rserver.tcp_checks is defined %}
{% for tcp_check in rserver.tcp_checks %}
TCP_CHECK {
Expand Down Expand Up @@ -208,7 +220,7 @@ virtual_server {{ vserver.ip }} {{ vserver.port }} {
misc_dynamic
{% endif %}
{% if mcheck.user is defined and mcheck.user %}
{% if mcheck.group is defined and mcheck.group %}
{% if mcheck.group is defined and mcheck.group %}
user {{ mcheck.user }} {{ mcheck.group }}
{% else %}
user {{ mcheck.user }}
Expand All @@ -223,7 +235,7 @@ virtual_server {{ vserver.ip }} {{ vserver.port }} {
url {
path {{ http_check.url_path }}
digest {{ http_check.url_digest }}
}
}
connect_timeout {{ http_check.connect_timeout | default('3') }}
nb_get_retry {{ http_check.nb_get_retry | default('3') }}
delay_before_retry {{ http_check.delay_before_retry | default('2') }}
Expand Down
10 changes: 9 additions & 1 deletion tests/keepalived_haproxy_master_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ keepalived_instances:
state: MASTER
virtual_router_id: 10
priority: 100
#Optional, VRRP Advert interval in seconds
#advert_int: 1
# Please set this if you want to use authentication in your VRRP
# instance. If more than 8 characters, it will be truncated.
# The password must be the same per router_id (so backup and
Expand Down Expand Up @@ -114,7 +116,13 @@ keepalived_instances:
# real_servers:
# - IP: '8.8.8.8'
# port: '53'
# # Currently on MISC_CHECK is supported. Section is optional.
# # Optional, relative weight to use, default: 1
# weight: 3
# # Optional, maximum number of connections to server
# uthreshold: 1000
# # Optional, minimum number of connections to server
# lthreshold: 1000
# # Section is optional.
# misc_check:
# - misc_path: '/usr/bin/host -W 1 github.com 8.8.8.8'
# # Role default is 3
Expand Down

0 comments on commit 7e069ff

Please sign in to comment.