freighthop 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. checksums.yaml +7 -0
  2. data/Puppetfile +1 -1
  3. data/Puppetfile.lock +4 -5
  4. data/README.md +18 -7
  5. data/Vagrantfile +4 -0
  6. data/lib/freighthop/cli/help.rb +1 -0
  7. data/lib/freighthop/cli/init.rb +10 -10
  8. data/lib/freighthop/cli/version.rb +17 -0
  9. data/lib/freighthop/cli.rb +3 -1
  10. data/lib/freighthop/version.rb +1 -1
  11. data/lib/freighthop.rb +4 -0
  12. data/modules/apt/CHANGELOG +2 -36
  13. data/modules/apt/Gemfile +5 -6
  14. data/modules/apt/Gemfile.lock +7 -40
  15. data/modules/apt/Modulefile +1 -1
  16. data/modules/apt/README.md +1 -2
  17. data/modules/apt/Rakefile +0 -1
  18. data/modules/apt/manifests/init.pp +2 -5
  19. data/modules/apt/manifests/params.pp +1 -4
  20. data/modules/apt/manifests/pin.pp +1 -1
  21. data/modules/apt/manifests/ppa.pp +10 -24
  22. data/modules/apt/manifests/update.pp +0 -1
  23. data/modules/apt/metadata.json +19 -32
  24. data/modules/apt/spec/defines/ppa_spec.rb +2 -53
  25. data/modules/apt/spec/defines/source_spec.rb +2 -2
  26. data/modules/apt/templates/source.list.erb +2 -2
  27. data/modules/apt/tests/key.pp +3 -3
  28. data/modules/concat/CHANGELOG +73 -0
  29. data/modules/concat/Gemfile +20 -0
  30. data/modules/concat/Gemfile.lock +104 -0
  31. data/modules/concat/Modulefile +7 -6
  32. data/modules/concat/README.md +440 -0
  33. data/modules/concat/Rakefile +5 -1
  34. data/modules/concat/files/concatfragments.rb +137 -0
  35. data/modules/concat/files/concatfragments.sh +15 -4
  36. data/modules/concat/lib/facter/concat_basedir.rb +9 -3
  37. data/modules/concat/manifests/fragment.pp +108 -48
  38. data/modules/concat/manifests/init.pp +191 -210
  39. data/modules/concat/manifests/setup.pp +31 -31
  40. data/modules/concat/metadata.json +40 -21
  41. data/modules/{apt → concat}/spec/spec_helper_system.rb +11 -6
  42. data/modules/{firewall → concat}/spec/system/basic_spec.rb +1 -1
  43. data/modules/concat/spec/system/concat_spec.rb +154 -0
  44. data/modules/concat/spec/system/deprecation_warnings_spec.rb +247 -0
  45. data/modules/concat/spec/system/empty_spec.rb +27 -0
  46. data/modules/concat/spec/system/fragment_source_spec.rb +142 -0
  47. data/modules/concat/spec/system/replace_spec.rb +257 -0
  48. data/modules/concat/spec/system/symbolic_name_spec.rb +35 -0
  49. data/modules/concat/spec/system/warn_spec.rb +106 -0
  50. data/modules/concat/spec/unit/classes/concat_setup_spec.rb +42 -0
  51. data/modules/concat/spec/unit/defines/concat_fragment_spec.rb +267 -0
  52. data/modules/concat/spec/unit/defines/concat_spec.rb +380 -0
  53. data/modules/concat/spec/unit/facts/concat_basedir_spec.rb +18 -0
  54. data/modules/concat/tests/fragment.pp +19 -0
  55. data/modules/concat/tests/init.pp +7 -0
  56. data/modules/firewall/Changelog +38 -0
  57. data/modules/firewall/Gemfile +5 -2
  58. data/modules/firewall/Gemfile.lock +76 -26
  59. data/modules/firewall/Modulefile +1 -1
  60. data/modules/firewall/README.markdown +47 -15
  61. data/modules/firewall/Rakefile +0 -7
  62. data/modules/firewall/lib/puppet/provider/firewall/ip6tables.rb +50 -7
  63. data/modules/firewall/lib/puppet/provider/firewall/iptables.rb +147 -31
  64. data/modules/firewall/lib/puppet/provider/firewallchain/iptables_chain.rb +19 -8
  65. data/modules/firewall/lib/puppet/type/firewall.rb +207 -3
  66. data/modules/firewall/lib/puppet/type/firewallchain.rb +73 -2
  67. data/modules/firewall/lib/puppet/util/firewall.rb +14 -0
  68. data/modules/firewall/metadata.json +181 -76
  69. data/modules/firewall/spec/acceptance/basic_spec.rb +8 -0
  70. data/modules/firewall/spec/acceptance/change_source_spec.rb +77 -0
  71. data/modules/firewall/spec/acceptance/class_spec.rb +27 -0
  72. data/modules/firewall/spec/acceptance/firewall_spec.rb +1608 -0
  73. data/modules/firewall/spec/acceptance/firewallchain_spec.rb +125 -0
  74. data/modules/firewall/spec/acceptance/ip6_fragment_spec.rb +94 -0
  75. data/modules/firewall/spec/acceptance/isfragment_spec.rb +92 -0
  76. data/modules/firewall/spec/acceptance/nodesets/centos-59-x64.yml +10 -0
  77. data/modules/firewall/spec/acceptance/nodesets/centos-64-x64-fusion.yml +10 -0
  78. data/modules/firewall/spec/acceptance/nodesets/centos-64-x64-pe.yml +12 -0
  79. data/modules/firewall/spec/acceptance/nodesets/centos-64-x64.yml +10 -0
  80. data/modules/firewall/spec/acceptance/nodesets/debian-607-x64.yml +10 -0
  81. data/modules/firewall/spec/acceptance/nodesets/debian-70rc1-x64.yml +10 -0
  82. data/modules/firewall/spec/acceptance/nodesets/default.yml +10 -0
  83. data/modules/firewall/spec/acceptance/nodesets/fedora-18-x64.yml +10 -0
  84. data/modules/firewall/spec/acceptance/nodesets/sles-11sp1-x64.yml +10 -0
  85. data/modules/firewall/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml +10 -0
  86. data/modules/firewall/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml +10 -0
  87. data/modules/firewall/spec/{system → acceptance}/params_spec.rb +44 -52
  88. data/modules/firewall/spec/acceptance/purge_spec.rb +124 -0
  89. data/modules/firewall/spec/acceptance/resource_cmd_spec.rb +93 -0
  90. data/modules/firewall/spec/acceptance/rules_spec.rb +248 -0
  91. data/modules/firewall/spec/acceptance/socket_spec.rb +96 -0
  92. data/modules/firewall/spec/{system → acceptance}/standard_usage_spec.rb +6 -10
  93. data/modules/firewall/spec/fixtures/ip6tables/conversion_hash.rb +107 -0
  94. data/modules/firewall/spec/fixtures/iptables/conversion_hash.rb +56 -2
  95. data/modules/firewall/spec/spec_helper_acceptance.rb +38 -0
  96. data/modules/firewall/spec/unit/classes/firewall_spec.rb +2 -2
  97. data/modules/firewall/spec/unit/facter/iptables_persistent_version_spec.rb +8 -5
  98. data/modules/firewall/spec/unit/facter/iptables_spec.rb +6 -4
  99. data/modules/firewall/spec/unit/puppet/provider/iptables_chain_spec.rb +14 -4
  100. data/modules/firewall/spec/unit/puppet/provider/iptables_spec.rb +246 -5
  101. data/modules/firewall/spec/unit/puppet/type/firewall_spec.rb +99 -8
  102. data/modules/firewall/spec/unit/puppet/type/firewallchain_spec.rb +50 -6
  103. data/modules/firewall/spec/unit/puppet/util/firewall_spec.rb +21 -0
  104. data/modules/mysql/CHANGELOG +0 -30
  105. data/modules/mysql/Gemfile +0 -1
  106. data/modules/mysql/Gemfile.lock +30 -31
  107. data/modules/mysql/Modulefile +1 -1
  108. data/modules/mysql/README.md +2 -49
  109. data/modules/mysql/files/mysqltuner.pl +1 -1
  110. data/modules/mysql/lib/puppet/provider/database/mysql.rb +1 -1
  111. data/modules/mysql/lib/puppet/provider/database_grant/mysql.rb +1 -1
  112. data/modules/mysql/lib/puppet/provider/database_user/mysql.rb +1 -1
  113. data/modules/mysql/lib/puppet/provider/mysql.rb +1 -2
  114. data/modules/mysql/lib/puppet/provider/mysql_database/mysql.rb +13 -2
  115. data/modules/mysql/lib/puppet/provider/mysql_user/mysql.rb +12 -0
  116. data/modules/mysql/lib/puppet/type/database_user.rb +1 -1
  117. data/modules/mysql/lib/puppet/type/mysql_grant.rb +3 -5
  118. data/modules/mysql/manifests/client.pp +0 -7
  119. data/modules/mysql/manifests/server/root_password.pp +0 -2
  120. data/modules/mysql/manifests/server.pp +0 -6
  121. data/modules/mysql/metadata.json +79 -81
  122. data/modules/mysql/spec/classes/mysql_server_spec.rb +0 -74
  123. data/modules/mysql/spec/system/mysql_server_root_password_spec.rb +1 -7
  124. data/modules/mysql/spec/system/mysql_server_spec.rb +3 -6
  125. data/modules/mysql/spec/system/types/mysql_grant_spec.rb +0 -27
  126. data/modules/mysql/spec/unit/puppet/functions/mysql_deepmerge_spec.rb +1 -1
  127. data/modules/mysql/spec/unit/puppet/provider/database/mysql_spec.rb +4 -4
  128. data/modules/mysql/spec/unit/puppet/provider/database_grant/mysql_spec.rb +15 -15
  129. data/modules/mysql/spec/unit/puppet/provider/database_user/mysql_spec.rb +4 -4
  130. data/modules/mysql/spec/unit/puppet/provider/mysql_database/mysql_spec.rb +3 -3
  131. data/modules/mysql/spec/unit/puppet/provider/mysql_user/mysql_spec.rb +3 -3
  132. data/modules/mysql/templates/my.cnf.erb +2 -4
  133. data/modules/mysql/tests/mysql_grant.pp +1 -1
  134. data/modules/postgresql/Changelog +31 -0
  135. data/modules/postgresql/Gemfile +4 -2
  136. data/modules/postgresql/Modulefile +1 -1
  137. data/modules/postgresql/README.md +10 -4
  138. data/modules/postgresql/Rakefile +0 -1
  139. data/modules/postgresql/lib/puppet/provider/postgresql_psql/ruby.rb +25 -3
  140. data/modules/postgresql/manifests/globals.pp +2 -0
  141. data/modules/postgresql/manifests/params.pp +21 -0
  142. data/modules/postgresql/manifests/server/config.pp +0 -5
  143. data/modules/postgresql/manifests/server/config_entry.pp +1 -1
  144. data/modules/postgresql/manifests/server/database.pp +2 -1
  145. data/modules/postgresql/manifests/server/db.pp +2 -0
  146. data/modules/postgresql/manifests/server/grant.pp +20 -16
  147. data/modules/postgresql/manifests/server/initdb.pp +27 -3
  148. data/modules/postgresql/manifests/server/pg_hba_rule.pp +2 -4
  149. data/modules/postgresql/manifests/server/role.pp +8 -2
  150. data/modules/postgresql/manifests/server/service.pp +5 -0
  151. data/modules/postgresql/manifests/server.pp +2 -0
  152. data/modules/postgresql/metadata.json +88 -65
  153. data/modules/postgresql/spec/acceptance/client_spec.rb +18 -0
  154. data/modules/postgresql/spec/{system → acceptance}/common_patterns_spec.rb +8 -14
  155. data/modules/postgresql/spec/{system → acceptance}/contrib_spec.rb +4 -9
  156. data/modules/postgresql/spec/acceptance/lib/devel_spec.rb +17 -0
  157. data/modules/postgresql/spec/acceptance/lib/java_spec.rb +20 -0
  158. data/modules/postgresql/spec/acceptance/lib/python_spec.rb +19 -0
  159. data/modules/postgresql/spec/acceptance/nodesets/centos-510-x64.yml +10 -0
  160. data/modules/postgresql/spec/acceptance/nodesets/centos-59-x64.yml +10 -0
  161. data/modules/postgresql/spec/acceptance/nodesets/centos-64-x64-pe.yml +12 -0
  162. data/modules/postgresql/spec/acceptance/nodesets/centos-64-x64.yml +10 -0
  163. data/modules/postgresql/spec/acceptance/nodesets/debian-607-x64.yml +10 -0
  164. data/modules/postgresql/spec/acceptance/nodesets/debian-73-x64.yml +10 -0
  165. data/modules/postgresql/spec/acceptance/nodesets/default.yml +10 -0
  166. data/modules/postgresql/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml +10 -0
  167. data/modules/postgresql/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml +10 -0
  168. data/modules/postgresql/spec/{system → acceptance}/postgresql_psql_spec.rb +6 -14
  169. data/modules/postgresql/spec/{system → acceptance}/server/config_entry_spec.rb +6 -12
  170. data/modules/postgresql/spec/{system → acceptance}/server/database_grant_spec.rb +6 -12
  171. data/modules/postgresql/spec/{system → acceptance}/server/database_spec.rb +6 -12
  172. data/modules/postgresql/spec/{system → acceptance}/server/db_spec.rb +47 -42
  173. data/modules/postgresql/spec/{system → acceptance}/server/grant_spec.rb +6 -12
  174. data/modules/postgresql/spec/{system → acceptance}/server/pg_hba_rule_spec.rb +10 -23
  175. data/modules/postgresql/spec/{system → acceptance}/server/plperl_spec.rb +6 -10
  176. data/modules/postgresql/spec/{system → acceptance}/server/role_spec.rb +13 -28
  177. data/modules/postgresql/spec/acceptance/server/table_grant_spec.rb +124 -0
  178. data/modules/postgresql/spec/{system → acceptance}/server/tablespace_spec.rb +8 -22
  179. data/modules/postgresql/spec/{system → acceptance}/server_spec.rb +38 -61
  180. data/modules/postgresql/spec/{system → acceptance}/validate_db_connection_spec.rb +8 -20
  181. data/modules/postgresql/spec/spec_helper_acceptance.rb +70 -0
  182. data/modules/postgresql/spec/unit/classes/globals_spec.rb +2 -2
  183. data/modules/postgresql/spec/unit/classes/lib/devel_spec.rb +1 -1
  184. data/modules/postgresql/spec/unit/classes/params_spec.rb +1 -1
  185. data/modules/postgresql/spec/unit/classes/repo_spec.rb +1 -1
  186. data/modules/postgresql/spec/unit/classes/server/initdb_spec.rb +2 -1
  187. data/modules/postgresql/spec/unit/classes/server/plperl_spec.rb +2 -2
  188. data/modules/postgresql/spec/unit/classes/server_spec.rb +9 -2
  189. data/modules/postgresql/spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb +15 -17
  190. data/modules/rbenv/bin/autospec +0 -0
  191. data/modules/rbenv/bin/facter +0 -0
  192. data/modules/rbenv/bin/filebucket +0 -0
  193. data/modules/rbenv/bin/hiera +0 -0
  194. data/modules/rbenv/bin/htmldiff +0 -0
  195. data/modules/rbenv/bin/ldiff +0 -0
  196. data/modules/rbenv/bin/pi +0 -0
  197. data/modules/rbenv/bin/puppet +0 -0
  198. data/modules/rbenv/bin/puppet-lint +0 -0
  199. data/modules/rbenv/bin/puppet-module +0 -0
  200. data/modules/rbenv/bin/puppetca +0 -0
  201. data/modules/rbenv/bin/puppetd +0 -0
  202. data/modules/rbenv/bin/puppetdoc +0 -0
  203. data/modules/rbenv/bin/puppetmasterd +0 -0
  204. data/modules/rbenv/bin/puppetqd +0 -0
  205. data/modules/rbenv/bin/puppetrun +0 -0
  206. data/modules/rbenv/bin/rake +0 -0
  207. data/modules/rbenv/bin/ralsh +0 -0
  208. data/modules/rbenv/bin/rspec +0 -0
  209. data/modules/rbenv/bin/rspec-puppet-init +0 -0
  210. data/modules/stdlib/spec/monkey_patches/alias_should_to_must.rb +0 -0
  211. data/modules/stdlib/spec/monkey_patches/publicize_methods.rb +0 -0
  212. data/modules/stdlib/spec/unit/puppet/parser/functions/abs_spec.rb +0 -0
  213. data/modules/stdlib/spec/unit/puppet/parser/functions/bool2num_spec.rb +0 -0
  214. data/modules/stdlib/spec/unit/puppet/parser/functions/capitalize_spec.rb +0 -0
  215. data/modules/stdlib/spec/unit/puppet/parser/functions/chomp_spec.rb +0 -0
  216. data/modules/stdlib/spec/unit/puppet/parser/functions/chop_spec.rb +0 -0
  217. data/modules/stdlib/spec/unit/puppet/parser/functions/delete_at_spec.rb +0 -0
  218. data/modules/stdlib/spec/unit/puppet/parser/functions/delete_spec.rb +0 -0
  219. data/modules/stdlib/spec/unit/puppet/parser/functions/dirname_spec.rb +0 -0
  220. data/modules/stdlib/spec/unit/puppet/parser/functions/downcase_spec.rb +0 -0
  221. data/modules/stdlib/spec/unit/puppet/parser/functions/empty_spec.rb +0 -0
  222. data/modules/stdlib/spec/unit/puppet/parser/functions/flatten_spec.rb +0 -0
  223. data/modules/stdlib/spec/unit/puppet/parser/functions/grep_spec.rb +0 -0
  224. data/modules/stdlib/spec/unit/puppet/parser/functions/has_interface_with_spec.rb +0 -0
  225. data/modules/stdlib/spec/unit/puppet/parser/functions/has_ip_address_spec.rb +0 -0
  226. data/modules/stdlib/spec/unit/puppet/parser/functions/has_ip_network_spec.rb +0 -0
  227. data/modules/stdlib/spec/unit/puppet/parser/functions/max_spec.rb +0 -0
  228. data/modules/stdlib/spec/unit/puppet/parser/functions/min_spec.rb +0 -0
  229. data/modules/stdlib/spec/unit/puppet/parser/functions/reject_spec.rb +0 -0
  230. data/modules/stdlib/spec/unit/puppet/parser/functions/to_bytes_spec.rb +0 -0
  231. data/modules/stdlib/spec/unit/puppet/parser/functions/validate_slength_spec.rb +0 -0
  232. metadata +92 -77
  233. data/modules/apt/manifests/unattended_upgrades.pp +0 -68
  234. data/modules/apt/spec/classes/unattended_upgrades_spec.rb +0 -204
  235. data/modules/apt/spec/system/apt_builddep_spec.rb +0 -38
  236. data/modules/apt/spec/system/apt_key_spec.rb +0 -53
  237. data/modules/apt/spec/system/apt_ppa_spec.rb +0 -59
  238. data/modules/apt/spec/system/apt_source_spec.rb +0 -51
  239. data/modules/apt/spec/system/basic_spec.rb +0 -10
  240. data/modules/apt/spec/system/class_spec.rb +0 -20
  241. data/modules/apt/templates/10periodic.erb +0 -12
  242. data/modules/apt/templates/50unattended-upgrades.erb +0 -53
  243. data/modules/apt/tests/unattended-upgrades.pp +0 -1
  244. data/modules/concat/README.markdown +0 -150
  245. data/modules/concat/spec/defines/init_spec.rb +0 -115
  246. data/modules/concat/spec/fixtures/manifests/site.pp +0 -0
  247. data/modules/firewall/spec/spec_helper_system.rb +0 -49
  248. data/modules/firewall/spec/system/class_spec.rb +0 -39
  249. data/modules/firewall/spec/system/purge_spec.rb +0 -29
  250. data/modules/firewall/spec/system/resource_cmd_spec.rb +0 -53
  251. data/modules/mysql/manifests/server/providers.pp +0 -8
  252. data/modules/mysql/tests/bindings.pp +0 -3
  253. data/modules/postgresql/Gemfile.lock +0 -74
  254. data/modules/postgresql/spec/spec_helper_system.rb +0 -66
  255. data/modules/postgresql/spec/system/client_spec.rb +0 -22
  256. data/modules/postgresql/spec/system/lib/devel_spec.rb +0 -22
  257. data/modules/postgresql/spec/system/lib/java_spec.rb +0 -25
  258. data/modules/postgresql/spec/system/lib/python_spec.rb +0 -24
  259. data/modules/postgresql/spec/system/server/table_grant_spec.rb +0 -72
