官术网_书友最值得收藏!

Producing automatic HTML documentation

"An expert is someone who is one page ahead of you in the manual."—David Knight

Like most engineers, I never read the manual, unless and until the product actually catches fire. However, as your manifests get bigger and more complex, it can be helpful to create HTML documentation for your nodes and classes using Puppet's automatic documentation tool, puppet doc.

How to do it…

Run puppet doc over your manifest as follows:

puppet doc --all --outputdir=/var/www/html/puppet --mode rdoc --manifestdir=/etc/puppet/manifests/

How it works…

puppet doc creates a structured HTML documentation tree in /var/www/html/puppet similar to that produced by RDoc, the popular Ruby documentation generator. This makes it easier to understand how different parts of the manifest relate to one another, as you can click on an included class name and see its definition.

There's more…

puppet doc will generate basic documentation of your manifests as they are at present. However, you can include more useful information by adding comments to your manifest files, using the standard RDoc syntax. Here's an example of some documentation comments added to a class:

class puppet {
    # This class sets up the Puppet client.
    #
    # ==Actions
    # Install a cron job to run Puppet.
    #
    # ==Requires
    # * Package["puppet"]
    #
    cron { "run-puppet":
        command => "/usr/sbin/puppet agent --test >/dev/null 2>&1",
        minute  => inline_template("<%= hostname.hash.abs % 60 %>"),
    }
}

Your comments are added to the documentation for each class in the resulting HTML files as shown in the following screenshot:

主站蜘蛛池模板: 喜德县| 西乌| 遵化市| 武陟县| 周宁县| 台中县| 南靖县| 棋牌| 电白县| 华阴市| 辽阳县| 旬邑县| 上饶县| 迭部县| 五常市| 咸宁市| 桃园市| 利川市| 瑞丽市| 寻甸| 阜宁县| 广丰县| 诏安县| 丰顺县| 淅川县| 深圳市| 枣阳市| 郑州市| 新邵县| 修武县| 蓬溪县| 祥云县| 嵩明县| 池州市| 沈丘县| 三门县| 濮阳县| 浮梁县| 安国市| 安塞县| 石门县|