Puppet Manifest Documentation

Version 5 (Nick Fagerlund, 12/29/2011 11:28 am)

1 1
# Puppet Manifest Documentation
2 1
3 1
Starting with version 0.24.7, Puppet ships with an enhanced
4 1
puppetdoc executable that allows user to generate browser readable
5 1
HTML or direct to console output of documentation embedded in
6 1
Puppet manifests.
7 1
8 1
# Documentation format
9 1
10 5 Nick Fagerlund
[rdoc]: http://links.puppetlabs.com/rdoc_markup
11 1
12 5 Nick Fagerlund
Documentation for a class (or defined type) should be written in
13 5 Nick Fagerlund
[RDoc format][rdoc] and placed in a large comment directly before the class
14 5 Nick Fagerlund
being documented. For example:
15 5 Nick Fagerlund
16 5 Nick Fagerlund
    # = Class: users
17 1
    #
18 5 Nick Fagerlund
    # This class installs our default set of users in our servers.
19 1
    #
20 5 Nick Fagerlund
    # == Parameters:
21 1
    #
22 5 Nick Fagerlund
    # $starting_uid::   This global variable is used to set the minimum
23 5 Nick Fagerlund
    #                   uid used for our users.
24 5 Nick Fagerlund
    #
25 5 Nick Fagerlund
    # $primary_group::  The primary group for all of our default users.
26 5 Nick Fagerlund
    #
27 5 Nick Fagerlund
    # == Actions:
28 1
    #   Install the default set of users: [dana,fox]
29 1
    #
30 5 Nick Fagerlund
    # == Requires:
31 1
    #   - Package["zsh"]
32 1
    #
33 5 Nick Fagerlund
    # == Sample Usage:
34 5 Nick Fagerlund
    # 
35 5 Nick Fagerlund
    #   class {'users':
36 5 Nick Fagerlund
    #     starting_uid  => 501,
37 5 Nick Fagerlund
    #     primary_group => 'staff',
38 5 Nick Fagerlund
    #   }
39 1
    #
40 1
    class users {
41 1
                  ...
42 1
    }
