Keepalived

Parses /etc/keepalived/keepalived.conf

Author: Raphael Pinson rap.nosp@m.hink@gmai.nosp@m.l.com

Summary
KeepalivedParses /etc/keepalived/keepalived.conf
ReferenceThis lens tries to keep as close as possible to `man 5 keepalived.conf` where possible.
LicenseThis file is licenced under the LGPLv2+, like the rest of Augeas.
Lens UsageTo be documented
Configuration filesThis lens applies to /etc/keepalived/keepalived.conf.
ExamplesThe Test_Keepalived file contains various examples and tests.
USEFUL PRIMITIVES
Comments and empty lines
indent
eol
opt_eol
sep_spc
sep_opt_spc
sep_dquot
lbracket
rbracket
commentMap comments in “#comment” nodes
comment_eolMap comments at eol
comment_or_eolA comment_eol or eol
emptyMap empty lines
sto_email_addr
word
word_slash
sto_word
sto_num
sto_to_eol
field
flagA single word
lens_blockA generic block with a title lens
blockA simple block with just a block title
named_blockA block with a block title and name
named_block_arg_titleA title lens for named_block_arg
named_block_argA block with a block title, a name and an argument
GLOBAL CONFIGURATION
emailA simple email address entry
global_defs_fieldPossible fields in the global_defs block
global_defsA global_defs block
prefixlenA prefix for IP addresses
ipaddrAn IP address or range with an optional mask
ipdevA device for IP addresses
static_ipaddress_fieldThe whole string is fed to ip addr add.
static_routes_fieldsrc $SRC_IP to $DST_IP dev $SRC_DEVICE
static_routes
global_confA global configuration entry
VRRP CONFIGURATION
vrrp_sync_group_field
vrrp_sync_group
vrrp_instance_field
vrrp_instance
vrrp_script_field
vrrp_script
vrrpd_confcontains subblocks of VRRP synchronization group(s) and VRRP instance(s)
LVS CONFIGURATION
tcp_check_field
real_server_field
virtual_server_field
virtual_server
virtual_server_group_field
virtual_server_group
lvs_confcontains subblocks of Virtual server group(s) and Virtual server(s)
lnsThe keepalived lens
filter

Reference

This lens tries to keep as close as possible to `man 5 keepalived.conf` where possible.

License

This file is licenced under the LGPLv2+, like the rest of Augeas.

Lens Usage

To be documented

Configuration files

This lens applies to /etc/keepalived/keepalived.conf.  See filter.

Examples

The Test_Keepalived file contains various examples and tests.

USEFUL PRIMITIVES

Comments and empty lines

indent

let indent = Util.indent

eol

let eol = Util.eol

opt_eol

let opt_eol = del /[ \t]*\n?/ " "

sep_spc

let sep_spc = Sep.space

sep_opt_spc

let sep_opt_spc = Sep.opt_space

sep_dquot

let sep_dquot = Util.del_str "\""

lbracket

rbracket

let rbracket = Util.del_str "}"

comment

