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" | "replicaof" | "slaveof"
57 | "bind" | "client-output-buffer-limit"
59 in let entry_noempty = [ indent . key (k - reserved_k) . del_ws_spc
60 . Quote.do_quote_opt_nil (store v) . eol ]
61 in let entry_empty = [ indent . key (k - reserved_k) . del_ws_spc
62 . dquote . store "" . dquote . eol ]
63 in entry_noempty | entry_empty
66 let seconds = [ label "seconds" . Quote.do_quote_opt_nil (store Rx.integer) ]
67 let keys = [ label "keys" . Quote.do_quote_opt_nil (store Rx.integer) ]
69 let save_val_empty = del_ws_spc . dquote . store "" . dquote
70 in let save_val_sec_keys = del_ws_spc . seconds . del_ws_spc . keys
71 in save_val_sec_keys | save_val_empty
74 Entries identified by the "save" keyword can be found more than once. They have
75 2 mandatory parameters, both integers or a single parameter that is empty double quoted
76 string. The same rules as standard_entry apply for quoting, comments and whitespaces.
78 let save_entry = [ indent . key save . save_val . eol ]
80 let replicaof = /replicaof|slaveof/
81 let ip = [ label "ip" . Quote.do_quote_opt_nil (store Rx.ip) ]
82 let port = [ label "port" . Quote.do_quote_opt_nil (store Rx.integer) ]
83 (* View: replicaof_entry
84 Entries identified by the "replicaof" keyword can be found more than once. They
85 have 2 mandatory parameters, the 1st one is an IP address, the 2nd one is a
86 port number. The same rules as standard_entry apply for quoting, comments and
89 let replicaof_entry = [ indent . key replicaof . del_ws_spc . ip . del_ws_spc . port . eol ]
91 let sentinel_global_entry =
92 let keys = "deny-scripts-reconfig" | "current-epoch" | "myid"
94 del_ws_spc . [ label "value" . store ( Rx.word | Rx.integer ) ]
96 let sentinel_cluster_setup =
97 let keys = "config-epoch" | "leader-epoch"
99 del_ws_spc . [ label "cluster" . store Rx.word ] .
100 del_ws_spc . [ label "epoch" . store Rx.integer ]
102 let sentinel_cluster_instance_setup =
103 let keys = "monitor" | "known-replica"
105 del_ws_spc . [ label "cluster" . store Rx.word ] .
106 del_ws_spc. [ label "ip" . store Rx.ip ] .
107 del_ws_spc . [ label "port" . store Rx.integer ] .
108 (del_ws_spc . [ label "quorum" . store Rx.integer ])?
110 let sentinel_clustering =
111 let keys = "known-sentinel"
113 del_ws_spc . [ label "cluster" . store Rx.word ] .
114 del_ws_spc . [ label "ip" . store Rx.ip ] .
115 del_ws_spc . [ label "port" . store Rx.integer ] .
116 del_ws_spc . [ label "id" . store Rx.word ]
118 (* View: sentinel_entry
121 indent . [ key "sentinel" . del_ws_spc .
122 (sentinel_global_entry | sentinel_cluster_setup | sentinel_cluster_instance_setup | sentinel_clustering)
126 The "bind" entry can be passed one or several ip addresses. A bind
127 statement "bind ip1 ip2 .. ipn" results in a tree
128 { "bind" { "ip" = ip1 } { "ip" = ip2 } ... { "ip" = ipn } }
131 let ip = del_ws_spc . Quote.do_quote_opt_nil (store Rx.ip) in
132 indent . [ key "bind" . [ label "ip" . ip ]+ ] . eol
134 let renamecmd = /rename-command/
135 let from = [ label "from" . Quote.do_quote_opt_nil (store Rx.word) ]
136 let to = [ label "to" . Quote.do_quote_opt_nil (store Rx.word) ]
138 Entries identified by the "rename-command" keyword can be found more than once.
139 They have 2 mandatory parameters, both strings. The same rules as
140 standard_entry apply for quoting, comments and whitespaces.
142 let renamecmd_entry = [ indent . key renamecmd . del_ws_spc . from . del_ws_spc . to . eol ]
144 let cobl_cmd = /client-output-buffer-limit/
145 let class = [ label "class" . Quote.do_quote_opt_nil (store Rx.word) ]
146 let hard_limit = [ label "hard_limit" . Quote.do_quote_opt_nil (store Rx.word) ]
147 let soft_limit = [ label "soft_limit" . Quote.do_quote_opt_nil (store Rx.word) ]
148 let soft_seconds = [ label "soft_seconds" . Quote.do_quote_opt_nil (store Rx.integer) ]
149 (* View: client_output_buffer_limit_entry
150 Entries identified by the "client-output-buffer-limit" keyword can be found
151 more than once. They have four mandatory parameters, of which the first is a
152 string, the last one is an integer and the others are either integers or words,
153 although redis is very liberal and takes "4242yadayadabytes" as a valid limit.
154 The same rules as standard_entry apply for quoting, comments and whitespaces.
156 let client_output_buffer_limit_entry =
157 [ indent . key cobl_cmd . del_ws_spc . class . del_ws_spc . hard_limit .
158 del_ws_spc . soft_limit . del_ws_spc . soft_seconds . eol ]
160 let entry = standard_entry
166 | client_output_buffer_limit_entry
171 let lns = (comment | empty | entry )*
174 incl "/etc/redis.conf"
175 . incl "/etc/redis/redis.conf"
177 let xfm = transform lns filter