43 1
44 1
Note: the next line after the documentation must be the class that
45 1
is being documented as in the example above.
46 1
47 1
# Direct to Console Output
48 1
49 1
The first mode for puppetdoc is to output the documentation
50 1
contained in the the various comments of a sole manifest
51 1
*without any post-processing* to the console.
52 1
53 1
This mode of running puppetdoc is perfect if you want to post
54 1
process the documentation by another system to produce man pages
55 1
from ReST (for instance with Pandoc:
56 1
[http://johnmacfarlane.net/pandoc/](http://johnmacfarlane.net/pandoc/))
57 1
58 1
Usage:
59 1
60 1
    $ puppetdoc [-all] <file-spec>
61 1
62 1
Argument:
63 1
64 1
    <file-spec>: path to a manifest file, for instance /etc/puppet/manifests/site.pp
65 1
66 1
By default, it outputs documentation from nodes, classes and
67 1
definitions contained into the manifest given as argument.
68 1
69 1
Option:
70 1
71 1
    --all or -a: produces also documentation attached to resources.
72 1
73 1
# RDoc HTML Generation
74 1
75 1
The second mode of puppetdoc is to generate a set of HTML files, as
76 1
RDoc does for ruby or Javadoc for Java.
77 1
78 5 Nick Fagerlund
The system is based on RDoc, and as such uses [RDoc markup][rdoc].
79 1
80 1
Usage:
81 1
82 1
    $ puppetdoc [--all] --mode rdoc [--outputdir <path-spec>] [--debug|--verbose] [--trace]
83 1
                [--modulepath <path-list>] [--manifestdir <path-spec>] [--config <file-spec>]
84 1
85 1
Options:
86 1
87 1
--all
88 1
produces documentation for all the resources along with the other
89 1
documentations produced.
90 1
--outputdir
91 1
store the result into the given directory instead of 'doc' in the
92 1
current directory.
93 1
--debug
94 1
display debug and greater level messages
95 1
--verbose
96 1
display info and greater level messages
97 1
--trace
98 1
display Ruby stack trace in case of error
99 1
--modulepath
100 1
override the puppet.conf modulepath. See puppetmasterd modulepath
101 1
option.
102 1
--manifestdir
103 1
override the puppet.conf manifestdir. See puppetmasterd manifestdir
104 1
option.
105 1
--config
106 1
override the default puppet.conf location. See puppetmasterd config
107 1
option.
108 1
The puppetdoc binary in RDoc mode supports most of the
109 1
puppetmasterd options related to module or manifest location,
110 1
including environments.
111 1
112 1
If no --config or --configdir options are used, then puppetdoc uses
113 1
the default puppetmasterd configuration file for the current user
114 1
(usually \~/.puppet or /etc/puppet/).
115 1
116 1
If one puppet.conf file can be found in --configdir or --config,
117 1
then the modulepath and manifestdir of the [puppetmasterd] section
118 1
are used.
119 1
120 1
Passing the --modulepath or the --manifestdir options on command
121 1
line overrides their respective values found in the puppet.conf
122 1
file.
123 1
124 1
By default, puppetdoc generates documentation with comments
125 1
associated with classes, nodes, definitions, nodes global
126 1
variables, custom facts and Puppet plugins located in modules.
127 1
128 1
Documentation is produced for each class and definition in each
129 1
module. Global manifests (i.e. those under manifestdir) are located
130 1
under the special "\<site>" module. Each class, module or plugin is
131 1
cross-referenced throughout the whole documentation.
132 1
133 1
Module documentation is extracted from an existing README file that
134 1
would be located under the module root directory:
135 1
136 1
    /etc/puppet/modules/postfix/manifest/init.pp
137 1
    /etc/puppet/modules/postfix/README
138 1
139 1
When producing the documentation for the whole module, the README
140 1
file will be used.
141 1
142 1
Class documentation is extracted as in direct to console output
143 1
from the comments just before the said class. The same for nodes,
144 1
definitions, global assignments, or resources.
145 1
146 1
The system reports included classes in including class.
147 1
148 1
# Puppetdoc Output
149 1
150 1
The Puppet Manifest Documentation system is based upon RDoc. By
151 1
default, puppetdoc outputs the documentation under the doc
152 1
directory (which can be overridden with --outputdir). This
153 1
directory can be viewed by a web browser or can be directly put
154 1
under a document root of a Web server for global access.
155 1
156 1
The system outputs one file per module, several files per classes,
157 1
along with global indices and per modules indices.
158 1
159 1
# RDoc markup
160 1
161 1
Since the HTML generation is based on RDoc, the various comments
162 1
where the documentation is extracted should be formatted with RDoc
163 1
markup. The RDoc markup is lightweight, implicit and
164 1
non-intrusive.
165 1
166 1
Here are the more important RDoc Markup rules extracted from RDoc
167 1
documentation.
168 1
169 1
Note that most of these markup elements are recognized only if they
170 1
are non-indented and start at the beginning of line.
171 1
172 1
-   Lists are typed as paragraphs with:
173 1
174 1
    -   a '\*' or '-' (for bullet lists)
175 1
    -   a digit followed by a period for numbered lists
176 1
177 1
-   Labelled lists (sometimes called description lists) are typed
178 1
    using square brackets for the label.
179 1
180 1
    -   [cat] small domestic animal
181 1
    -   [+cat+] command to copy standard input
182 1
183 1
-   Labelled lists may also be produced by putting a double colon
184 1
    after the label. This sets the result in tabular form, so the
185 1
    descriptions all line up.
186 1
187 1
    -   cat:: small domestic animal
188 1
    -   +cat+:: command to copy standard input
189 1
190 1
    For both kinds of labelled lists, if the body text starts on the
191 1
    same line as the label, then the start of that text determines the
192 1
    block indent for the rest of the body. The text may also start on
193 1
    the line following the label, indented from the start of the label.
194 1
    This is often preferable if the label is long.
195 1
196 1
-   Headings are entered using equals signs
197 1
198 1
    -   = Level One Heading
199 1
    -   == Level Two Heading
200 1
    -   and so on
201 1
202 1
-   Rules (horizontal lines) are entered using three or more
203 1
    hyphens.
204 1
205 1
-   Non-verbatim text can be marked up
206 1
207 1
    -   \*bold\*
208 1
    -   \_italic\_
209 1
    -   +typewriter+
210 1
211 1
-   Hyperlinks to the web starting http:, mailto:, ftp:, or www.
212 1
    are recognized. An HTTP url that references an external image file
213 1
    is converted into an inline \<IMG..>. Hyperlinks starting link: are
214 1
    assumed to refer to local files whose path is relative to the
215 1
    --outputdir directory.
216 1
217 1
-   Hyperlinks can also be of the form label[url], in which case
218 1
    the label is used in the displayed text, and url is used as the
219 1
    target.
220 1
221 1
-   Puppetdoc stops processing comments if it finds a comment line
222 1
    containing #--. This can be used to separate external from internal
223 1
    comments, or to stop a comment being associated with a method,
224 1
    class, or module. Commenting can be turned back on with a line that
225 1
    starts #++.
226 1
227 1
-   Comment blocks can contain other directives
228 1
229 1
    -   :include:filename
230 4 Thomas L. Kjeldsen
        :   include the contents of the named file at this point. The file will be searched for in the current directory by default. The contents of the file will be shifted to have the same indentation as the ':' at the start of the :include: directive.
231 1
232 1
233 1
    -   :title:text
234 1
        :   Sets the title for the document.
235 1
236 1
237 1
    -   :main:name
238 1
        :   Sets name as the main page.