summaryrefslogtreecommitdiffstats
path: root/doc/server/plugins/generators/tgenshi/motd.txt
blob: 89cf77dc5222002b8d9151ad60ff61197b028fb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
.. -*- mode: rst -*-

.. _server-plugins-generators-tgenshi-motd:

motd
====

The following template automatically generates a MOTD (message of the
day) file that describes the system in terms of its Bcfg2 metadata
and probe responses.  It conditionally displays groups, categories,
and probe responses, if there exists any data for them.

New Style of TGenshi
--------------------

This is the preferred way of creating TGenshi contents. It requires
Genshi 0.5 or later.

On the Bcfg2 server
^^^^^^^^^^^^^^^^^^^

Where, **$bcfg2** is your Bcfg2 repository on your Bcfg2 server, the
following files need to be created:

::

    $bcfg2/TGenshi/etc/motd/info.xml
    $bcfg2/TGenshi/etc/motd/template.newtxt

The contents of ``motd/template.newtxt`` could be something like this::

    ------------------------------------------------------------------------
                        GOALS FOR SERVER MANGED BY BCFG2
    ------------------------------------------------------------------------
    Hostname is ${metadata.hostname}

    Groups:
    {% for group in metadata.groups %}\
     * ${group}
    {% end %}\

    {% if metadata.categories %}\
    Categories:
    {% for category in metadata.categories %}\
     * ${category}
    {% end %}\
    {% end %}\


    {% if metadata.Probes %}\
    Probes:
    {% for probe, value in metadata.Probes.iteritems() %}\
     * ${probe} \
       ${value}
    {% end %}\
    {% end %}\

    -------------------------------------------------------------------------
                            ITOPS MOTD
    -------------------------------------------------------------------------
    Please create a Ticket for any system level changes you need from IT.

This template gets the hostname, groups membership of the host, categories
of the host (if any), and result of probes on the host (if any). The
template formats this in with a header and footer that makes it visually
more appealing.

A ``motd/info.xml`` file isn't strictly needed, because ``/etc/motd``
has the Bcfg2 default permissions (i.e. root:root 0644), but it can be
included for completeness.

Output
^^^^^^

One possible output of this template would be the following::

    ------------------------------------------------------------------------
                        GOALS FOR SERVER MANGED BY BCFG2
    ------------------------------------------------------------------------
    Hostname is cobra.example.com

    Groups:
     * oracle-server
     * centos5-5.2
     * centos5
     * redhat
     * x86_64
     * sys-vmware

    Categories:
     * os-variant
     * os
     * database-server
     * os-version


    Probes:
     * arch    x86_64
     * network    intranet_network
     * diskspace    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup00-LogVol00
                           18G  2.1G   15G  13% /
    /dev/sda1              99M   13M   82M  13% /boot
    tmpfs                 3.8G     0  3.8G   0% /dev/shm
    /dev/mapper/mhcdbo-clear
                          1.5T  198M  1.5T   1% /mnt/san-oracle
     * virtual    vmware

    -------------------------------------------------------------------------
                            IT MOTD
    -------------------------------------------------------------------------
    Please create a Ticket for any system level changes you need from IT.

Taking it to the next level
^^^^^^^^^^^^^^^^^^^^^^^^^^^

One way to make this even more useful, is to only include the result of
certain probes. It would also be a nice feature to be able to include
customer messages on a host or group level.

Old Style of TGenshi
--------------------

The following is a way to do the same thing using the older,
it-may-be-depreciated, style of Genshi (pre-0.5).::

    Hostname is $metadata.hostname

    Groups:
    #for group in metadata.groups
     * $group
    #end

    #if metadata.categories
    Categories:
    #for category in metadata.categories
     * $category
    #end
    #end

    #if metadata.probes
    Probes:
    #for probe, value in metadata.probes.iteritems()
     * $probe $value
    #end
    #end

This template results in::

    > buildfile /bar.conf ubik3
    <ConfigFile name="/bar.conf" owner="root" perms="0644" group="root">Hostname is ubik3

    Groups:
     * desktop
     * computeserver
     * mcs-base
     * ypbound
     * workstation
     * mysql-4
     * debian-sarge-base
     * debian-sarge
     * base
     * debian

    Categories:
     * noyp
     * mysql

    </ConfigFile>