Parses /etc/keepalived/keepalived.conf
Author: Raphael Pinson rap@gmai l.com hink
Keepalived | Parses /etc/keepalived/keepalived.conf |
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. |
USEFUL PRIMITIVES | |
Comments and empty lines | |
indent | |
eol | |
sep_spc | |
lbracket | |
rbracket | |
comment | Map comments in “#comment” nodes |
comment_eol | Map comments at eol |
comment_or_eol | A comment_eol or eol |
empty | Map empty lines |
sto_email_addr | |
word | |
word_slash | |
sto_word | |
sto_num | |
field | |
flag | A single word |
lens_block | A generic block with a title lens |
block | A simple block with just a block title |
named_block | A block with a block title and name |
named_block_arg_title | A title lens for named_block_arg |
named_block_arg | A block with a block title, a name and an argument |
GLOBAL CONFIGURATION | |
A simple email address entry | |
global_defs_field | Possible fields in the global_defs block |
global_defs | A global_defs block |
prefixlen | A prefix for IP addresses |
ipaddr | An IP address or range with an optional mask |
ipdev | A device for IP addresses |
static_ipaddress_field | The whole string is fed to ip addr add. |
static_routes_field | src $SRC_IP to $DST_IP dev $SRC_DEVICE |
static_routes | |
global_conf | A global configuration entry |
VRRP CONFIGURATION | |
vrrp_sync_group_field | |
vrrp_sync_group | |
vrrp_instance_field | |
vrrp_instance | |
vrrpd_conf | contains 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_conf | contains subblocks of Virtual server group(s) and Virtual server(s) |
lns | The keepalived lens |
filter |
This lens applies to /etc/keepalived/keepalived.conf. See filter.
let comment_or_eol = comment_eol | ( del /[ \t]*#?\n/ "\n" )
A comment_eol or eol
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`.
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 | flag "smtp_alert" | flag "nopreempt" | block "authentication" ( field "auth_type" sto_word | field "auth_pass" sto_word ) | block "virtual_ipaddress" static_ipaddress_field
let indent = Util.indent
let eol = Util.eol
let sep_spc = Sep.space
let rbracket = Util.del_str "}"
Map comments in “#comment” nodes
let comment = Util.comment_generic /[ \t]*[#!][ \t]*/ "# "
Map comments at eol
let comment_eol = Util.comment_generic /[ \t]*[#!][ \t]*/ " # "
A comment_eol or eol
let comment_or_eol = comment_eol | ( del /[ \t]*#?\n/ "\n" )
Map empty lines
let empty = Util.empty
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.integer
let field ( kw:string ) (sto:lens) = indent . Build.key_value_line_comment kw sep_spc sto comment_eol
A single word
let flag ( kw:regexp ) = indent . Build.flag kw
A generic block with a title lens
let lens_block ( title:lens ) (sto:lens) = [ indent . title . sep_spc . lbracket . eol . (sto | empty | comment)+ . indent . rbracket . eol ]
A simple block with just a block title
let block ( kw:string ) (sto:lens) = lens_block (key kw) sto
A block with a block title and name
let named_block ( kw:string ) (sto:lens) = lens_block (key kw . sep_spc . sto_word) sto
A title lens for named_block_arg
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 block with a block title, a name and an argument
let named_block_arg ( kw:string ) (name:string) (arg:string) (sto:lens) = lens_block (named_block_arg_title kw name arg) sto
A simple email address entry
let email = [ indent . label "email" . sto_email_addr . comment_or_eol ]
Possible fields in the global_defs block
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
A global_defs block
let global_defs = block "global_defs" global_defs_field
A prefix for IP addresses
let prefixlen = [ label "prefixlen" . Util.del_str "/" . sto_num ]
An IP address or range with an optional mask
let ipaddr = label "ipaddr" . store /[0-9\.-]+/ . prefixlen?
A device for IP addresses
let ipdev = [ key "dev" . sep_spc . sto_word ]
The whole string is fed to ip addr add.
let static_ipaddress_field = [ indent . ipaddr . (sep_spc . ipdev)? . comment_or_eol ]
src $SRC_IP to $DST_IP dev $SRC_DEVICE
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 ]
let static_routes = block "static_ipaddress" static_ipaddress_field | block "static_routes" static_routes_field
A global configuration entry
let global_conf = global_defs | static_routes
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 | flag "smtp_alert" | flag "nopreempt" | block "authentication" ( field "auth_type" sto_word | field "auth_pass" sto_word ) | block "virtual_ipaddress" static_ipaddress_field
let vrrp_instance = named_block "vrrp_instance" vrrp_instance_field
contains subblocks of VRRP synchronization group(s) and VRRP instance(s)
let vrrpd_conf = vrrp_sync_group | vrrp_instance
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
contains subblocks of Virtual server group(s) and Virtual server(s)
let lvs_conf = virtual_server | virtual_server_group
The keepalived lens
let lns = ( empty | comment | global_conf | vrrpd_conf | lvs_conf )*