Imported Upstream version 1.7.0
[platform/upstream/augeas.git] / lenses / puppetfileserver.aug
1 (* -*- coding: utf-8 -*-
2 Module: PuppetFileserver
3   Parses /etc/puppet/fileserver.conf used by puppetmasterd daemon.
4
5 Author: Frédéric Lespez <frederic.lespez@free.fr>
6
7 About: Reference
8   This lens tries to keep as close as possible to puppet documentation
9   for this file:
10   http://docs.puppetlabs.com/guides/file_serving.html
11
12 About: License
13   This file is licensed under the LGPL v2+, like the rest of Augeas.
14
15 About: Lens Usage
16   Sample usage of this lens in augtool
17
18     * Create a new mount point
19       > ins test_mount after /files/etc/puppet/fileserver.conf/*[last()]
20       > defvar test_mount /files/etc/puppet/fileserver.conf/test_mount
21       > set $test_mount/path /etc/puppet/files
22       > set $test_mount/allow *.example.com
23       > ins allow after $test_mount/*[last()]
24       > set $test_mount/allow[last()] server.domain.com
25       > set $test_mount/deny dangerous.server.com
26     * List the definition of a mount point
27       > print /files/etc/puppet/fileserver.conf/files
28     * Remove a mount point
29       > rm /files/etc/puppet/fileserver.conf/test_mount
30
31 About: Configuration files
32   This lens applies to /etc/puppet/fileserver.conf. See <filter>.
33 *)
34
35
36 module PuppetFileserver =
37   autoload xfm
38
39 (************************************************************************
40  * Group:                 USEFUL PRIMITIVES
41  *************************************************************************)
42
43 (* Group: INI File settings *)
44
45 (* Variable: eol *)
46 let eol = IniFile.eol
47
48 (* Variable: sep
49   Only treat one space as the sep, extras are stripped by IniFile *)
50 let sep = Util.del_str " "
51
52 (*
53 Variable: comment
54   Only supports "#" as commentary
55 *)
56 let comment = IniFile.comment "#" "#"
57
58 (*
59 Variable: entry_re
60   Regexp for possible <entry> keyword (path, allow, deny)
61 *)
62 let entry_re = /path|allow|deny/
63
64
65 (************************************************************************
66  * Group:                 ENTRY
67  *************************************************************************)
68
69 (*
70 View: entry
71   - It might be indented with an arbitrary amount of whitespace
72   - It does not have any separator between keywords and their values
73   - It can only have keywords with the following values (path, allow, deny)
74 *)
75 let entry = IniFile.indented_entry entry_re sep comment
76
77
78 (************************************************************************
79  * Group:                      RECORD
80  *************************************************************************)
81
82 (* Group: Title definition *)
83
84 (*
85 View: title
86   Uses standard INI File title
87 *)
88 let title = IniFile.indented_title IniFile.record_re
89
90 (*
91 View: title
92   Uses standard INI File record
93 *)
94 let record = IniFile.record title entry
95
96
97 (************************************************************************
98  * Group:                      LENS
99  *************************************************************************)
100
101 (*
102 View: lns
103   Uses standard INI File lens
104 *)
105 let lns = IniFile.lns record comment
106
107 (* Variable: filter *)
108 let filter = (incl "/etc/puppet/fileserver.conf"
109              .incl "/usr/local/etc/puppet/fileserver.conf"
110              .incl "/etc/puppetlabs/puppet/fileserver.conf")
111
112 let xfm = transform lns filter