let comment = Util.comment_generic /[ \t]*[#!][ \t]*/ "# "

Map comments in “#comment” nodes

comment_eol

let comment_eol = Util.comment_generic /[ \t]*[#!][ \t]*/ " # "

Map comments at eol

comment_or_eol

let comment_or_eol = comment_eol | (del /[ \t]*[#!]?\n/ "\n")

A comment_eol or eol

empty

let empty = Util.empty

Map empty lines

sto_email_addr

let sto_email_addr = store Rx.email_addr

word

let word = Rx.word

word_slash

let word_slash = word | "/"

sto_word

let sto_word = store word

sto_num

let sto_num = store Rx.relinteger

sto_to_eol

let sto_to_eol = store /[^#! \t\n][^#!\n]*[^#! \t\n]|[^#! \t\n]/

field

let field (kw:string) (sto:lens) = indent . Build.key_value_line_comment kw sep_spc sto comment_eol

flag

let flag (kw:regexp) = [ indent . key kw . comment_or_eol ]

A single word

lens_block

let lens_block (title:lens) (sto:lens) = [ indent . title . opt_eol . lbracket . (sto | empty | comment)+ . indent . rbracket . eol ]

A generic block with a title lens

block

let block (kw:string) (sto:lens) = lens_block (key kw) sto

A simple block with just a block title

named_block

let named_block (kw:string) (sto:lens) = lens_block (key kw . sep_spc . sto_word) sto

A block with a block title and name

named_block_arg_title

let named_block_arg_title (kw:string) (name:string) (arg:string) = key kw . sep_spc . [ label name . sto_word ] . sep_spc . [ label arg . sto_word ]

A title lens for named_block_arg

named_block_arg

let named_block_arg (kw:string) (name:string) (arg:string) (sto:lens) = lens_block (named_block_arg_title kw name arg) sto

A block with a block title, a name and an argument

GLOBAL CONFIGURATION

email

let email = [ indent . label "email" . sto_email_addr . comment_or_eol ]

A simple email address entry

global_defs_field

let global_defs_field = block "notification_email" email | field "notification_email_from" sto_email_addr | field "smtp_server" sto_word | field "smtp_connect_timeout" sto_num | field "lvs_id" sto_word | field "router_id" sto_word

Possible fields in the global_defs block

global_defs

let global_defs = block "global_defs" global_defs_field

A global_defs block

prefixlen

let prefixlen = [ label "prefixlen" . Util.del_str "/" . sto_num ]

A prefix for IP addresses

ipaddr

let ipaddr = label "ipaddr" . store /[0-9.-]+/ . prefixlen?

An IP address or range with an optional mask

ipdev

let ipdev = [ key "dev" . sep_spc . sto_word ]

A device for IP addresses

static_ipaddress_field

let static_ipaddress_field = [ indent . ipaddr . (sep_spc . ipdev)? . comment_or_eol ]

The whole string is fed to ip addr add.  You can truncate the string anywhere you like and let ip addr add use defaults for the rest of the string.  To be refined with fields according to `ip addr help`.

static_routes_field

let static_routes_field = [ indent . label "route" . [ key "src" . sto_word ] . sep_spc . [ key "to" . sto_word ] . sep_spc . [ key "dev" . sto_word ] . comment_or_eol ]

src $SRC_IP to $DST_IP dev $SRC_DEVICE

static_routes

let static_routes = block "static_ipaddress" static_ipaddress_field | block "static_routes" static_routes_field

global_conf

let global_conf = global_defs | static_routes

A global configuration entry

VRRP CONFIGURATION

vrrp_sync_group_field

let vrrp_sync_group_field = block "group" [ indent . key word . comment_or_eol ]

vrrp_sync_group

let vrrp_sync_group = named_block "vrrp_sync_group" vrrp_sync_group_field

vrrp_instance_field

let vrrp_instance_field = field "state" sto_word | field "interface" sto_word | field "lvs_sync_daemon_interface" sto_word | field "virtual_router_id" sto_num | field "priority" sto_num | field "advert_int" sto_num | field "garp_master_delay" sto_num | field "notify_master" sto_to_eol | field "notify_backup" sto_to_eol | field "notify_fault" sto_to_eol | flag "smtp_alert" | flag "nopreempt" | flag "ha_suspend" | flag "debug" | block "authentication" ( field "auth_type" sto_word | field "auth_pass" sto_word ) | block "virtual_ipaddress" static_ipaddress_field | block "track_interface" ( flag word ) | block "track_script" ( flag word )

vrrp_instance

let vrrp_instance = named_block "vrrp_instance" vrrp_instance_field

vrrp_script_field

let vrrp_script_field = field "script" sto_to_eol | field "interval" sto_num | field "weight" sto_num

vrrp_script

let vrrp_script = named_block "vrrp_script" vrrp_script_field

vrrpd_conf

let vrrpd_conf = vrrp_sync_group | vrrp_instance | vrrp_script

contains subblocks of VRRP synchronization group(s) and VRRP instance(s)

LVS CONFIGURATION

tcp_check_field

let tcp_check_field = field "connect_timeout" sto_num | field "connect_port" sto_num

real_server_field

let real_server_field = field "weight" sto_num | block "TCP_CHECK" tcp_check_field

virtual_server_field

let virtual_server_field = field "delay_loop" sto_num | field "lb_algo" sto_word | field "lb_kind" sto_word | field "nat_mask" sto_word | field "protocol" sto_word | named_block_arg "real_server" "ip" "port" real_server_field

virtual_server

let virtual_server = named_block_arg "virtual_server" "ip" "port" virtual_server_field

virtual_server_group_field

let virtual_server_group_field = [ indent . label "vip" . [ ipaddr ] . sep_spc . [ label "port" . sto_num ] . comment_or_eol ]

virtual_server_group

let virtual_server_group = named_block "virtual_server_group" virtual_server_group_field

lvs_conf

let lvs_conf = virtual_server | virtual_server_group

contains subblocks of Virtual server group(s) and Virtual server(s)

lns

let lns = ( empty | comment | global_conf | vrrpd_conf | lvs_conf )*

The keepalived lens

filter

Provides unit tests and examples for the Keepalived lens.
let indent = Util.indent
let eol = Util.eol
let opt_eol = del /[ \t]*\n?/ " "
let sep_spc = Sep.space
let sep_opt_spc = Sep.opt_space
let sep_dquot = Util.del_str "\""
let rbracket = Util.del_str "}"
let comment = Util.comment_generic /[ \t]*[#!][ \t]*/ "# "
Map comments in “#comment” nodes
let comment_eol = Util.comment_generic /[ \t]*[#!][ \t]*/ " # "
Map comments at eol
let comment_or_eol = comment_eol | (del /[ \t]*[#!]?\n/ "\n")
A comment_eol or eol
let empty = Util.empty
Map empty lines
let sto_email_addr = store Rx.email_addr
let word = Rx.word
let word_slash = word | "/"
let sto_word = store word
let sto_num = store Rx.relinteger
let sto_to_eol = store /[^#! \t\n][^#!\n]*[^#! \t\n]|[^#! \t\n]/
let field (kw:string) (sto:lens) = indent . Build.key_value_line_comment kw sep_spc sto comment_eol
let flag (kw:regexp) = [ indent . key kw . comment_or_eol ]
A single word
let lens_block (title:lens) (sto:lens) = [ indent . title . opt_eol . lbracket . (sto | empty | comment)+ . indent . rbracket . eol ]
A generic block with a title lens
let block (kw:string) (sto:lens) = lens_block (key kw) sto
A simple block with just a block title
let named_block (kw:string) (sto:lens) = lens_block (key kw . sep_spc . sto_word) sto
A block with a block title and name
let named_block_arg_title (kw:string) (name:string) (arg:string) = key kw . sep_spc . [ label name . sto_word ] . sep_spc . [ label arg . sto_word ]
A title lens for named_block_arg
let named_block_arg (kw:string) (name:string) (arg:string) (sto:lens) = lens_block (named_block_arg_title kw name arg) sto
A block with a block title, a name and an argument
let email = [ indent . label "email" . sto_email_addr . comment_or_eol ]
A simple email address entry
let global_defs_field = block "notification_email" email | field "notification_email_from" sto_email_addr | field "smtp_server" sto_word | field "smtp_connect_timeout" sto_num | field "lvs_id" sto_word | field "router_id" sto_word
Possible fields in the global_defs block
let global_defs = block "global_defs" global_defs_field
A global_defs block
let prefixlen = [ label "prefixlen" . Util.del_str "/" . sto_num ]
A prefix for IP addresses
let ipaddr = label "ipaddr" . store /[0-9.-]+/ . prefixlen?
An IP address or range with an optional mask
let ipdev = [ key "dev" . sep_spc . sto_word ]
A device for IP addresses
let static_ipaddress_field = [ indent . ipaddr . (sep_spc . ipdev)? . comment_or_eol ]
The whole string is fed to ip addr add.
let static_routes_field = [ indent . label "route" . [ key "src" . sto_word ] . sep_spc . [ key "to" . sto_word ] . sep_spc . [ key "dev" . sto_word ] . comment_or_eol ]
src $SRC_IP to $DST_IP dev $SRC_DEVICE
let static_routes = block "static_ipaddress" static_ipaddress_field | block "static_routes" static_routes_field
let global_conf = global_defs | static_routes
A global configuration entry
let vrrp_sync_group_field = block "group" [ indent . key word . comment_or_eol ]
let vrrp_sync_group = named_block "vrrp_sync_group" vrrp_sync_group_field
let vrrp_instance_field = field "state" sto_word | field "interface" sto_word | field "lvs_sync_daemon_interface" sto_word | field "virtual_router_id" sto_num | field "priority" sto_num | field "advert_int" sto_num | field "garp_master_delay" sto_num | field "notify_master" sto_to_eol | field "notify_backup" sto_to_eol | field "notify_fault" sto_to_eol | flag "smtp_alert" | flag "nopreempt" | flag "ha_suspend" | flag "debug" | block "authentication" ( field "auth_type" sto_word | field "auth_pass" sto_word ) | block "virtual_ipaddress" static_ipaddress_field | block "track_interface" ( flag word ) | block "track_script" ( flag word )
let vrrp_instance = named_block "vrrp_instance" vrrp_instance_field
let vrrp_script_field = field "script" sto_to_eol | field "interval" sto_num | field "weight" sto_num
let vrrp_script = named_block "vrrp_script" vrrp_script_field
let vrrpd_conf = vrrp_sync_group | vrrp_instance | vrrp_script
contains subblocks of VRRP synchronization group(s) and VRRP instance(s)
let tcp_check_field = field "connect_timeout" sto_num | field "connect_port" sto_num
let real_server_field = field "weight" sto_num | block "TCP_CHECK" tcp_check_field
let virtual_server_field = field "delay_loop" sto_num | field "lb_algo" sto_word | field "lb_kind" sto_word | field "nat_mask" sto_word | field "protocol" sto_word | named_block_arg "real_server" "ip" "port" real_server_field
let virtual_server = named_block_arg "virtual_server" "ip" "port" virtual_server_field
let virtual_server_group_field = [ indent . label "vip" . [ ipaddr ] . sep_spc . [ label "port" . sto_num ] . comment_or_eol ]
let virtual_server_group = named_block "virtual_server_group" virtual_server_group_field
let lvs_conf = virtual_server | virtual_server_group
contains subblocks of Virtual server group(s) and Virtual server(s)
let lns = ( empty | comment | global_conf | vrrpd_conf | lvs_conf )*
The keepalived lens
Close