Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / puppet_auth.aug
1 (*
2 Module: Puppet_Auth
3   Parses /etc/puppet/auth.conf
4
5 Author: Raphael Pinson <raphael.pinson@camptocamp.com>
6
7 About: Reference
8   This lens tries to keep as close as possible to `http://docs.puppetlabs.com/guides/rest_auth_conf.html` where possible.
9
10 About: License
11    This file is licenced under the LGPL v2+, like the rest of Augeas.
12
13 About: Lens Usage
14    To be documented
15
16 About: Configuration files
17    This lens applies to /etc/puppet/auth.conf. See <filter>.
18
19 About: Examples
20    The <Test_Puppet_Auth> file contains various examples and tests.
21 *)
22
23 module Puppet_Auth =
24
25 autoload xfm
26
27 (* View: list
28    A list of values *)
29 let list (kw:string) (val:regexp) =
30      let item = [ seq kw . store val ]
31   in let comma = del /[ \t]*,[ \t]*/ ", "
32   in [ Util.indent . key kw . Sep.space
33      . Build.opt_list item comma . Util.comment_or_eol ]
34
35 (* View: auth
36    An authentication stanza *)
37 let auth =
38   [ Util.indent . Build.xchg /auth(enticated)?/ "auth" "auth"
39   . Sep.space . store /yes|no|on|off|any/ . Util.comment_or_eol ]
40
41 (* View: reset_counters *)
42 let reset_counters =
43     counter "environment" . counter "method"
44   . counter "allow" . counter "allow_ip"
45
46 (* View: setting *)
47 let setting = list "environment" Rx.word
48             | list "method" /find|search|save|destroy/
49             | list "allow" /[^# \t\n,][^#\n,]*[^# \t\n,]|[^# \t\n,]/
50             | list "allow_ip" /[A-Za-z0-9.:\/]+/
51             | auth
52
53 (* View: record *)
54 let record =
55      let operator = [ label "operator" . store "~" ]
56   in [ Util.indent . key "path"
57       . (Sep.space . operator)?
58       . Sep.space . store /[^~# \t\n][^#\n]*[^# \t\n]|[^~# \t\n]/ . Util.eol
59       . reset_counters
60       . (Util.empty | Util.comment | setting)*
61       . setting ]
62
63 (* View: lns *)
64 let lns = (Util.empty | Util.comment | record)*
65
66 (* Variable: filter *)
67 let filter = (incl "/etc/puppet/auth.conf"
68              .incl "/usr/local/etc/puppet/auth.conf"
69              .incl "/etc/puppetlabs/puppet/auth.conf")
70
71 let xfm = transform lns filter