|
1 | 1 | # A system to construct files using fragments from other files or templates. |
2 | 2 | # |
3 | | -# This requires at least puppet 0.25 to work correctly as we use some |
| 3 | +# This requires at least puppet 0.25 to work correctly as we use some |
4 | 4 | # enhancements in recursive directory management and regular expressions |
5 | 5 | # to do the work here. |
6 | 6 | # |
7 | 7 | # USAGE: |
8 | 8 | # The basic use case is as below: |
9 | 9 | # |
10 | | -# concat{"/etc/named.conf": |
| 10 | +# concat{"/etc/named.conf": |
11 | 11 | # notify => Service["named"] |
12 | 12 | # } |
13 | 13 | # |
|
17 | 17 | # content => template("named_conf_zone.erb") |
18 | 18 | # } |
19 | 19 | # |
20 | | -# # add a fragment not managed by puppet so local users |
| 20 | +# # add a fragment not managed by puppet so local users |
21 | 21 | # # can add content to managed file |
22 | 22 | # concat::fragment{"foo.com_user_config": |
23 | 23 | # target => "/etc/named.conf", |
24 | 24 | # order => 12, |
25 | 25 | # ensure => "/etc/named.conf.local" |
26 | 26 | # } |
27 | 27 | # |
28 | | -# This will use the template named_conf_zone.erb to build a single |
| 28 | +# This will use the template named_conf_zone.erb to build a single |
29 | 29 | # bit of config up and put it into the fragments dir. The file |
30 | 30 | # will have an number prefix of 10, you can use the order option |
31 | 31 | # to control that and thus control the order the final file gets built in. |
|
39 | 39 | # There's some regular expression magic to figure out the puppet version but |
40 | 40 | # if you're on an older 0.24 version just set $puppetversion = 24 |
41 | 41 | # |
42 | | -# Before you can use any of the concat features you should include the |
| 42 | +# Before you can use any of the concat features you should include the |
43 | 43 | # class concat::setup somewhere on your node first. |
44 | 44 | # |
45 | 45 | # DETAIL: |
|
48 | 48 | # seem more complex than some of the one-liner alternatives you might find on |
49 | 49 | # the net we do a lot of error checking and safety checks in the script to avoid |
50 | 50 | # problems that might be caused by complex escaping errors etc. |
51 | | -# |
| 51 | +# |
52 | 52 | # LICENSE: |
53 | 53 | # Apache Version 2 |
54 | 54 | # |
55 | 55 | # LATEST: |
56 | 56 | # http://github.com/ripienaar/puppet-concat/ |
57 | 57 | # |
58 | 58 | # CONTACT: |
59 | | -# R.I.Pienaar <rip@devco.net> |
| 59 | +# R.I.Pienaar <rip@devco.net> |
60 | 60 | # Volcane on freenode |
61 | 61 | # @ripienaar on twitter |
62 | 62 | # www.devco.net |
63 | 63 |
|
64 | 64 |
|
65 | | -# Sets up so that you can use fragments to build a final config file, |
| 65 | +# Sets up so that you can use fragments to build a final config file, |
66 | 66 | # |
67 | 67 | # OPTIONS: |
68 | 68 | # - mode The mode of the final file |
|
78 | 78 | # - Creates fragment directories if it didn't exist already |
79 | 79 | # - Executes the concatfragments.sh script to build the final file, this script will create |
80 | 80 | # directory/fragments.concat. Execution happens only when: |
81 | | -# * The directory changes |
82 | | -# * fragments.concat != final destination, this means rebuilds will happen whenever |
| 81 | +# * The directory changes |
| 82 | +# * fragments.concat != final destination, this means rebuilds will happen whenever |
83 | 83 | # someone changes or deletes the final file. Checking is done using /usr/bin/cmp. |
84 | 84 | # * The Exec gets notified by something else - like the concat::fragment define |
85 | 85 | # - Copies the file over to the final destination using a file resource |
86 | 86 | # |
87 | 87 | # ALIASES: |
88 | 88 | # - The exec can notified using Exec["concat_/path/to/file"] or Exec["concat_/path/to/directory"] |
89 | | -# - The final file can be referened as File["/path/to/file"] or File["concat_/path/to/file"] |
90 | | -define concat($mode = 0644, $owner = $::id, $group = $concat::setup::root_group, $warn = "false", $force = "false", $backup = "puppet", $gnu = "true", $order="alpha") { |
| 89 | +# - The final file can be referened as File["/path/to/file"] or File["concat_/path/to/file"] |
| 90 | +define concat($mode = 0644, $owner = $::id, $group = $concat::setup::root_group, $warn = "false", $force = "false", $backup = "puppet", $gnu = undef, $order="alpha") { |
91 | 91 | $safe_name = regsubst($name, '/', '_', 'G') |
92 | 92 | $concatdir = $concat::setup::concatdir |
93 | 93 | $version = $concat::setup::majorversion |
|
113 | 113 | default: { fail("Improper 'force' value given to concat: $force") } |
114 | 114 | } |
115 | 115 |
|
116 | | - case $gnu { |
117 | | - 'true',true,yes,on: { $gnuflag = "" } |
118 | | - 'false',false,no,off: { $gnuflag = "-g" } |
119 | | - default: { fail("Improper 'gnu' value given to concat: $gnu") } |
120 | | - } |
121 | | - |
122 | 116 | case $order { |
123 | 117 | numeric: { $orderflag = "-n" } |
124 | 118 | alpha: { $orderflag = "" } |
|
168 | 162 | subscribe => File[$fragdir], |
169 | 163 | alias => "concat_${fragdir}", |
170 | 164 | require => [ File[$fragdir], File["${fragdir}/fragments"], File["${fragdir}/fragments.concat"] ], |
171 | | - unless => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} -t ${warnflag} ${forceflag} ${orderflag} ${gnuflag}", |
172 | | - command => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag} ${gnuflag}", |
| 165 | + unless => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} -t ${warnflag} ${forceflag} ${orderflag}", |
| 166 | + command => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag}", |
173 | 167 | } |
174 | 168 | if $::id == 'root' { |
175 | 169 | Exec["concat_${name}"]{ |
|
0 commit comments