3 Parses Redis's configuration files
5 Author: Marc Fournier <marc.fournier@camptocamp.com>
8 This lens is based on Redis's default redis.conf
12 augtool> set /augeas/load/Redis/incl "/etc/redis/redis.conf"
13 augtool> set /augeas/load/Redis/lens "Redis.lns"
16 augtool> get /files/etc/redis/redis.conf/vm-enabled
17 /files/etc/redis/redis.conf/vm-enabled = no
18 augtool> print /files/etc/redis/redis.conf/rename-command[1]/
19 /files/etc/redis/redis.conf/rename-command
20 /files/etc/redis/redis.conf/rename-command/from = "CONFIG"
21 /files/etc/redis/redis.conf/rename-command/to = "CONFIG2"
23 augtool> set /files/etc/redis/redis.conf/activerehashing no
26 augtool> set /files/etc/redis/redis.conf/save[1]/seconds 123
27 augtool> set /files/etc/redis/redis.conf/save[1]/keys 456
31 The <Test_Redis> file also contains various examples.
34 This file is licensed under the LGPL v2+, like the rest of Augeas.
42 let comment = Util.comment
43 let empty = Util.empty
44 let indent = Util.indent
46 let del_ws_spc = Util.del_ws_spc
47 let dquote = Util.del_str "\""
49 (* View: standard_entry
50 A standard entry is a key-value pair, separated by blank space, with optional
51 blank spaces at line beginning & end. The value part can be optionnaly enclosed
52 in single or double quotes. Comments at end-of-line ar NOT allowed by
56 let reserved_k = "save" | "rename-command" | "slaveof"
57 | "client-output-buffer-limit"
58 in let entry_noempty = [ indent . key k . del_ws_spc
59 . Quote.do_quote_opt_nil (store v) . eol ]
60 in let entry_empty = [ indent . key (k - reserved_k) . del_ws_spc
61 . dquote . store "" . dquote . eol ]
62 in entry_noempty | entry_empty
65 let seconds = [ label "seconds" . Quote.do_quote_opt_nil (store Rx.integer) ]
66 let keys = [ label "keys" . Quote.do_quote_opt_nil (store Rx.integer) ]
68 Entries identified by the "save" keyword can be found more than once. They have
69 2 mandatory parameters, both integers. The same rules as standard_entry apply
70 for quoting, comments and whitespaces.
72 let save_entry = [ indent . key save . del_ws_spc . seconds . del_ws_spc . keys . eol ]
74 let slaveof = /slaveof/
75 let ip = [ label "ip" . Quote.do_quote_opt_nil (store Rx.ip) ]
76 let port = [ label "port" . Quote.do_quote_opt_nil (store Rx.integer) ]
77 (* View: slaveof_entry
78 Entries identified by the "slaveof" keyword can be found more than once. They
79 have 2 mandatory parameters, the 1st one is an IP address, the 2nd one is a
80 port number. The same rules as standard_entry apply for quoting, comments and
83 let slaveof_entry = [ indent . key slaveof . del_ws_spc . ip . del_ws_spc . port . eol ]
85 let renamecmd = /rename-command/
86 let from = [ label "from" . Quote.do_quote_opt_nil (store Rx.word) ]
87 let to = [ label "to" . Quote.do_quote_opt_nil (store Rx.word) ]
89 Entries identified by the "rename-command" keyword can be found more than once.
90 They have 2 mandatory parameters, both strings. The same rules as
91 standard_entry apply for quoting, comments and whitespaces.
93 let renamecmd_entry = [ indent . key renamecmd . del_ws_spc . from . del_ws_spc . to . eol ]
95 let cobl_cmd = /client-output-buffer-limit/
96 let class = [ label "class" . Quote.do_quote_opt_nil (store Rx.word) ]
97 let hard_limit = [ label "hard_limit" . Quote.do_quote_opt_nil (store Rx.word) ]
98 let soft_limit = [ label "soft_limit" . Quote.do_quote_opt_nil (store Rx.word) ]
99 let soft_seconds = [ label "soft_seconds" . Quote.do_quote_opt_nil (store Rx.integer) ]
100 (* View: client_output_buffer_limit_entry
101 Entries identified by the "client-output-buffer-limit" keyword can be found
102 more than once. They have four mandatory paramters, of which the first is a
103 string, the last one is an integer and the others are either integers or words,
104 although redis is very liberal and takes "4242yadayadabytes" as a valid limit.
105 The same rules as standard_entry apply for quoting, comments and whitespaces.
107 let client_output_buffer_limit_entry =
108 [ indent . key cobl_cmd . del_ws_spc . class . del_ws_spc . hard_limit .
109 del_ws_spc . soft_limit . del_ws_spc . soft_seconds . eol ]
111 let entry = standard_entry
115 | client_output_buffer_limit_entry
120 let lns = (comment | empty | entry )*
122 let filter = incl "/etc/redis/redis.conf"
124 let xfm = transform lns filter