puppet 3.6.0.rc1 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/ext/debian/control +1 -1
- data/ext/debian/puppetmaster-passenger.postinst +82 -36
- data/ext/debian/puppetmaster-passenger.postrm +45 -17
- data/lib/puppet/forge.rb +2 -5
- data/lib/puppet/module_tool.rb +23 -0
- data/lib/puppet/module_tool/applications/application.rb +11 -10
- data/lib/puppet/module_tool/applications/builder.rb +5 -5
- data/lib/puppet/module_tool/dependency.rb +1 -0
- data/lib/puppet/module_tool/installed_modules.rb +5 -4
- data/lib/puppet/module_tool/local_tarball.rb +2 -3
- data/lib/puppet/module_tool/tar/gnu.rb +7 -16
- data/lib/puppet/util/execution.rb +4 -6
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/source.rb +1 -1
- data/lib/puppet/version.rb +1 -1
- data/spec/unit/environments_spec.rb +2 -2
- data/spec/unit/module_tool/tar/gnu_spec.rb +5 -7
- data/spec/unit/module_tool_spec.rb +30 -0
- data/spec/unit/util/execution_spec.rb +4 -4
- metadata +12 -22
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 24620c21510d3a912529b5626cf0a1aa5f7ac100
|
4
|
+
data.tar.gz: ee123b144f3df2df256fb7e3516ceb620d4fa551
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d66333da3d4da20ab53f6385727401c80d40e99d7bcfab61f6887f727ffc707f618c1b8953d89b55a6d099f052668248d09a04ac6835dce46df56f2d095b2727
|
7
|
+
data.tar.gz: 5bddfc520f0770ba52db0470b6061854098f2f00e77c395e1e9588fb8ce9a90ba41dba19a095fa4765a9df9d717feeb38e806578ccf792af64079ef188728386
|
data/ext/debian/control
CHANGED
@@ -99,7 +99,7 @@ Description: Centralized configuration management - master startup and compatibi
|
|
99
99
|
|
100
100
|
Package: puppetmaster-passenger
|
101
101
|
Architecture: all
|
102
|
-
Depends: ${misc:Depends}, ruby | ruby-interpreter, puppetmaster-common (= ${source:Version}), facter (>= 1.7.0), lsb-base, libapache2-mod-passenger
|
102
|
+
Depends: ${misc:Depends}, ruby | ruby-interpreter, puppetmaster-common (= ${source:Version}), facter (>= 1.7.0), lsb-base, apache2, libapache2-mod-passenger
|
103
103
|
Conflicts: puppetmaster (<< 2.6.1~rc2-1)
|
104
104
|
Replaces: puppetmaster (<< 2.6.1~rc2-1)
|
105
105
|
Description: Centralised configuration management - master setup to run under mod passenger
|
@@ -2,63 +2,109 @@
|
|
2
2
|
|
3
3
|
set -e
|
4
4
|
|
5
|
+
sitename="puppetmaster"
|
6
|
+
|
7
|
+
# The debian provided a2* utils in Apache 2.4 uses "site name" as
|
8
|
+
# argument, while the version in Apache 2.2 uses "file name".
|
9
|
+
#
|
10
|
+
# For added fun, the Apache 2.4 version requires files to have a
|
11
|
+
# ".conf" suffix, but this must be stripped when using it as argument
|
12
|
+
# for the a2* utilities.
|
13
|
+
#
|
14
|
+
# This will end in tears…
|
15
|
+
# Can be removed when we only support apache >= 2.4
|
16
|
+
apache2_puppetmaster_sitename() {
|
17
|
+
apache2_version="$(dpkg-query --showformat='${Version}\n' --show apache2)"
|
18
|
+
if dpkg --compare-versions "$apache2_version" gt "2.4~"; then
|
19
|
+
echo "${sitename}.conf"
|
20
|
+
else
|
21
|
+
echo "${sitename}"
|
22
|
+
fi
|
23
|
+
}
|
24
|
+
|
25
|
+
# Can be removed when we only support apache >= 2.4
|
26
|
+
restart_apache2() {
|
27
|
+
if [ -x "/etc/init.d/apache2" ]; then
|
28
|
+
# Seems that a restart is needed. reload breaks ssl apparently.
|
29
|
+
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
|
30
|
+
invoke-rc.d apache2 restart || exit $?
|
31
|
+
else
|
32
|
+
/etc/init.d/apache2 restart || exit $?
|
33
|
+
fi
|
34
|
+
fi
|
35
|
+
}
|
36
|
+
|
37
|
+
# We may need to update the passenger directives in the apache vhost because
|
38
|
+
# RailsAutoDetect and RackAutoDetect were removed in passenger 4.0.0
|
39
|
+
# see http://www.modrails.com/documentation/Users%20guide%20Apache.html#_railsautodetect_rackautodetect_and_wsgiautodetect
|
40
|
+
update_vhost_for_passenger4() {
|
41
|
+
# Get passenger version from dpkg.
|
42
|
+
# This will end in tears…
|
43
|
+
passenger_version="$(dpkg-query --showformat='${Version}\n' --show libapache2-mod-passenger)"
|
44
|
+
if dpkg --compare-versions "$passenger_version" gt "4.0~"; then
|
45
|
+
sed -r -i \
|
46
|
+
-e "/RailsAutoDetect/d" \
|
47
|
+
-e "/RackAutoDetect/d" \
|
48
|
+
$tempfile
|
49
|
+
fi
|
50
|
+
}
|
51
|
+
|
5
52
|
if [ "$1" = "configure" ]; then
|
6
|
-
|
53
|
+
|
7
54
|
# Change the owner of the rack config.ru to be the puppet user
|
8
55
|
# because passenger will suid to that user, see #577366
|
9
56
|
if ! dpkg-statoverride --list /usr/share/puppet/rack/puppetmasterd/config.ru >/dev/null 2>&1
|
10
57
|
then
|
11
|
-
|
58
|
+
dpkg-statoverride --update --add puppet puppet 0644 /usr/share/puppet/rack/puppetmasterd/config.ru
|
12
59
|
fi
|
13
60
|
# Setup passenger configuration
|
14
61
|
if [ "$2" = "" ]; then
|
15
|
-
|
62
|
+
|
63
|
+
# Check that puppet master --configprint works properly
|
64
|
+
# If it doesn't the following steps to update the vhost will produce a very unhelpful and broken vhost
|
65
|
+
if [ $(puppet master --configprint all 2>&1 | grep "Could not parse" | wc -l) != "0" ]; then
|
66
|
+
echo "Puppet config print not working properly, exiting"
|
67
|
+
exit 1
|
68
|
+
fi
|
69
|
+
|
70
|
+
# Initialize puppetmaster CA and generate the master certificate
|
16
71
|
# only if the host doesn't already have any puppet ssl certificate.
|
17
72
|
# The ssl key and cert need to be available (eg generated) before
|
18
|
-
# apache2 is configured and started since apache2 ssl configuration
|
73
|
+
# apache2 is configured and started since apache2 ssl configuration
|
19
74
|
# uses the puppetmaster ssl files.
|
20
|
-
|
21
|
-
|
22
|
-
|
75
|
+
if [ ! -e "$(puppet master --configprint hostcert)" ]; then
|
76
|
+
puppet cert generate $(puppet master --configprint certname)
|
77
|
+
fi
|
78
|
+
|
23
79
|
# Setup apache2 configuration files
|
24
|
-
APACHE2_SITE_FILE="/etc/apache2/sites-available
|
80
|
+
APACHE2_SITE_FILE="/etc/apache2/sites-available/$(apache2_puppetmaster_sitename)"
|
25
81
|
if [ ! -e "${APACHE2_SITE_FILE}" ]; then
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
82
|
+
tempfile=$(mktemp)
|
83
|
+
sed -r \
|
84
|
+
-e "s|(SSLCertificateFile\s+).+$|\1$(puppet master --configprint hostcert)|" \
|
85
|
+
-e "s|(SSLCertificateKeyFile\s+).+$|\1$(puppet master --configprint hostprivkey)|" \
|
86
|
+
-e "s|(SSLCACertificateFile\s+).+$|\1$(puppet master --configprint localcacert)|" \
|
87
|
+
-e "s|(SSLCertificateChainFile\s+).+$|\1$(puppet master --configprint localcacert)|" \
|
88
|
+
-e "s|(SSLCARevocationFile\s+).+$|\1$(puppet master --configprint cacrl)|" \
|
89
|
+
-e "s|DocumentRoot /etc/puppet/rack/public|DocumentRoot /usr/share/puppet/rack/puppetmasterd/public|" \
|
90
|
+
-e "s|<Directory /etc/puppet/rack/>|<Directory /usr/share/puppet/rack/puppetmasterd/>|" \
|
91
|
+
/usr/share/puppetmaster-passenger/apache2.site.conf.tmpl > $tempfile
|
92
|
+
update_vhost_for_passenger4
|
93
|
+
mv $tempfile "${APACHE2_SITE_FILE}"
|
37
94
|
fi
|
95
|
+
|
96
|
+
# Enable needed modules
|
38
97
|
a2enmod ssl
|
39
98
|
a2enmod headers
|
40
|
-
a2ensite
|
41
|
-
|
42
|
-
# Seems that a restart is needed. reload breaks ssl apparently.
|
43
|
-
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
|
44
|
-
invoke-rc.d apache2 restart || exit $?
|
45
|
-
else
|
46
|
-
/etc/init.d/apache2 restart || exit $?
|
47
|
-
fi
|
48
|
-
fi
|
99
|
+
a2ensite ${sitename}
|
100
|
+
restart_apache2
|
49
101
|
fi
|
102
|
+
|
50
103
|
# Fix CRL file on upgrade to use the CA crl file instead of the host crl.
|
51
104
|
if dpkg --compare-versions "$2" lt-nl "2.6.1-1"; then
|
52
105
|
if [ -e /etc/apache2/sites-available/puppetmaster ]; then
|
53
106
|
sed -r -i 's|SSLCARevocationFile[[:space:]]+/var/lib/puppet/ssl/crl.pem$|SSLCARevocationFile /var/lib/puppet/ssl/ca/ca_crl.pem|' /etc/apache2/sites-available/puppetmaster
|
54
|
-
|
55
|
-
# Seems that a restart is needed. reload breaks ssl apparently.
|
56
|
-
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
|
57
|
-
invoke-rc.d apache2 restart || exit $?
|
58
|
-
else
|
59
|
-
/etc/init.d/apache2 restart || exit $?
|
60
|
-
fi
|
61
|
-
fi
|
107
|
+
restart_apache2
|
62
108
|
fi
|
63
109
|
fi
|
64
110
|
fi
|
@@ -1,25 +1,53 @@
|
|
1
|
-
#!/bin/sh
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
sitename="puppetmaster"
|
6
|
+
|
7
|
+
# The debian provided a2* utils in Apache 2.4 uses "site name" as
|
8
|
+
# argument, while the version in Apache 2.2 uses "file name".
|
9
|
+
#
|
10
|
+
# For added fun, the Apache 2.4 version requires files to have a
|
11
|
+
# ".conf" suffix, but this must be stripped when using it as argument
|
12
|
+
# for the a2* utilities.
|
13
|
+
#
|
14
|
+
# This will end in tears…
|
15
|
+
# Can be removed when we only support apache >= 2.4
|
16
|
+
apache2_puppetmaster_sitename() {
|
17
|
+
apache2_version="$(dpkg-query --showformat='${Version}\n' --show apache2)"
|
18
|
+
if dpkg --compare-versions "$apache2_version" gt "2.4~"; then
|
19
|
+
echo "${sitename}.conf"
|
20
|
+
else
|
21
|
+
echo "${sitename}"
|
22
|
+
fi
|
23
|
+
}
|
24
|
+
|
25
|
+
# Can be removed when we only support apache >= 2.4
|
26
|
+
restart_apache2() {
|
27
|
+
if [ -x "/etc/init.d/apache2" ]; then
|
28
|
+
# Seems that a restart is needed. reload breaks ssl apparently.
|
29
|
+
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
|
30
|
+
invoke-rc.d apache2 restart || exit $?
|
31
|
+
else
|
32
|
+
/etc/init.d/apache2 restart || exit $?
|
33
|
+
fi
|
34
|
+
fi
|
35
|
+
}
|
2
36
|
|
3
37
|
case "$1" in
|
4
38
|
purge)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
39
|
+
if dpkg-statoverride --list /usr/share/puppet/rack/puppetmasterd/config.ru >/dev/null 2>&1
|
40
|
+
then
|
41
|
+
dpkg-statoverride --remove /usr/share/puppet/rack/puppetmasterd/config.ru
|
42
|
+
fi
|
43
|
+
# Remove the puppetmaster site configuration on purge
|
44
|
+
rm -f /etc/apache2/sites-available/$(apache2_puppetmaster_sitename)
|
45
|
+
;;
|
12
46
|
remove)
|
13
47
|
# Disable the puppetmaster apache2 site configuration on package removal
|
14
|
-
a2dissite
|
15
|
-
|
16
|
-
|
17
|
-
invoke-rc.d apache2 force-reload || exit $?
|
18
|
-
else
|
19
|
-
/etc/init.d/apache2 force-reload || exit $?
|
20
|
-
fi
|
21
|
-
fi
|
22
|
-
;;
|
48
|
+
a2dissite ${sitename}
|
49
|
+
restart_apache2
|
50
|
+
;;
|
23
51
|
upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
|
24
52
|
;;
|
25
53
|
*)
|
data/lib/puppet/forge.rb
CHANGED
@@ -117,14 +117,11 @@ class Puppet::Forge < Semantic::Dependency::Source
|
|
117
117
|
|
118
118
|
name = meta['name'].tr('/', '-')
|
119
119
|
version = Semantic::Version.parse(meta['version'])
|
120
|
+
release = "#{name}@#{version}"
|
120
121
|
|
121
122
|
dependencies = (meta['dependencies'] || [])
|
122
123
|
dependencies.map! do |dep|
|
123
|
-
|
124
|
-
[
|
125
|
-
dep['name'].tr('/', '-'),
|
126
|
-
(Semantic::VersionRange.parse(range) rescue Semantic::VersionRange::EMPTY_RANGE),
|
127
|
-
]
|
124
|
+
Puppet::ModuleTool.parse_module_dependency(release, dep)[0..1]
|
128
125
|
end
|
129
126
|
|
130
127
|
super(source, name, version, Hash[dependencies])
|
data/lib/puppet/module_tool.rb
CHANGED
@@ -154,6 +154,29 @@ module Puppet
|
|
154
154
|
Puppet.lookup(:current_environment)
|
155
155
|
end
|
156
156
|
end
|
157
|
+
|
158
|
+
# Handles parsing of module dependency expressions into proper
|
159
|
+
# {Semantic::VersionRange}s, including reasonable error handling.
|
160
|
+
#
|
161
|
+
# @param where [String] a description of the thing we're parsing the
|
162
|
+
# dependency expression for
|
163
|
+
# @param dep [Hash] the dependency description to parse
|
164
|
+
# @return [Array(String, Semantic::VersionRange, String)] an tuple of the
|
165
|
+
# dependent module's name, the version range dependency, and the
|
166
|
+
# unparsed range expression.
|
167
|
+
def self.parse_module_dependency(where, dep)
|
168
|
+
dep_name = dep['name'].tr('/', '-')
|
169
|
+
range = dep['version_requirement'] || dep['versionRequirement'] || '>= 0.0.0'
|
170
|
+
|
171
|
+
begin
|
172
|
+
parsed_range = Semantic::VersionRange.parse(range)
|
173
|
+
rescue ArgumentError => e
|
174
|
+
Puppet.debug "Error in #{where} parsing dependency #{dep_name} (#{e.message}); using empty range."
|
175
|
+
parsed_range = Semantic::VersionRange::EMPTY_RANGE
|
176
|
+
end
|
177
|
+
|
178
|
+
[ dep_name, parsed_range, range ]
|
179
|
+
end
|
157
180
|
end
|
158
181
|
end
|
159
182
|
|
@@ -43,14 +43,6 @@ module Puppet::ModuleTool
|
|
43
43
|
modulefile_path = File.join(@path, 'Modulefile')
|
44
44
|
metadata_path = File.join(@path, 'metadata.json')
|
45
45
|
|
46
|
-
if File.file?(modulefile_path)
|
47
|
-
if File.file?(metadata_path)
|
48
|
-
Puppet.warning "Modulefile is deprecated. Using metadata.json."
|
49
|
-
else
|
50
|
-
Puppet.warning "Modulefile is deprecated. Building metadata.json from Modulefile."
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
46
|
if File.file?(metadata_path)
|
55
47
|
File.open(metadata_path) do |f|
|
56
48
|
begin
|
@@ -59,11 +51,20 @@ module Puppet::ModuleTool
|
|
59
51
|
raise ArgumentError, "Could not parse JSON #{metadata_path}", ex.backtrace
|
60
52
|
end
|
61
53
|
end
|
54
|
+
end
|
55
|
+
|
56
|
+
if File.file?(modulefile_path)
|
57
|
+
if File.file?(metadata_path)
|
58
|
+
Puppet.warning "Modulefile is deprecated. Merging your Modulefile and metadata.json."
|
59
|
+
else
|
60
|
+
Puppet.warning "Modulefile is deprecated. Building metadata.json from Modulefile."
|
61
|
+
end
|
62
62
|
|
63
|
-
elsif File.file?(modulefile_path)
|
64
63
|
Puppet::ModuleTool::ModulefileReader.evaluate(@metadata, modulefile_path)
|
64
|
+
end
|
65
65
|
|
66
|
-
|
66
|
+
has_metadata = File.file?(modulefile_path) || File.file?(metadata_path)
|
67
|
+
if !has_metadata && require_metadata
|
67
68
|
raise ArgumentError, "No metadata found for module #{@path}"
|
68
69
|
end
|
69
70
|
|
@@ -69,11 +69,11 @@ module Puppet::ModuleTool
|
|
69
69
|
def write_json
|
70
70
|
metadata_path = File.join(build_path, 'metadata.json')
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
72
|
+
# TODO: This may necessarily change the order in which the metadata.json
|
73
|
+
# file is packaged from what was written by the user. This is a
|
74
|
+
# regretable, but required for now.
|
75
|
+
File.open(metadata_path, 'w') do |f|
|
76
|
+
f.write(metadata.to_json)
|
77
77
|
end
|
78
78
|
|
79
79
|
File.open(File.join(build_path, 'checksums.json'), 'w') do |f|
|
@@ -59,17 +59,18 @@ module Puppet::ModuleTool
|
|
59
59
|
@metadata = mod.metadata
|
60
60
|
name = mod.forge_name.tr('/', '-')
|
61
61
|
version = Semantic::Version.parse(mod.version)
|
62
|
+
release = "#{name}@#{version}"
|
62
63
|
|
63
64
|
super(source, name, version, {})
|
64
65
|
|
65
66
|
if mod.dependencies
|
66
67
|
mod.dependencies.each do |dep|
|
67
|
-
|
68
|
-
|
68
|
+
results = Puppet::ModuleTool.parse_module_dependency(release, dep)
|
69
|
+
dep_name, parsed_range, range = results
|
69
70
|
|
70
71
|
dep.tap do |dep|
|
71
|
-
add_constraint('initialize',
|
72
|
-
|
72
|
+
add_constraint('initialize', dep_name, range.to_s) do |node|
|
73
|
+
parsed_range === node.version
|
73
74
|
end
|
74
75
|
end
|
75
76
|
end
|
@@ -48,12 +48,11 @@ module Puppet::ModuleTool
|
|
48
48
|
@metadata = mod.metadata
|
49
49
|
name = mod.forge_name.tr('/', '-')
|
50
50
|
version = Semantic::Version.parse(mod.version)
|
51
|
+
release = "#{name}@#{version}"
|
51
52
|
|
52
53
|
if mod.dependencies
|
53
54
|
dependencies = mod.dependencies.map do |dep|
|
54
|
-
|
55
|
-
range = Semantic::VersionRange.parse(range) rescue Semantic::VersionRange::EMPTY_RANGE
|
56
|
-
[ dep['name'].tr('/', '-'), range ]
|
55
|
+
Puppet::ModuleTool.parse_module_dependency(release, dep)[0..1]
|
57
56
|
end
|
58
57
|
dependencies = Hash[dependencies]
|
59
58
|
end
|
@@ -1,28 +1,19 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
|
1
3
|
class Puppet::ModuleTool::Tar::Gnu
|
2
4
|
def unpack(sourcefile, destdir, owner)
|
3
5
|
sourcefile = File.expand_path(sourcefile)
|
4
6
|
destdir = File.expand_path(destdir)
|
5
7
|
|
6
8
|
Dir.chdir(destdir) do
|
7
|
-
|
8
|
-
Puppet::Util::Execution.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
Puppet::Util::Execution.execute(['find', destdir] + %w[-type d -exec chmod 755 {} +])
|
13
|
-
Puppet::Util::Execution.execute(['find', destdir] + %w[-type f -exec chmod a-wst {} +])
|
14
|
-
Puppet::Util::Execution.execute(['chown', '-R', owner, destdir])
|
9
|
+
Puppet::Util::Execution.execute("gzip -dc #{Shellwords.shellescape(sourcefile)} | tar xof -")
|
10
|
+
Puppet::Util::Execution.execute("find . -type d -exec chmod 755 {} +")
|
11
|
+
Puppet::Util::Execution.execute("find . -type f -exec chmod a-wst {} +")
|
12
|
+
Puppet::Util::Execution.execute("chown -R #{owner} .")
|
15
13
|
end
|
16
14
|
end
|
17
15
|
|
18
16
|
def pack(sourcedir, destfile)
|
19
|
-
|
20
|
-
Puppet::Util::Execution.execpipe(['gzip', '-c'], true, 'w+') do |pipe|
|
21
|
-
pipe.write(tarball)
|
22
|
-
pipe.close_write
|
23
|
-
File.open(destfile, 'w+') do |file|
|
24
|
-
file.write(pipe.read)
|
25
|
-
end
|
26
|
-
end
|
17
|
+
Puppet::Util::Execution.execute("tar cf - #{sourcedir} | gzip -c > #{File.basename(destfile)}")
|
27
18
|
end
|
28
19
|
end
|
@@ -33,9 +33,8 @@ module Puppet::Util::Execution
|
|
33
33
|
# which is treated as a set of command arguments to pass through.
|
34
34
|
#
|
35
35
|
# In either case, the command is passed directly to the shell, STDOUT and
|
36
|
-
# STDERR are connected together, and STDOUT
|
37
|
-
#
|
38
|
-
# not been opened in read or write mode respectively will block indefinitely.)
|
36
|
+
# STDERR are connected together, and STDOUT will be streamed to the yielded
|
37
|
+
# pipe.
|
39
38
|
#
|
40
39
|
# @param command [String, Array<String>] the command to execute as one string,
|
41
40
|
# or as parts in an array. The parts of the array are joined with one
|
@@ -43,7 +42,6 @@ module Puppet::Util::Execution
|
|
43
42
|
# string to execute.
|
44
43
|
# @param failonfail [Boolean] (true) if the execution should fail with
|
45
44
|
# Exception on failure or not.
|
46
|
-
# @param mode [String] ('r') the mode to open the pipe with
|
47
45
|
# @yield [pipe] to a block executing a subprocess
|
48
46
|
# @yieldparam pipe [IO] the opened pipe
|
49
47
|
# @yieldreturn [String] the output to return
|
@@ -54,7 +52,7 @@ module Puppet::Util::Execution
|
|
54
52
|
#
|
55
53
|
# @see Kernel#open for `mode` values
|
56
54
|
# @api public
|
57
|
-
def self.execpipe(command, failonfail = true
|
55
|
+
def self.execpipe(command, failonfail = true)
|
58
56
|
# Paste together an array with spaces. We used to paste directly
|
59
57
|
# together, no spaces, which made for odd invocations; the user had to
|
60
58
|
# include whitespace between arguments.
|
@@ -76,7 +74,7 @@ module Puppet::Util::Execution
|
|
76
74
|
# a predictable output
|
77
75
|
english_env = ENV.to_hash.merge( {'LANG' => 'C', 'LC_ALL' => 'C'} )
|
78
76
|
output = Puppet::Util.withenv(english_env) do
|
79
|
-
open("| #{command_str} 2>&1"
|
77
|
+
open("| #{command_str} 2>&1") do |pipe|
|
80
78
|
yield pipe
|
81
79
|
end
|
82
80
|
end
|
@@ -14,7 +14,7 @@ module Semantic
|
|
14
14
|
def create_release(name, version, dependencies = {})
|
15
15
|
version = Version.parse(version) if version.is_a? String
|
16
16
|
dependencies = dependencies.inject({}) do |hash, (key, value)|
|
17
|
-
hash[key] = VersionRange.parse(value || '>= 0')
|
17
|
+
hash[key] = VersionRange.parse(value || '>= 0.0.0')
|
18
18
|
hash[key] ||= VersionRange::EMPTY_RANGE
|
19
19
|
hash
|
20
20
|
end
|
data/lib/puppet/version.rb
CHANGED
@@ -198,7 +198,7 @@ config_version=/some/script
|
|
198
198
|
with_config_version(File.expand_path('/some/script'))
|
199
199
|
end
|
200
200
|
|
201
|
-
expect(@logs.map(&:to_s).join).to match(/Invalid.*at
|
201
|
+
expect(@logs.map(&:to_s).join).to match(/Invalid.*at.*\/env1.*may not have sections.*ignored: 'foo'/)
|
202
202
|
end
|
203
203
|
|
204
204
|
it "logs a warning, but processes the main settings if there are any extraneous settings" do
|
@@ -214,7 +214,7 @@ config_version=/some/script
|
|
214
214
|
with_config_version(File.expand_path('/some/script'))
|
215
215
|
end
|
216
216
|
|
217
|
-
expect(@logs.map(&:to_s).join).to match(/Invalid.*at
|
217
|
+
expect(@logs.map(&:to_s).join).to match(/Invalid.*at.*\/env1.*unknown setting.*dog, cat/)
|
218
218
|
end
|
219
219
|
|
220
220
|
it "interpretes relative paths from the environment's directory" do
|
@@ -9,17 +9,15 @@ describe Puppet::ModuleTool::Tar::Gnu do
|
|
9
9
|
|
10
10
|
it "unpacks a tar file" do
|
11
11
|
Dir.expects(:chdir).with(File.expand_path(destdir)).yields(mock)
|
12
|
-
Puppet::Util::Execution.expects(:execute).with(
|
13
|
-
Puppet::Util::Execution.expects(:
|
14
|
-
Puppet::Util::Execution.expects(:execute).with(
|
15
|
-
Puppet::Util::Execution.expects(:execute).with(
|
16
|
-
Puppet::Util::Execution.expects(:execute).with(["chown", "-R", "<owner:group>", File.expand_path(destdir)])
|
12
|
+
Puppet::Util::Execution.expects(:execute).with("gzip -dc #{Shellwords.shellescape(File.expand_path(sourcefile))} | tar xof -")
|
13
|
+
Puppet::Util::Execution.expects(:execute).with("find . -type d -exec chmod 755 {} +")
|
14
|
+
Puppet::Util::Execution.expects(:execute).with("find . -type f -exec chmod a-wst {} +")
|
15
|
+
Puppet::Util::Execution.expects(:execute).with("chown -R <owner:group> .")
|
17
16
|
subject.unpack(sourcefile, destdir, '<owner:group>')
|
18
17
|
end
|
19
18
|
|
20
19
|
it "packs a tar file" do
|
21
|
-
Puppet::Util::Execution.expects(:execute).with(
|
22
|
-
Puppet::Util::Execution.expects(:execpipe).with(["gzip", "-c"], true, 'w+')
|
20
|
+
Puppet::Util::Execution.expects(:execute).with("tar cf - #{sourcedir} | gzip -c > #{File.basename(destfile)}")
|
23
21
|
subject.pack(sourcedir, destfile)
|
24
22
|
end
|
25
23
|
end
|
@@ -297,4 +297,34 @@ TREE
|
|
297
297
|
end
|
298
298
|
end
|
299
299
|
end
|
300
|
+
|
301
|
+
describe '.parse_module_dependency' do
|
302
|
+
it 'parses a dependency without a version range expression' do
|
303
|
+
name, range, expr = subject.parse_module_dependency('source', 'name' => 'foo-bar')
|
304
|
+
expect(name).to eql('foo-bar')
|
305
|
+
expect(range).to eql(Semantic::VersionRange.parse('>= 0.0.0'))
|
306
|
+
expect(expr).to eql('>= 0.0.0')
|
307
|
+
end
|
308
|
+
|
309
|
+
it 'parses a dependency with a version range expression' do
|
310
|
+
name, range, expr = subject.parse_module_dependency('source', 'name' => 'foo-bar', 'version_requirement' => '1.2.x')
|
311
|
+
expect(name).to eql('foo-bar')
|
312
|
+
expect(range).to eql(Semantic::VersionRange.parse('1.2.x'))
|
313
|
+
expect(expr).to eql('1.2.x')
|
314
|
+
end
|
315
|
+
|
316
|
+
it 'parses a dependency with a version range expression in the (deprecated) versionRange key' do
|
317
|
+
name, range, expr = subject.parse_module_dependency('source', 'name' => 'foo-bar', 'versionRequirement' => '1.2.x')
|
318
|
+
expect(name).to eql('foo-bar')
|
319
|
+
expect(range).to eql(Semantic::VersionRange.parse('1.2.x'))
|
320
|
+
expect(expr).to eql('1.2.x')
|
321
|
+
end
|
322
|
+
|
323
|
+
it 'does not raise an error on invalid version range expressions' do
|
324
|
+
name, range, expr = subject.parse_module_dependency('source', 'name' => 'foo-bar', 'version_requirement' => 'nope')
|
325
|
+
expect(name).to eql('foo-bar')
|
326
|
+
expect(range).to eql(Semantic::VersionRange::EMPTY_RANGE)
|
327
|
+
expect(expr).to eql('nope')
|
328
|
+
end
|
329
|
+
end
|
300
330
|
end
|
@@ -596,27 +596,27 @@ describe Puppet::Util::Execution do
|
|
596
596
|
|
597
597
|
describe "#execpipe" do
|
598
598
|
it "should execute a string as a string" do
|
599
|
-
Puppet::Util::Execution.expects(:open).with('| echo hello 2>&1'
|
599
|
+
Puppet::Util::Execution.expects(:open).with('| echo hello 2>&1').returns('hello')
|
600
600
|
$CHILD_STATUS.expects(:==).with(0).returns(true)
|
601
601
|
Puppet::Util::Execution.execpipe('echo hello').should == 'hello'
|
602
602
|
end
|
603
603
|
|
604
604
|
it "should print meaningful debug message for string argument" do
|
605
605
|
Puppet::Util::Execution.expects(:debug).with("Executing 'echo hello'")
|
606
|
-
Puppet::Util::Execution.expects(:open).with('| echo hello 2>&1'
|
606
|
+
Puppet::Util::Execution.expects(:open).with('| echo hello 2>&1').returns('hello')
|
607
607
|
$CHILD_STATUS.expects(:==).with(0).returns(true)
|
608
608
|
Puppet::Util::Execution.execpipe('echo hello')
|
609
609
|
end
|
610
610
|
|
611
611
|
it "should print meaningful debug message for array argument" do
|
612
612
|
Puppet::Util::Execution.expects(:debug).with("Executing 'echo hello'")
|
613
|
-
Puppet::Util::Execution.expects(:open).with('| echo hello 2>&1'
|
613
|
+
Puppet::Util::Execution.expects(:open).with('| echo hello 2>&1').returns('hello')
|
614
614
|
$CHILD_STATUS.expects(:==).with(0).returns(true)
|
615
615
|
Puppet::Util::Execution.execpipe(['echo','hello'])
|
616
616
|
end
|
617
617
|
|
618
618
|
it "should execute an array by pasting together with spaces" do
|
619
|
-
Puppet::Util::Execution.expects(:open).with('| echo hello 2>&1'
|
619
|
+
Puppet::Util::Execution.expects(:open).with('| echo hello 2>&1').returns('hello')
|
620
620
|
$CHILD_STATUS.expects(:==).with(0).returns(true)
|
621
621
|
Puppet::Util::Execution.execpipe(['echo', 'hello']).should == 'hello'
|
622
622
|
end
|
metadata
CHANGED
@@ -1,22 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.6.0
|
5
|
-
prerelease: 6
|
4
|
+
version: 3.6.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Puppet Labs
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-14 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: facter
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>'
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '1.6'
|
22
20
|
- - <
|
@@ -25,9 +23,8 @@ dependencies:
|
|
25
23
|
type: :runtime
|
26
24
|
prerelease: false
|
27
25
|
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
26
|
requirements:
|
30
|
-
- -
|
27
|
+
- - '>'
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: '1.6'
|
33
30
|
- - <
|
@@ -36,7 +33,6 @@ dependencies:
|
|
36
33
|
- !ruby/object:Gem::Dependency
|
37
34
|
name: hiera
|
38
35
|
requirement: !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
36
|
requirements:
|
41
37
|
- - ~>
|
42
38
|
- !ruby/object:Gem::Version
|
@@ -44,7 +40,6 @@ dependencies:
|
|
44
40
|
type: :runtime
|
45
41
|
prerelease: false
|
46
42
|
version_requirements: !ruby/object:Gem::Requirement
|
47
|
-
none: false
|
48
43
|
requirements:
|
49
44
|
- - ~>
|
50
45
|
- !ruby/object:Gem::Version
|
@@ -52,7 +47,6 @@ dependencies:
|
|
52
47
|
- !ruby/object:Gem::Dependency
|
53
48
|
name: rgen
|
54
49
|
requirement: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
50
|
requirements:
|
57
51
|
- - ~>
|
58
52
|
- !ruby/object:Gem::Version
|
@@ -60,7 +54,6 @@ dependencies:
|
|
60
54
|
type: :runtime
|
61
55
|
prerelease: false
|
62
56
|
version_requirements: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
57
|
requirements:
|
65
58
|
- - ~>
|
66
59
|
- !ruby/object:Gem::Version
|
@@ -68,17 +61,15 @@ dependencies:
|
|
68
61
|
- !ruby/object:Gem::Dependency
|
69
62
|
name: json_pure
|
70
63
|
requirement: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
64
|
requirements:
|
73
|
-
- -
|
65
|
+
- - '>='
|
74
66
|
- !ruby/object:Gem::Version
|
75
67
|
version: '0'
|
76
68
|
type: :runtime
|
77
69
|
prerelease: false
|
78
70
|
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
71
|
requirements:
|
81
|
-
- -
|
72
|
+
- - '>='
|
82
73
|
- !ruby/object:Gem::Version
|
83
74
|
version: '0'
|
84
75
|
description: Puppet, an automated configuration management tool
|
@@ -2356,6 +2347,7 @@ files:
|
|
2356
2347
|
- spec/watchr.rb
|
2357
2348
|
homepage: https://github.com/puppetlabs/puppet
|
2358
2349
|
licenses: []
|
2350
|
+
metadata: {}
|
2359
2351
|
post_install_message:
|
2360
2352
|
rdoc_options:
|
2361
2353
|
- --title
|
@@ -2366,22 +2358,20 @@ rdoc_options:
|
|
2366
2358
|
require_paths:
|
2367
2359
|
- lib
|
2368
2360
|
required_ruby_version: !ruby/object:Gem::Requirement
|
2369
|
-
none: false
|
2370
2361
|
requirements:
|
2371
|
-
- -
|
2362
|
+
- - '>='
|
2372
2363
|
- !ruby/object:Gem::Version
|
2373
2364
|
version: '0'
|
2374
2365
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
2375
|
-
none: false
|
2376
2366
|
requirements:
|
2377
|
-
- -
|
2367
|
+
- - '>='
|
2378
2368
|
- !ruby/object:Gem::Version
|
2379
|
-
version:
|
2369
|
+
version: '0'
|
2380
2370
|
requirements: []
|
2381
2371
|
rubyforge_project: puppet
|
2382
|
-
rubygems_version:
|
2372
|
+
rubygems_version: 2.0.3
|
2383
2373
|
signing_key:
|
2384
|
-
specification_version:
|
2374
|
+
specification_version: 4
|
2385
2375
|
summary: Puppet, an automated configuration management tool
|
2386
2376
|
test_files:
|
2387
2377
|
- spec/fixtures/faulty_face/puppet/face/syntax.rb
|