freighthop 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Puppetfile +1 -1
- data/Puppetfile.lock +4 -5
- data/README.md +18 -7
- data/Vagrantfile +4 -0
- data/lib/freighthop/cli/help.rb +1 -0
- data/lib/freighthop/cli/init.rb +10 -10
- data/lib/freighthop/cli/version.rb +17 -0
- data/lib/freighthop/cli.rb +3 -1
- data/lib/freighthop/version.rb +1 -1
- data/lib/freighthop.rb +4 -0
- data/modules/apt/CHANGELOG +2 -36
- data/modules/apt/Gemfile +5 -6
- data/modules/apt/Gemfile.lock +7 -40
- data/modules/apt/Modulefile +1 -1
- data/modules/apt/README.md +1 -2
- data/modules/apt/Rakefile +0 -1
- data/modules/apt/manifests/init.pp +2 -5
- data/modules/apt/manifests/params.pp +1 -4
- data/modules/apt/manifests/pin.pp +1 -1
- data/modules/apt/manifests/ppa.pp +10 -24
- data/modules/apt/manifests/update.pp +0 -1
- data/modules/apt/metadata.json +19 -32
- data/modules/apt/spec/defines/ppa_spec.rb +2 -53
- data/modules/apt/spec/defines/source_spec.rb +2 -2
- data/modules/apt/templates/source.list.erb +2 -2
- data/modules/apt/tests/key.pp +3 -3
- data/modules/concat/CHANGELOG +73 -0
- data/modules/concat/Gemfile +20 -0
- data/modules/concat/Gemfile.lock +104 -0
- data/modules/concat/Modulefile +7 -6
- data/modules/concat/README.md +440 -0
- data/modules/concat/Rakefile +5 -1
- data/modules/concat/files/concatfragments.rb +137 -0
- data/modules/concat/files/concatfragments.sh +15 -4
- data/modules/concat/lib/facter/concat_basedir.rb +9 -3
- data/modules/concat/manifests/fragment.pp +108 -48
- data/modules/concat/manifests/init.pp +191 -210
- data/modules/concat/manifests/setup.pp +31 -31
- data/modules/concat/metadata.json +40 -21
- data/modules/{apt → concat}/spec/spec_helper_system.rb +11 -6
- data/modules/{firewall → concat}/spec/system/basic_spec.rb +1 -1
- data/modules/concat/spec/system/concat_spec.rb +154 -0
- data/modules/concat/spec/system/deprecation_warnings_spec.rb +247 -0
- data/modules/concat/spec/system/empty_spec.rb +27 -0
- data/modules/concat/spec/system/fragment_source_spec.rb +142 -0
- data/modules/concat/spec/system/replace_spec.rb +257 -0
- data/modules/concat/spec/system/symbolic_name_spec.rb +35 -0
- data/modules/concat/spec/system/warn_spec.rb +106 -0
- data/modules/concat/spec/unit/classes/concat_setup_spec.rb +42 -0
- data/modules/concat/spec/unit/defines/concat_fragment_spec.rb +267 -0
- data/modules/concat/spec/unit/defines/concat_spec.rb +380 -0
- data/modules/concat/spec/unit/facts/concat_basedir_spec.rb +18 -0
- data/modules/concat/tests/fragment.pp +19 -0
- data/modules/concat/tests/init.pp +7 -0
- data/modules/firewall/Changelog +38 -0
- data/modules/firewall/Gemfile +5 -2
- data/modules/firewall/Gemfile.lock +76 -26
- data/modules/firewall/Modulefile +1 -1
- data/modules/firewall/README.markdown +47 -15
- data/modules/firewall/Rakefile +0 -7
- data/modules/firewall/lib/puppet/provider/firewall/ip6tables.rb +50 -7
- data/modules/firewall/lib/puppet/provider/firewall/iptables.rb +147 -31
- data/modules/firewall/lib/puppet/provider/firewallchain/iptables_chain.rb +19 -8
- data/modules/firewall/lib/puppet/type/firewall.rb +207 -3
- data/modules/firewall/lib/puppet/type/firewallchain.rb +73 -2
- data/modules/firewall/lib/puppet/util/firewall.rb +14 -0
- data/modules/firewall/metadata.json +181 -76
- data/modules/firewall/spec/acceptance/basic_spec.rb +8 -0
- data/modules/firewall/spec/acceptance/change_source_spec.rb +77 -0
- data/modules/firewall/spec/acceptance/class_spec.rb +27 -0
- data/modules/firewall/spec/acceptance/firewall_spec.rb +1608 -0
- data/modules/firewall/spec/acceptance/firewallchain_spec.rb +125 -0
- data/modules/firewall/spec/acceptance/ip6_fragment_spec.rb +94 -0
- data/modules/firewall/spec/acceptance/isfragment_spec.rb +92 -0
- data/modules/firewall/spec/acceptance/nodesets/centos-59-x64.yml +10 -0
- data/modules/firewall/spec/acceptance/nodesets/centos-64-x64-fusion.yml +10 -0
- data/modules/firewall/spec/acceptance/nodesets/centos-64-x64-pe.yml +12 -0
- data/modules/firewall/spec/acceptance/nodesets/centos-64-x64.yml +10 -0
- data/modules/firewall/spec/acceptance/nodesets/debian-607-x64.yml +10 -0
- data/modules/firewall/spec/acceptance/nodesets/debian-70rc1-x64.yml +10 -0
- data/modules/firewall/spec/acceptance/nodesets/default.yml +10 -0
- data/modules/firewall/spec/acceptance/nodesets/fedora-18-x64.yml +10 -0
- data/modules/firewall/spec/acceptance/nodesets/sles-11sp1-x64.yml +10 -0
- data/modules/firewall/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml +10 -0
- data/modules/firewall/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml +10 -0
- data/modules/firewall/spec/{system → acceptance}/params_spec.rb +44 -52
- data/modules/firewall/spec/acceptance/purge_spec.rb +124 -0
- data/modules/firewall/spec/acceptance/resource_cmd_spec.rb +93 -0
- data/modules/firewall/spec/acceptance/rules_spec.rb +248 -0
- data/modules/firewall/spec/acceptance/socket_spec.rb +96 -0
- data/modules/firewall/spec/{system → acceptance}/standard_usage_spec.rb +6 -10
- data/modules/firewall/spec/fixtures/ip6tables/conversion_hash.rb +107 -0
- data/modules/firewall/spec/fixtures/iptables/conversion_hash.rb +56 -2
- data/modules/firewall/spec/spec_helper_acceptance.rb +38 -0
- data/modules/firewall/spec/unit/classes/firewall_spec.rb +2 -2
- data/modules/firewall/spec/unit/facter/iptables_persistent_version_spec.rb +8 -5
- data/modules/firewall/spec/unit/facter/iptables_spec.rb +6 -4
- data/modules/firewall/spec/unit/puppet/provider/iptables_chain_spec.rb +14 -4
- data/modules/firewall/spec/unit/puppet/provider/iptables_spec.rb +246 -5
- data/modules/firewall/spec/unit/puppet/type/firewall_spec.rb +99 -8
- data/modules/firewall/spec/unit/puppet/type/firewallchain_spec.rb +50 -6
- data/modules/firewall/spec/unit/puppet/util/firewall_spec.rb +21 -0
- data/modules/mysql/CHANGELOG +0 -30
- data/modules/mysql/Gemfile +0 -1
- data/modules/mysql/Gemfile.lock +30 -31
- data/modules/mysql/Modulefile +1 -1
- data/modules/mysql/README.md +2 -49
- data/modules/mysql/files/mysqltuner.pl +1 -1
- data/modules/mysql/lib/puppet/provider/database/mysql.rb +1 -1
- data/modules/mysql/lib/puppet/provider/database_grant/mysql.rb +1 -1
- data/modules/mysql/lib/puppet/provider/database_user/mysql.rb +1 -1
- data/modules/mysql/lib/puppet/provider/mysql.rb +1 -2
- data/modules/mysql/lib/puppet/provider/mysql_database/mysql.rb +13 -2
- data/modules/mysql/lib/puppet/provider/mysql_user/mysql.rb +12 -0
- data/modules/mysql/lib/puppet/type/database_user.rb +1 -1
- data/modules/mysql/lib/puppet/type/mysql_grant.rb +3 -5
- data/modules/mysql/manifests/client.pp +0 -7
- data/modules/mysql/manifests/server/root_password.pp +0 -2
- data/modules/mysql/manifests/server.pp +0 -6
- data/modules/mysql/metadata.json +79 -81
- data/modules/mysql/spec/classes/mysql_server_spec.rb +0 -74
- data/modules/mysql/spec/system/mysql_server_root_password_spec.rb +1 -7
- data/modules/mysql/spec/system/mysql_server_spec.rb +3 -6
- data/modules/mysql/spec/system/types/mysql_grant_spec.rb +0 -27
- data/modules/mysql/spec/unit/puppet/functions/mysql_deepmerge_spec.rb +1 -1
- data/modules/mysql/spec/unit/puppet/provider/database/mysql_spec.rb +4 -4
- data/modules/mysql/spec/unit/puppet/provider/database_grant/mysql_spec.rb +15 -15
- data/modules/mysql/spec/unit/puppet/provider/database_user/mysql_spec.rb +4 -4
- data/modules/mysql/spec/unit/puppet/provider/mysql_database/mysql_spec.rb +3 -3
- data/modules/mysql/spec/unit/puppet/provider/mysql_user/mysql_spec.rb +3 -3
- data/modules/mysql/templates/my.cnf.erb +2 -4
- data/modules/mysql/tests/mysql_grant.pp +1 -1
- data/modules/postgresql/Changelog +31 -0
- data/modules/postgresql/Gemfile +4 -2
- data/modules/postgresql/Modulefile +1 -1
- data/modules/postgresql/README.md +10 -4
- data/modules/postgresql/Rakefile +0 -1
- data/modules/postgresql/lib/puppet/provider/postgresql_psql/ruby.rb +25 -3
- data/modules/postgresql/manifests/globals.pp +2 -0
- data/modules/postgresql/manifests/params.pp +21 -0
- data/modules/postgresql/manifests/server/config.pp +0 -5
- data/modules/postgresql/manifests/server/config_entry.pp +1 -1
- data/modules/postgresql/manifests/server/database.pp +2 -1
- data/modules/postgresql/manifests/server/db.pp +2 -0
- data/modules/postgresql/manifests/server/grant.pp +20 -16
- data/modules/postgresql/manifests/server/initdb.pp +27 -3
- data/modules/postgresql/manifests/server/pg_hba_rule.pp +2 -4
- data/modules/postgresql/manifests/server/role.pp +8 -2
- data/modules/postgresql/manifests/server/service.pp +5 -0
- data/modules/postgresql/manifests/server.pp +2 -0
- data/modules/postgresql/metadata.json +88 -65
- data/modules/postgresql/spec/acceptance/client_spec.rb +18 -0
- data/modules/postgresql/spec/{system → acceptance}/common_patterns_spec.rb +8 -14
- data/modules/postgresql/spec/{system → acceptance}/contrib_spec.rb +4 -9
- data/modules/postgresql/spec/acceptance/lib/devel_spec.rb +17 -0
- data/modules/postgresql/spec/acceptance/lib/java_spec.rb +20 -0
- data/modules/postgresql/spec/acceptance/lib/python_spec.rb +19 -0
- data/modules/postgresql/spec/acceptance/nodesets/centos-510-x64.yml +10 -0
- data/modules/postgresql/spec/acceptance/nodesets/centos-59-x64.yml +10 -0
- data/modules/postgresql/spec/acceptance/nodesets/centos-64-x64-pe.yml +12 -0
- data/modules/postgresql/spec/acceptance/nodesets/centos-64-x64.yml +10 -0
- data/modules/postgresql/spec/acceptance/nodesets/debian-607-x64.yml +10 -0
- data/modules/postgresql/spec/acceptance/nodesets/debian-73-x64.yml +10 -0
- data/modules/postgresql/spec/acceptance/nodesets/default.yml +10 -0
- data/modules/postgresql/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml +10 -0
- data/modules/postgresql/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml +10 -0
- data/modules/postgresql/spec/{system → acceptance}/postgresql_psql_spec.rb +6 -14
- data/modules/postgresql/spec/{system → acceptance}/server/config_entry_spec.rb +6 -12
- data/modules/postgresql/spec/{system → acceptance}/server/database_grant_spec.rb +6 -12
- data/modules/postgresql/spec/{system → acceptance}/server/database_spec.rb +6 -12
- data/modules/postgresql/spec/{system → acceptance}/server/db_spec.rb +47 -42
- data/modules/postgresql/spec/{system → acceptance}/server/grant_spec.rb +6 -12
- data/modules/postgresql/spec/{system → acceptance}/server/pg_hba_rule_spec.rb +10 -23
- data/modules/postgresql/spec/{system → acceptance}/server/plperl_spec.rb +6 -10
- data/modules/postgresql/spec/{system → acceptance}/server/role_spec.rb +13 -28
- data/modules/postgresql/spec/acceptance/server/table_grant_spec.rb +124 -0
- data/modules/postgresql/spec/{system → acceptance}/server/tablespace_spec.rb +8 -22
- data/modules/postgresql/spec/{system → acceptance}/server_spec.rb +38 -61
- data/modules/postgresql/spec/{system → acceptance}/validate_db_connection_spec.rb +8 -20
- data/modules/postgresql/spec/spec_helper_acceptance.rb +70 -0
- data/modules/postgresql/spec/unit/classes/globals_spec.rb +2 -2
- data/modules/postgresql/spec/unit/classes/lib/devel_spec.rb +1 -1
- data/modules/postgresql/spec/unit/classes/params_spec.rb +1 -1
- data/modules/postgresql/spec/unit/classes/repo_spec.rb +1 -1
- data/modules/postgresql/spec/unit/classes/server/initdb_spec.rb +2 -1
- data/modules/postgresql/spec/unit/classes/server/plperl_spec.rb +2 -2
- data/modules/postgresql/spec/unit/classes/server_spec.rb +9 -2
- data/modules/postgresql/spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb +15 -17
- data/modules/rbenv/bin/autospec +0 -0
- data/modules/rbenv/bin/facter +0 -0
- data/modules/rbenv/bin/filebucket +0 -0
- data/modules/rbenv/bin/hiera +0 -0
- data/modules/rbenv/bin/htmldiff +0 -0
- data/modules/rbenv/bin/ldiff +0 -0
- data/modules/rbenv/bin/pi +0 -0
- data/modules/rbenv/bin/puppet +0 -0
- data/modules/rbenv/bin/puppet-lint +0 -0
- data/modules/rbenv/bin/puppet-module +0 -0
- data/modules/rbenv/bin/puppetca +0 -0
- data/modules/rbenv/bin/puppetd +0 -0
- data/modules/rbenv/bin/puppetdoc +0 -0
- data/modules/rbenv/bin/puppetmasterd +0 -0
- data/modules/rbenv/bin/puppetqd +0 -0
- data/modules/rbenv/bin/puppetrun +0 -0
- data/modules/rbenv/bin/rake +0 -0
- data/modules/rbenv/bin/ralsh +0 -0
- data/modules/rbenv/bin/rspec +0 -0
- data/modules/rbenv/bin/rspec-puppet-init +0 -0
- data/modules/stdlib/spec/monkey_patches/alias_should_to_must.rb +0 -0
- data/modules/stdlib/spec/monkey_patches/publicize_methods.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/abs_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/bool2num_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/capitalize_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/chomp_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/chop_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/delete_at_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/delete_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/dirname_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/downcase_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/empty_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/flatten_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/grep_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/has_interface_with_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/has_ip_address_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/has_ip_network_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/max_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/min_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/reject_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/to_bytes_spec.rb +0 -0
- data/modules/stdlib/spec/unit/puppet/parser/functions/validate_slength_spec.rb +0 -0
- metadata +92 -77
- data/modules/apt/manifests/unattended_upgrades.pp +0 -68
- data/modules/apt/spec/classes/unattended_upgrades_spec.rb +0 -204
- data/modules/apt/spec/system/apt_builddep_spec.rb +0 -38
- data/modules/apt/spec/system/apt_key_spec.rb +0 -53
- data/modules/apt/spec/system/apt_ppa_spec.rb +0 -59
- data/modules/apt/spec/system/apt_source_spec.rb +0 -51
- data/modules/apt/spec/system/basic_spec.rb +0 -10
- data/modules/apt/spec/system/class_spec.rb +0 -20
- data/modules/apt/templates/10periodic.erb +0 -12
- data/modules/apt/templates/50unattended-upgrades.erb +0 -53
- data/modules/apt/tests/unattended-upgrades.pp +0 -1
- data/modules/concat/README.markdown +0 -150
- data/modules/concat/spec/defines/init_spec.rb +0 -115
- data/modules/concat/spec/fixtures/manifests/site.pp +0 -0
- data/modules/firewall/spec/spec_helper_system.rb +0 -49
- data/modules/firewall/spec/system/class_spec.rb +0 -39
- data/modules/firewall/spec/system/purge_spec.rb +0 -29
- data/modules/firewall/spec/system/resource_cmd_spec.rb +0 -53
- data/modules/mysql/manifests/server/providers.pp +0 -8
- data/modules/mysql/tests/bindings.pp +0 -3
- data/modules/postgresql/Gemfile.lock +0 -74
- data/modules/postgresql/spec/spec_helper_system.rb +0 -66
- data/modules/postgresql/spec/system/client_spec.rb +0 -22
- data/modules/postgresql/spec/system/lib/devel_spec.rb +0 -22
- data/modules/postgresql/spec/system/lib/java_spec.rb +0 -25
- data/modules/postgresql/spec/system/lib/python_spec.rb +0 -24
- 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
|
-
#
|
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
|
-
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
$
|
126
|
-
$
|
127
|
-
$
|
128
|
-
$
|
129
|
-
$
|
130
|
-
$
|
131
|
-
$
|
132
|
-
$
|
133
|
-
$
|
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
|
138
|
-
$concatdir
|
139
|
-
$
|
140
|
-
$
|
141
|
-
$
|
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
|
-
|
146
|
-
$
|
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
|
-
|
149
|
-
$
|
104
|
+
false: {
|
105
|
+
$warn_message = ''
|
106
|
+
}
|
107
|
+
'false', 'no', 'off': {
|
108
|
+
warning($bool_warn_message)
|
109
|
+
$warn_message = ''
|
150
110
|
}
|
151
111
|
default: {
|
152
|
-
$
|
112
|
+
$warn_message = $warn
|
153
113
|
}
|
154
114
|
}
|
155
115
|
|
156
|
-
$warnmsg_escaped = regsubst($
|
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
|
-
|
163
|
-
|
164
|
-
|
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
|
-
|
175
|
-
numeric
|
176
|
-
|
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
|
-
|
187
|
-
|
188
|
-
|
189
|
-
mode => $mode,
|
190
|
-
backup => $backup
|
132
|
+
$newlineflag = $ensure_newline ? {
|
133
|
+
true => '-l',
|
134
|
+
false => '',
|
191
135
|
}
|
192
136
|
|
193
|
-
|
194
|
-
|
137
|
+
File {
|
138
|
+
backup => false,
|
195
139
|
}
|
196
140
|
|
197
|
-
$
|
198
|
-
|
199
|
-
|
200
|
-
|
141
|
+
if $ensure == 'present' {
|
142
|
+
file { $fragdir:
|
143
|
+
ensure => directory,
|
144
|
+
mode => '0750',
|
145
|
+
}
|
201
146
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
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
|
-
|
213
|
-
|
214
|
-
|
157
|
+
file { "${fragdir}/fragments.concat":
|
158
|
+
ensure => present,
|
159
|
+
mode => '0640',
|
160
|
+
}
|
215
161
|
|
216
|
-
|
217
|
-
|
218
|
-
|
162
|
+
file { "${fragdir}/${concat_name}":
|
163
|
+
ensure => present,
|
164
|
+
mode => '0640',
|
165
|
+
}
|
219
166
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
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
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
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
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
224
|
+
exec { "concat_${name}":
|
225
|
+
alias => "concat_${fragdir}",
|
226
|
+
command => $absent_exec_command,
|
227
|
+
path => $absent_exec_path
|
247
228
|
}
|
248
229
|
}
|
249
230
|
}
|