Merge branch '0.24.x' of git://github.com/jamtur01/puppet into 0.24.x

This commit is contained in:
Luke Kanies 2008-10-21 19:28:21 +02:00
Родитель fe789798cc 6d05cbc1e1
Коммит b7d72360f6
13 изменённых файлов: 1087 добавлений и 918 удалений

Просмотреть файл

@ -1,4 +1,10 @@
0.24.6
Fixed #1662 - Configuration Reference still references 'section'
Fixed #1460 - enhance redhat puppetmaster init.d script to easy start puppetmaster as a mongrel cluster
Fixed #1663 - Regression relating to facter fact naming from 0.24.5
Fixed #1655 - Provider::Confine::Variable tests are broken
Fixed #1646 - service puppet status does not work as non-root

Просмотреть файл

@ -1,7 +1,8 @@
#!/bin/bash
# puppetmaster This shell script enables the puppetmaster server.
#
# Author: Duane Griffin <d.griffin@psenterprise.com>
# Authors: Duane Griffin <d.griffin@psenterprise.com>
# Peter Meier <peter.meier@immerda.ch> (Mongrel enhancements)
#
# chkconfig: - 65 45
#
@ -22,6 +23,11 @@ fi
PUPPETMASTER_OPTS=""
[ -n "$PUPPETMASTER_MANIFEST" ] && PUPPETMASTER_OPTS="--manifest=${PUPPETMASTER_MANIFEST}"
if [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -gt 1 ]; then
PUPPETMASTER_OPTS="$PUPPETMASTER_OPTS --servertype=mongrel"
elif [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -eq 1 ]; then
PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} --masterport=${PUPPETMASTER_PORTS[0]}"
fi
[ -n "$PUPPETMASTER_LOG" ] && PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} --logdest=${PUPPETMASTER_LOG}"
PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} \
${PUPPETMASTER_EXTRA_OPTS}"
@ -36,8 +42,16 @@ start() {
# Confirm the manifest exists
if [ -r $PUPPETMASTER_MANIFEST ]; then
daemon $PUPPETMASTER $PUPPETMASTER_OPTS
RETVAL=$?
if [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -gt 1 ]; then
for ((i=0; i<${#PUPPETMASTER_PORTS[@]}; i++)); do
echo -en "\nPort: ${PUPPETMASTER_PORTS[$i]}"
daemon $PUPPETMASTER $PUPPETMASTER_OPTS --masterport=${PUPPETMASTER_PORTS[$i]} --pidfile=/var/run/puppet/puppetmaster.${PUPPETMASTER_PORTS[$i]}.pid
ret=$?; [ $ret != 0 ] && RETVAL=$ret
done
else
daemon $PUPPETMASTER $PUPPETMASTER_OPTS
RETVAL=$?
fi
else
failure $"Manifest does not exist: $PUPPETMASTER_MANIFEST"
echo
@ -50,8 +64,16 @@ start() {
stop() {
echo -n $"Stopping puppetmaster: "
killproc $PUPPETMASTER
RETVAL=$?
if [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -gt 1 ]; then
for ((i=0; i<${#PUPPETMASTER_PORTS[@]}; i++)); do
echo -en "\nPort: ${PUPPETMASTER_PORTS[$i]}"
killproc -p /var/run/puppet/puppetmaster.${PUPPETMASTER_PORTS[$i]}.pid puppetmaster
ret=$?; [ $ret != 0 ] && RETVAL=$ret
done
else
killproc $PUPPETMASTER
RETVAL=$?
fi
echo
[ $RETVAL -eq 0 ] && rm -f "$lockfile"
return $RETVAL
@ -67,6 +89,20 @@ genconfig() {
$PUPPETMASTER $PUPPETMASTER_OPTS --genconfig
}
puppetmaster_status() {
if [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -gt 1 ]; then
for ((i=0; i<${#PUPPETMASTER_PORTS[@]}; i++)); do
echo -en "Port ${PUPPETMASTER_PORTS[$i]}: "
status -p /var/run/puppet/puppetmaster.${PUPPETMASTER_PORTS[$i]}.pid puppetmaster
ret=$?; [ $ret != 0 ] && RETVAL=$ret
done
else
status $PUPPETMASTER
RETVAL=$?
fi
return $RETVAL
}
case "$1" in
start)
start
@ -81,8 +117,7 @@ case "$1" in
[ -f "$lockfile" ] && restart
;;
status)
status $PUPPETMASTER
RETVAL=$?
puppetmaster_status
;;
genconfig)
genconfig

Просмотреть файл

@ -5,5 +5,27 @@
# Specify syslog to send log messages to the system log.
#PUPPETMASTER_LOG=syslog
# You may specify an alternate port or an array of ports on which
# puppetmaster should listen. Default is: 8140
# If you specify more than one port, the puppetmaster ist automatically
# started with the servertype set to mongrel. This might be interesting
# if you'd like to run your puppetmaster in a loadbalanced cluster.
# Please note: this won't setup nor start any loadbalancer.
# If you'd like to run puppetmaster with mongrel as servertype but only
# on one (specified) port, you have to add --servertype=mongrel to
# PUPPETMASTER_EXTRA_OPTS.
# Default: Empty (Puppetmaster isn't started with mongrel, nor on a
# specific port)
#
# Please note: Due to reduced options in the rc-functions lib in RHEL/Centos
# versions prior to 5, this feature won't work. Fedora versions >= 8 are
# known to work.
#PUPPETMASTER_PORTS=""
# Puppetmaster on a different port, run with standard webrick servertype
#PUPPETMASTER_PORTS="8141"
# Example with multiple ports which will start puppetmaster with mongrel
# as a servertype
#PUPPETMASTER_PORTS=( 18140 18141 18142 18143 )
# You may specify other parameters to the puppetmaster here
#PUPPETMASTER_EXTRA_OPTS=--noca

Просмотреть файл

@ -79,7 +79,13 @@ fstatement: NAME LPAREN funcvalues RPAREN {
:arguments => args,
:ftype => :statement
}
| NAME LPAREN RPAREN {
| NAME LPAREN funcvalues COMMA RPAREN {
args = aryfy(val[2])
result = ast AST::Function,
:name => val[0],
:arguments => args,
:ftype => :statement
} | NAME LPAREN RPAREN {
result = ast AST::Function,
:name => val[0],
:arguments => AST::ASTArray.new({}),
@ -93,15 +99,22 @@ fstatement: NAME LPAREN funcvalues RPAREN {
:ftype => :statement
}
funcvalues: namestrings
| resourcerefs
namestrings: namestring
| namestrings COMMA namestring {
funcvalues: namestring
| resourceref
| funcvalues COMMA namestring {
result = aryfy(val[0], val[2])
result.line = @lexer.line
result.file = @lexer.file
}
| funcvalues COMMA resourceref {
unless val[0].is_a?(AST::ASTArray)
val[0] = aryfy(val[0])
end
val[0].push(val[2])
result = val[0]
}
# This is *almost* an rvalue, but I couldn't get a full
# rvalue to work without scads of shift/reduce conflicts.
@ -116,17 +129,6 @@ namestring: name
result = ast AST::Name, :value => val[0]
}
resourcerefs: resourceref
| resourcerefs COMMA resourceref {
unless val[0].is_a?(AST::ASTArray)
val[0] = aryfy(val[0])
end
val[0].push(val[2])
result = val[0]
}
resource: classname LBRACE resourceinstances endsemi RBRACE {
array = val[2]
if array.instance_of?(AST::ResourceInstance)
@ -701,6 +703,13 @@ array: LBRACK rvalues RBRACK {
else
result = ast AST::ASTArray, :children => [val[1]]
end
}
| LBRACK rvalues COMMA RBRACK {
if val[1].instance_of?(AST::ASTArray)
result = val[1]
else
result = ast AST::ASTArray, :children => [val[1]]
end
} | LBRACK RBRACK {
result = ast AST::ASTArray
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -42,8 +42,13 @@ class Puppet::Parser::TemplateWrapper
return scope.catalog.classes
end
# Allow templates to access the defined tags
# Allow templates to access the tags defined in the current scope
def tags
return scope.tags
end
# Allow templates to access the all the defined tags
def all_tags
return scope.catalog.tags
end
@ -78,7 +83,8 @@ class Puppet::Parser::TemplateWrapper
# to the regular methods.
benchmark(:debug, "Bound template variables for #{file}") do
scope.to_hash.each { |name, value|
instance_variable_set("@#{name}", value)
realname = name.gsub(/[^\w]/, "_")
instance_variable_set("@#{realname}", value)
}
end

Просмотреть файл

@ -49,10 +49,6 @@ On The Command-Line
+++++++++++++++++++
Every Puppet executable (with the exception of ``puppetdoc``) accepts all of
the parameters below, but not all of the arguments make sense for every executable.
Each parameter has a section listed with it in parentheses; often, that section
will map to an executable (e.g., ``puppetd``), in which case it probably only
makes sense for that one executable. If ``main`` is listed as the section,
it is most likely an option that is valid for everyone.
I have tried to be as thorough as possible in the descriptions of the
arguments, so it should be obvious whether an argument is appropriate or not.
@ -121,9 +117,6 @@ Note that this invocation will replace the contents of any pre-existing
`puppet.conf` file, so make a backup of your present config if it contains
valuable information.
All parameters will be under a single section heading matching the name of
the process used to generate the configuraiton ('puppetd', in this case).
Like the `--genconfig` argument, the executables also accept a `--genmanifest`
argument, which will generate a manifest that can be used to manage all of
Puppet's directories and files and prints it to standard output. This can

Просмотреть файл

@ -142,4 +142,36 @@ describe Puppet::Parser do
end
describe Puppet::Parser, "when parsing function calls" do
it "should not raise errors with no arguments" do
lambda { @parser.parse("tag()") }.should_not raise_error
end
it "should not raise errors with rvalue function with no args" do
lambda { @parser.parse("$a = template()") }.should_not raise_error
end
it "should not raise errors with arguments" do
lambda { @parser.parse("notice(1)") }.should_not raise_error
end
it "should not raise errors with multiple arguments" do
lambda { @parser.parse("notice(1,2)") }.should_not raise_error
end
it "should not raise errors with multiple arguments and a trailing comma" do
lambda { @parser.parse("notice(1,2,)") }.should_not raise_error
end
end
describe Puppet::Parser, "when parsing arrays with trailing comma" do
it "should not raise errors with a trailing comma" do
lambda { @parser.parse("$a = [1,2,]") }.should_not raise_error
end
end
end

Просмотреть файл

@ -62,10 +62,16 @@ describe Puppet::Parser::TemplateWrapper do
tw.classes().should == ["class1", "class2"]
end
it "should allow you to retrieve the defined tags with tags" do
it "should allow you to retrieve all the tags with all_tags" do
catalog = mock 'catalog', :tags => ["tag1", "tag2"]
@scope.expects(:catalog).returns( catalog )
tw = Puppet::Parser::TemplateWrapper.new(@scope, @file)
tw.all_tags().should == ["tag1","tag2"]
end
it "should allow you to retrieve the tags defined in the current scope" do
@scope.expects(:tags).returns( ["tag1", "tag2"] )
tw = Puppet::Parser::TemplateWrapper.new(@scope, @file)
tw.tags().should == ["tag1","tag2"]
end
@ -78,5 +84,18 @@ describe Puppet::Parser::TemplateWrapper do
@tw.result
@tw.instance_variable_get("@one").should == "foo"
end
end
%w{! . ; :}.each do |badchar|
it "should translate #{badchar} to _ when setting the instance variables" do
template_mock = mock("template", :result => "woot!")
File.expects(:read).with("/tmp/fake_template").returns("template contents")
ERB.expects(:new).with("template contents", 0, "-").returns(template_mock)
@scope.expects(:to_hash).returns("one#{badchar}" => "foo")
@tw.result
@tw.instance_variable_get("@one_").should == "foo"
end
end
end

Просмотреть файл

@ -0,0 +1,3 @@
file {
["/tmp/arraytrailingcomma1","/tmp/arraytrailingcomma2", ]: content => "tmp"
}

Просмотреть файл

@ -0,0 +1,5 @@
@file {
["/tmp/funccomma1","/tmp/funccomma2"]: content => "1"
}
realize( File["/tmp/funccomma1"], File["/tmp/funccomma2"] , )

Просмотреть файл

@ -66,6 +66,19 @@ class TestParser < Test::Unit::TestCase
}
end
def test_arrayrvalueswithtrailingcomma
parser = mkparser
ret = nil
file = tempfile()
assert_nothing_raised {
parser.string = "file { \"#{file}\": mode => [755, 640,] }"
}
assert_nothing_raised {
ret = parser.parse
}
end
def mkmanifest(file)
name = File.join(tmpdir, "file%s" % rand(100))
@@tmpfiles << name

Просмотреть файл

@ -446,6 +446,20 @@ class TestSnippets < Test::Unit::TestCase
"Did not make second file from duplicate subclass names")
end
def snippet_funccomma
assert_file("/tmp/funccomma1",
"Did not make first file from trailing function comma")
assert_file("/tmp/funccomma2",
"Did not make second file from trailing function comma")
end
def snippet_arraytrailingcomma
assert_file("/tmp/arraytrailingcomma1",
"Did not make first file from array")
assert_file("/tmp/arraytrailingcomma2",
"Did not make second file from array")
end
# Iterate across each of the snippets and create a test.
Dir.entries(snippetdir).sort.each { |file|
next if file =~ /^\./