Keepalived Real Server


back to resource list (opens in a new tab)

The keepalived_real_server resource can be used to configure real_server blocks within a virtual_server. They are managed as separate configuration files, and injected into the virtual_server block via include directives configured via the real_servers property of the keepalived_virtual_server resource.

A keepalived_real_server can be associated with a healthcheck via an include of a file containing a check sub-block using the healthcheck property. If using any of the health check resources provided by this cookbook, you can use the config_file method on the associated resource to automatically get the appropriate configuration path, as shown below.

More information available at (opens in a new tab)


  • :create
  • :delete


NameTypeDefaultDescriptionAllowed Values
ipaddressStringnilIP Address of the Server
portIntegernilPort of the Server
healthcheckStringnilIncludes a healthcheck file
weightIntegernilScript to run for notifications when any transition of state happens
inhibit_on_failuretrue, falsenil
notify_upStringnilScript to execute when healthchecker considers the service as up
notify_downStringnilScript to execute when healthchecker considers the service as down
config_directoryString/etc/keepalived/servers.ddirectory for the config file to reside in
config_fileString::File.join(config_directory, 'keepalived_real_server__#{ipaddress}-#{port}__.conf')full path to the config file
cookbookStringkeepalivedWhich cookbook to look in for the template
sourceStringreal_server.conf.erbName of the template to render


keepalived_real_server 'Secure Web Server' do
  ipaddress ipaddress
  port      port
  notify_up '/usr/local/bin/'
  notify_down '/usr/local/bin/'
  inhibit_on_failure true
  notifies :restart, 'service[keepalived]', :delayed
keepalived_http_get 'health_check_url' do
  nb_get_retry 3
  url path: '/health_check', status_code: 200
  notifies :restart, 'service[keepalived]', :delayed
keepalived_real_server 'fe01' do
  ipaddress ''
  port 80
  weight 5
  inhibit_on_failure true
  healthcheck resources(keepalived_http_get: 'health_check_url').config_file
  notifies :restart, 'service[keepalived]', :delayed
Was this helpful?