@@ -1,52 +1,112 @@
1
+ # == Define: concat::fragment
2
+ #
1
3
  # Puts a file fragment into a directory previous setup using concat
2
4
  #
3
- # OPTIONS:
4
- # - target The file that these fragments belong to
5
- # - content If present puts the content into the file
6
- # - source If content was not specified, use the source
7
- # - order By default all files gets a 10_ prefix in the directory
8
- # you can set it to anything else using this to influence the
9
- # order of the content in the file
10
- # - ensure Present/Absent or destination to a file to include another file
11
- # - mode Mode for the file
12
- # - owner Owner of the file
13
- # - group Owner of the file
14
- # - backup Controls the filebucketing behavior of the final file and
15
- # see File type reference for its use. Defaults to 'puppet'
16
- define concat::fragment($target, $content='', $source='', $order=10, $ensure = 'present', $mode = '0644', $owner = $::id, $group = $concat::setup::root_group, $backup = 'puppet') {
17
- $safe_name = regsubst($name, '/', '_', 'G')
18
- $safe_target_name = regsubst($target, '/', '_', 'G')
19
- $concatdir = $concat::setup::concatdir
20
- $fragdir = "${concatdir}/${safe_target_name}"
21
-
22
- # if content is passed, use that, else if source is passed use that
23
- # if neither passed, but $ensure is in symlink form, make a symlink
24
- case $content {
25
- '': {
26
- case $source {
27
- '': {
28
- case $ensure {
29
- '', 'absent', 'present', 'file', 'directory': {
30
- crit('No content, source or symlink specified')
31
- }
32
- default: {
33
- #do nothing, make puppet-lint happy.
34
- }
35
- }
36
- }
37
- default: { File{ source => $source } }
38
- }
39
- }
40
- default: { File{ content => $content } }
41
- }
42
-
43
- file{"${fragdir}/fragments/${order}_${safe_name}":
44
- ensure => $ensure,
45
- mode => $mode,
46
- owner => $owner,
47
- group => $group,
48
- backup => $backup,
49
- alias => "concat_fragment_${name}",
50
- notify => Exec["concat_${target}"]
5
+ # === Options:
6
+ #
7
+ # [*target*]
8
+ # The file that these fragments belong to
9
+ # [*content*]
10
+ # If present puts the content into the file
11
+ # [*source*]
12
+ # If content was not specified, use the source
13
+ # [*order*]
14
+ # By default all files gets a 10_ prefix in the directory you can set it to
15
+ # anything else using this to influence the order of the content in the file
16
+ # [*ensure*]
17
+ # Present/Absent or destination to a file to include another file
18
+ # [*mode*]
19
+ # Deprecated
20
+ # [*owner*]
21
+ # Deprecated
22
+ # [*group*]
23
+ # Deprecated
24
+ # [*backup*]
25
+ # Deprecated
26
+ #
27
+ define concat::fragment(
28
+ $target,
29
+ $content = undef,
30
+ $source = undef,
31
+ $order = 10,
32
+ $ensure = 'present',
33
+ $mode = undef,
34
+ $owner = undef,
35
+ $group = undef,
36
+ $backup = undef
37
+ ) {
38
+ validate_string($target)
39
+ if ! ($ensure in [ 'present', 'absent' ]) {
40
+ warning('Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated. If you want to use the content of a file as a fragment please use the $source parameter.')
41
+ }
42
+ validate_string($content)
43
+ if !(is_string($source) or is_array($source)) {
44
+ fail('$source is not a string or an Array.')
45
+ }
46
+ validate_string($order)
47
+ if $mode {
48
+ warning('The $mode parameter to concat::fragment is deprecated and has no effect')
49
+ }
50
+ if $owner {
51
+ warning('The $owner parameter to concat::fragment is deprecated and has no effect')
52
+ }
53
+ if $group {
54
+ warning('The $group parameter to concat::fragment is deprecated and has no effect')
55
+ }
56
+ if $backup {
57
+ warning('The $backup parameter to concat::fragment is deprecated and has no effect')
58
+ }
59
+
60
+ include concat::setup
61
+
62
+ $safe_name = regsubst($name, '[/:\n]', '_', 'GM')
63
+ $safe_target_name = regsubst($target, '[/:\n]', '_', 'GM')
64
+ $concatdir = $concat::setup::concatdir
65
+ $fragdir = "${concatdir}/${safe_target_name}"
66
+
67
+ # The file type's semantics are problematic in that ensure => present will
68
+ # not over write a pre-existing symlink. We are attempting to provide
69
+ # backwards compatiblity with previous concat::fragment versions that
70
+ # supported the file type's ensure => /target syntax
71
+
72
+ # be paranoid and only allow the fragment's file resource's ensure param to
73
+ # be file, absent, or a file target
74
+ $safe_ensure = $ensure ? {
75
+ '' => 'file',
76
+ undef => 'file',
77
+ 'file' => 'file',
78
+ 'present' => 'file',
79
+ 'absent' => 'absent',
80
+ default => $ensure,
81
+ }
82
+
83
+ # if it looks line ensure => /target syntax was used, fish that out
84
+ if ! ($ensure in ['', 'present', 'absent', 'file' ]) {
85
+ $ensure_target = $ensure
86
+ }
87
+
88
+ # the file type's semantics only allows one of: ensure => /target, content,
89
+ # or source
90
+ if ($ensure_target and $source) or
91
+ ($ensure_target and $content) or
92
+ ($source and $content) {
93
+ fail('You cannot specify more than one of $content, $source, $ensure => /target')
94
+ }
95
+
96
+ if ! ($content or $source or $ensure_target) {
97
+ crit('No content, source or symlink specified')
98
+ }
99
+
100
+ # punt on group ownership until some point in the distant future when $::gid
101
+ # can be relied on to be present
102
+ file { "${fragdir}/fragments/${order}_${safe_name}":
103
+ ensure => $safe_ensure,
104
+ owner => $::id,
105
+ mode => '0640',
106
+ source => $source,
107
+ content => $content,
108
+ backup => false,
109
+ alias => "concat_fragment_${name}",
110
+ notify => Exec["concat_${target}"]
51
111
  }
52
112
  }
@@ -1,249 +1,230 @@
1
- # A system to construct files using fragments from other files or templates.
1
+ # == Define: concat
2
2
  #
3
- # This requires at least puppet 0.25 to work correctly as we use some
4
- # enhancements in recursive directory management and regular expressions
5
- # to do the work here.
6
- #
7
- # USAGE:
8
- # The basic use case is as below:
9
- #
10
- # concat{"/etc/named.conf":
11
- # notify => Service["named"]
12
- # }
13
- #
14
- # concat::fragment{"foo.com_config":
15
- # target => "/etc/named.conf",
16
- # order => 10,
17
- # content => template("named_conf_zone.erb")
18
- # }
19
- #
20
- # # add a fragment not managed by puppet so local users
21
- # # can add content to managed file
22
- # concat::fragment{"foo.com_user_config":
23
- # target => "/etc/named.conf",
24
- # order => 12,
25
- # ensure => "/etc/named.conf.local"
26
- # }
27
- #
28
- # This will use the template named_conf_zone.erb to build a single
29
- # bit of config up and put it into the fragments dir. The file
30
- # will have an number prefix of 10, you can use the order option
31
- # to control that and thus control the order the final file gets built in.
32
- #
33
- # You can also specify a path and use a different name for your resources:
34
- #
35
- # # You can make this something dynamic, based on whatever parameters your
36
- # # module/class for example.
37
- # $vhost_file = '/etc/httpd/vhosts/01-my-vhost.conf'
38
- #
39
- # concat{'apache-vhost-myvhost':
40
- # path => $vhost_file,
41
- # }
42
- #
43
- # # We don't care where the file is located, just what to put in it.
44
- # concat::fragment {'apache-vhost-myvhost-main':
45
- # target => 'apache-vhost-myvhost',
46
- # content => '<virtualhost *:80>',
47
- # order => 01,
48
- # }
49
- #
50
- # concat::fragment {'apache-vhost-myvhost-close':
51
- # target => 'apache-vhost-myvhost',
52
- # content => '</virtualhost>',
53
- # order => 99,
54
- # }
55
- #
56
- #
57
- # SETUP:
58
- # The class concat::setup uses the fact concat_basedir to define the variable
59
- # $concatdir, where all the temporary files and fragments will be
60
- # durably stored. The fact concat_basedir will be set up on the client to
61
- # <Puppet[:vardir]>/concat, so you will be able to run different setup/flavours
62
- # of puppet clients.
63
- # However, since this requires the file lib/facter/concat_basedir.rb to be
64
- # deployed on the clients, so you will have to set "pluginsync = true" on
65
- # both the master and client, at least for the first run.
66
- #
67
- # There's some regular expression magic to figure out the puppet version but
68
- # if you're on an older 0.24 version just set $puppetversion = 24
69
- #
70
- # DETAIL:
71
- # We use a helper shell script called concatfragments.sh that gets placed
72
- # in <Puppet[:vardir]>/concat/bin to do the concatenation. While this might
73
- # seem more complex than some of the one-liner alternatives you might find on
74
- # the net we do a lot of error checking and safety checks in the script to avoid
75
- # problems that might be caused by complex escaping errors etc.
76
- #
77
- # LICENSE:
78
- # Apache Version 2
79
- #
80
- # LATEST:
81
- # http://github.com/ripienaar/puppet-concat/
82
- #
83
- # CONTACT:
84
- # R.I.Pienaar <rip@devco.net>
85
- # Volcane on freenode
86
- # @ripienaar on twitter
87
- # www.devco.net
88
-
89
-
90
3
  # Sets up so that you can use fragments to build a final config file,
91
4
  #
92
- # OPTIONS:
93
- # - path The path to the final file. Use this in case you want to
94
- # differentiate between the name of a resource and the file path.
95
- # Note: Use the name you provided in the target of your
96
- # fragments.
97
- # - mode The mode of the final file
98
- # - owner Who will own the file
99
- # - group Who will own the file
100
- # - force Enables creating empty files if no fragments are present
101
- # - warn Adds a normal shell style comment top of the file indicating
102
- # that it is built by puppet
103
- # - backup Controls the filebucketing behavior of the final file and
104
- # see File type reference for its use. Defaults to 'puppet'
105
- #
106
- # ACTIONS:
107
- # - Creates fragment directories if it didn't exist already
108
- # - Executes the concatfragments.sh script to build the final file, this
109
- # script will create directory/fragments.concat. Execution happens only
110
- # when:
111
- # * The directory changes
112
- # * fragments.concat != final destination, this means rebuilds will happen
113
- # whenever someone changes or deletes the final file. Checking is done
114
- # using /usr/bin/cmp.
115
- # * The Exec gets notified by something else - like the concat::fragment
116
- # define
117
- # - Copies the file over to the final destination using a file resource
5
+ # === Options:
6
+ #
7
+ # [*ensure*]
8
+ # Present/Absent
9
+ # [*path*]
10
+ # The path to the final file. Use this in case you want to differentiate
11
+ # between the name of a resource and the file path. Note: Use the name you
12
+ # provided in the target of your fragments.
13
+ # [*owner*]
14
+ # Who will own the file
15
+ # [*group*]
16
+ # Who will own the file
17
+ # [*mode*]
18
+ # The mode of the final file
19
+ # [*force*]
20
+ # Enables creating empty files if no fragments are present
21
+ # [*warn*]
22
+ # Adds a normal shell style comment top of the file indicating that it is
23
+ # built by puppet
24
+ # [*force*]
25
+ # [*backup*]
26
+ # Controls the filebucketing behavior of the final file and see File type
27
+ # reference for its use. Defaults to 'puppet'
28
+ # [*replace*]
29
+ # Whether to replace a file that already exists on the local system
30
+ # [*order*]
31
+ # [*ensure_newline*]
32
+ # [*gnu*]
33
+ # Deprecated
34
+ #
35
+ # === Actions:
36
+ # * Creates fragment directories if it didn't exist already
37
+ # * Executes the concatfragments.sh script to build the final file, this
38
+ # script will create directory/fragments.concat. Execution happens only
39
+ # when:
40
+ # * The directory changes
41
+ # * fragments.concat != final destination, this means rebuilds will happen
42
+ # whenever someone changes or deletes the final file. Checking is done
43
+ # using /usr/bin/cmp.
44
+ # * The Exec gets notified by something else - like the concat::fragment
45
+ # define
46
+ # * Copies the file over to the final destination using a file resource
47
+ #
48
+ # === Aliases:
49
+ #
50
+ # * The exec can notified using Exec["concat_/path/to/file"] or
51
+ # Exec["concat_/path/to/directory"]
52
+ # * The final file can be referenced as File["/path/to/file"] or
53
+ # File["concat_/path/to/file"]
118
54
  #
119
- # ALIASES:
120
- # - The exec can notified using Exec["concat_/path/to/file"] or
121
- # Exec["concat_/path/to/directory"]
122
- # - The final file can be referened as File["/path/to/file"] or
123
- # File["concat_/path/to/file"]
124
55
  define concat(
125
- $path = $name,
126
- $owner = $::id,
127
- $group = $concat::setup::root_group,
128
- $mode = '0644',
129
- $warn = false,
130
- $force = false,
131
- $backup = 'puppet',
132
- $gnu = undef,
133
- $order='alpha'
56
+ $ensure = 'present',
57
+ $path = $name,
58
+ $owner = undef,
59
+ $group = undef,
60
+ $mode = '0644',
61
+ $warn = false,
62
+ $force = false,
63
+ $backup = 'puppet',
64
+ $replace = true,
65
+ $order = 'alpha',
66
+ $ensure_newline = false,
67
+ $gnu = undef
134
68
  ) {
69
+ validate_re($ensure, '^present$|^absent$')
70
+ validate_absolute_path($path)
71
+ validate_string($owner)
72
+ validate_string($group)
73
+ validate_string($mode)
74
+ if ! (is_string($warn) or $warn == true or $warn == false) {
75
+ fail('$warn is not a string or boolean')
76
+ }
77
+ validate_bool($force)
78
+ validate_string($backup)
79
+ validate_bool($replace)
80
+ validate_re($order, '^alpha$|^numeric$')
81
+ validate_bool($ensure_newline)
82
+ if $gnu {
83
+ warning('The $gnu parameter to concat is deprecated and has no effect')
84
+ }
85
+
135
86
  include concat::setup
136
87
 
137
- $safe_name = regsubst($name, '/', '_', 'G')
138
- $concatdir = $concat::setup::concatdir
139
- $version = $concat::setup::majorversion
140
- $fragdir = "${concatdir}/${safe_name}"
141
- $concat_name = 'fragments.concat.out'
88
+ $safe_name = regsubst($name, '[/:]', '_', 'G')
89
+ $concatdir = $concat::setup::concatdir
90
+ $fragdir = "${concatdir}/${safe_name}"
91
+ $concat_name = 'fragments.concat.out'
92
+ $script_command = $concat::setup::script_command
142
93
  $default_warn_message = '# This file is managed by Puppet. DO NOT EDIT.'
94
+ $bool_warn_message = 'Using stringified boolean values (\'true\', \'yes\', \'on\', \'false\', \'no\', \'off\') to represent boolean true/false as the $warn parameter to concat is deprecated and will be treated as the warning message in a future release'
143
95
 
144
96
  case $warn {
145
- 'true', true, yes, on: {
146
- $warnmsg = $default_warn_message
97
+ true: {
98
+ $warn_message = $default_warn_message
99
+ }
100
+ 'true', 'yes', 'on': {
101
+ warning($bool_warn_message)
102
+ $warn_message = $default_warn_message
147
103
  }
148
- 'false', false, no, off: {
149
- $warnmsg = ''
104
+ false: {
105
+ $warn_message = ''
106
+ }
107
+ 'false', 'no', 'off': {
108
+ warning($bool_warn_message)
109
+ $warn_message = ''
150
110
  }
151
111
  default: {
152
- $warnmsg = $warn
112
+ $warn_message = $warn
153
113
  }
154
114
  }
155
115
 
156
- $warnmsg_escaped = regsubst($warnmsg, "'", "'\\\\''", 'G')
116
+ $warnmsg_escaped = regsubst($warn_message, '\'', '\'\\\'\'', 'G')
157
117
  $warnflag = $warnmsg_escaped ? {
158
118
  '' => '',
159
119
  default => "-w '${warnmsg_escaped}'"
160
120
  }
161
121
 
162
- case $force {
163
- 'true', true, yes, on: {
164
- $forceflag = '-f'
165
- }
166
- 'false', false, no, off: {
167
- $forceflag = ''
168
- }
169
- default: {
170
- fail("Improper 'force' value given to concat: ${force}")
171
- }
122
+ $forceflag = $force ? {
123
+ true => '-f',
124
+ false => '',
172
125
  }
173
126
 
174
- case $order {
175
- numeric: {
176
- $orderflag = '-n'
177
- }
178
- alpha: {
179
- $orderflag = ''
180
- }
181
- default: {
182
- fail("Improper 'order' value given to concat: ${order}")
183
- }
127
+ $orderflag = $order ? {
128
+ 'numeric' => '-n',
129
+ 'alpha' => '',
184
130
  }
185
131
 
186
- File {
187
- owner => $::id,
188
- group => $group,
189
- mode => $mode,
190
- backup => $backup
132
+ $newlineflag = $ensure_newline ? {
133
+ true => '-l',
134
+ false => '',
191
135
  }
192
136
 
193
- file { $fragdir:
194
- ensure => directory,
137
+ File {
138
+ backup => false,
195
139
  }
196
140
 
197
- $source_real = $version ? {
198
- 24 => 'puppet:///concat/null',
199
- default => undef,
200
- }
141
+ if $ensure == 'present' {
142
+ file { $fragdir:
143
+ ensure => directory,
144
+ mode => '0750',
145
+ }
201
146
 
202
- file { "${fragdir}/fragments":
203
- ensure => directory,
204
- force => true,
205
- ignore => ['.svn', '.git', '.gitignore'],
206
- notify => Exec["concat_${name}"],
207
- purge => true,
208
- recurse => true,
209
- source => $source_real,
210
- }
147
+ file { "${fragdir}/fragments":
148
+ ensure => directory,
149
+ mode => '0750',
150
+ force => true,
151
+ ignore => ['.svn', '.git', '.gitignore'],
152
+ notify => Exec["concat_${name}"],
153
+ purge => true,
154
+ recurse => true,
155
+ }
211
156
 
212
- file { "${fragdir}/fragments.concat":
213
- ensure => present,
214
- }
157
+ file { "${fragdir}/fragments.concat":
158
+ ensure => present,
159
+ mode => '0640',
160
+ }
215
161
 
216
- file { "${fragdir}/${concat_name}":
217
- ensure => present,
218
- }
162
+ file { "${fragdir}/${concat_name}":
163
+ ensure => present,
164
+ mode => '0640',
165
+ }
219
166
 
220
- file { $name:
221
- ensure => present,
222
- path => $path,
223
- alias => "concat_${name}",
224
- group => $group,
225
- mode => $mode,
226
- owner => $owner,
227
- source => "${fragdir}/${concat_name}",
228
- }
167
+ file { $name:
168
+ ensure => present,
169
+ owner => $owner,
170
+ group => $group,
171
+ mode => $mode,
172
+ replace => $replace,
173
+ path => $path,
174
+ alias => "concat_${name}",
175
+ source => "${fragdir}/${concat_name}",
176
+ backup => $backup,
177
+ }
229
178
 
230
- exec { "concat_${name}":
231
- alias => "concat_${fragdir}",
232
- command => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag}",
233
- notify => File[$name],
234
- require => [
235
- File[$fragdir],
236
- File["${fragdir}/fragments"],
237
- File["${fragdir}/fragments.concat"],
238
- ],
239
- subscribe => File[$fragdir],
240
- unless => "${concat::setup::concatdir}/bin/concatfragments.sh -o ${fragdir}/${concat_name} -d ${fragdir} -t ${warnflag} ${forceflag} ${orderflag}",
241
- }
179
+ # remove extra whitespace from string interpolation to make testing easier
180
+ $command = strip(regsubst("${script_command} -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", '\s+', ' ', 'G'))
181
+
182
+ # if puppet is running as root, this exec should also run as root to allow
183
+ # the concatfragments.sh script to potentially be installed in path that
184
+ # may not be accessible by a target non-root owner.
185
+ exec { "concat_${name}":
186
+ alias => "concat_${fragdir}",
187
+ command => $command,
188
+ notify => File[$name],
189
+ subscribe => File[$fragdir],
190
+ unless => "${command} -t",
191
+ path => $::path,
192
+ require => [
193
+ File[$fragdir],
194
+ File["${fragdir}/fragments"],
195
+ File["${fragdir}/fragments.concat"],
196
+ ],
197
+ }
198
+ } else {
199
+ file { [
200
+ $fragdir,
201
+ "${fragdir}/fragments",
202
+ "${fragdir}/fragments.concat",
203
+ "${fragdir}/${concat_name}"
204
+ ]:
205
+ ensure => absent,
206
+ force => true,
207
+ }
208
+
209
+ file { $name:
210
+ ensure => absent,
211
+ backup => $backup,
212
+ }
213
+
214
+ $absent_exec_command = $::kernel ? {
215
+ 'windows' => 'cmd.exe /c exit 0',
216
+ default => 'true',
217
+ }
218
+
219
+ $absent_exec_path = $::kernel ? {
220
+ 'windows' => $::path,
221
+ default => '/bin:/usr/bin',
222
+ }
242
223
 
243
- if $::id == 'root' {
244
- Exec["concat_${name}"] {
245
- user => root,
246
- group => $group,
224
+ exec { "concat_${name}":
225
+ alias => "concat_${fragdir}",
226
+ command => $absent_exec_command,
227
+ path => $absent_exec_path
247
228
  }
248
229
  }
249
230
  }