Cookbooks
keepalived
documentation
Keepalived Virtual Server

keepalived_virtual_server

back to resource list (opens in a new tab)

The keepalived_virtual_server resource can be used to configure a track script via a virtual_server configuration block.

More information available at https://www.keepalived.org/manpage.html (opens in a new tab)

Actions

  • :create
  • :delete

Properties

NameTypeDefaultDescriptionAllowed Values
ip_addressStringnilName Property, IPaddress + Port of the server, eg: 192.168.1.1 80
real_serversArraynilReal Servers this is a virtual server for, will use include to load their files
ip_familyStringnilIP family for a fwmark serviceinet, inet6
delay_loopIntegernildelay timer for checker polling
lvs_schedStringnilLVS schedulerrr, wrr, lc, wlc, lblc, sh, mh, dh, fo, ovf, lblcr, sed, nq
opstrue, falsenilEnable One-Packet-Scheduling for UDP
lvs_methodStringnilDefault LVS forwarding methodNAT, DR
persistence_engineStringnilLVS persistence engine namesip
persistence_timeoutIntegernilLVS persistence timeout in seconds
persistence_granularityStringnilLVS granularity mask
protocolStringnilL4 protocolTCP, UDP, SCTP
ha_suspendtrue, falsenilIf VS IP address is not set, suspend healthchecker's activity
virtualhostStringnilDefault VirtualHost string for HTTP_GET or SSL_GET
alphatrue, falsenilOn daemon startup assume that all RSs are down and healthchecks failed
omegatrue, falsenilOn daemon shutdown consider quorum and RS down notifiers for execution, where appropriate
quorumIntegernilMinimum total weight of all live servers in the pool necessary to operate VS with no quality regression
hysteresisIntegernilTolerate this much weight units compared to the nominal quorum, when considering quorum gain or loss
quorum_upStringnilScript to execute when quorum is gained
quorum_downStringnilScript to execute when quorum is lost
sorry_serverStringnilIf a sorry server is configured, all real servers will be brought down when the quorum is not achieved
sorry_server_inhibittrue, falsenilapplies inhibit_on_failure behaviour to the sorry_server
config_directoryString/etc/keepalived/conf.ddirectory for the config file to reside in
config_fileString::File.join(config_directory, '00_keepalived_virtual_server__#{name}__.conf')full path to the config file
cookbookStringkeepalivedWhich cookbook to look in for the template
sourceStringvirtual_server.conf.erbName of the template to render

Examples

frontends = search(:node, 'role:frontend')
 
frontends.each do |fe|
  keepalived_real_server fe.name do
    ipaddress fe['ipaddress']
    port 80
    weight 5
    notifies :restart, 'service[keepalived]', :delayed
  end
end
 
server_paths = frontends.map do |fe|
  resources(keepalived_real_server: fe.name).config_file
end
 
keepalived_virtual_server '192.168.1.5 80' do
  lb_kind 'NAT'
  virtualhost 'www.sous-chefs.org'
  sorry_server '127.0.0.1 8080'
  real_servers server_paths.to_a
  notifies :restart, 'service[keepalived]', :delayed
end