1 |
What is it? |
2 |
=========== |
3 |
|
4 |
A Puppet module that can construct files from fragments. |
5 |
|
6 |
Please see the comments in the various .pp files for details |
7 |
as well as posts on my blog at http://www.devco.net/ |
8 |
|
9 |
Released under the Apache 2.0 licence |
10 |
|
11 |
Usage: |
12 |
------ |
13 |
|
14 |
If you wanted a /etc/motd file that listed all the major modules |
15 |
on the machine. And that would be maintained automatically even |
16 |
if you just remove the include lines for other modules you could |
17 |
use code like below, a sample /etc/motd would be: |
18 |
|
19 |
<pre> |
20 |
Puppet modules on this server: |
21 |
|
22 |
-- Apache |
23 |
-- MySQL |
24 |
</pre> |
25 |
|
26 |
Local sysadmins can also append to the file by just editing /etc/motd.local |
27 |
their changes will be incorporated into the puppet managed motd. |
28 |
|
29 |
<pre> |
30 |
# class to setup basic motd, include on all nodes |
31 |
class motd { |
32 |
include concat::setup |
33 |
$motd = "/etc/motd" |
34 |
|
35 |
concat{$motd, |
36 |
owner => root, |
37 |
group => root, |
38 |
mode => 644 |
39 |
} |
40 |
|
41 |
concat::fragment{"motd_header": |
42 |
target => $motd, |
43 |
content => "\nPuppet modules on this server:\n\n", |
44 |
order => 01, |
45 |
} |
46 |
|
47 |
# local users on the machine can append to motd by just creating |
48 |
# /etc/motd.local |
49 |
concat::fragment{"motd_local": |
50 |
target => $motd, |
51 |
ensure => "/etc/motd.local", |
52 |
order => 15 |
53 |
} |
54 |
} |
55 |
|
56 |
# used by other modules to register themselves in the motd |
57 |
define motd::register($content="", $order=10) { |
58 |
if $content == "" { |
59 |
$body = $name |
60 |
} else { |
61 |
$body = $content |
62 |
} |
63 |
|
64 |
concat::fragment{"motd_fragment_$name": |
65 |
target => "/etc/motd", |
66 |
content => " -- $body\n" |
67 |
} |
68 |
} |
69 |
|
70 |
# a sample apache module |
71 |
class apache { |
72 |
include apache::install, apache::config, apache::service |
73 |
|
74 |
motd::register{"Apache": } |
75 |
} |
76 |
</pre> |
77 |
|
78 |
Known Issues: |
79 |
------------- |
80 |
* In 0.24.8 you will see inintended notifies, if you build a file |
81 |
in a run, the next run will also see it as changed. This is due |
82 |
to how 0.24.8 does the purging of unhandled files, this is improved |
83 |
in 0.25.x and we cannot work around it in our code. |
84 |
|
85 |
Contributors: |
86 |
------------- |
87 |
**Paul Elliot** |
88 |
|
89 |
* Provided 0.24.8 support, shell warnings and empty file creation support. |
90 |
|
91 |
**Chad Netzer** |
92 |
|
93 |
* Various patches to improve safety of file operations |
94 |
* Symlink support |
95 |
|
96 |
**David Schmitt** |
97 |
|
98 |
* Patch to remove hard coded paths relying on OS path |
99 |
* Patch to use file{} to copy the resulting file to the final destination. This means Puppet client will show diffs and that hopefully we can change file ownerships now |
100 |
|
101 |
Contact: |
102 |
-------- |
103 |
You can contact me on rip@devco.net or follow my blog at http://www.devco.net I am also on twitter as ripienaar |