summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-11-01 00:06:14 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-11-01 00:06:14 +0000
commit14d8186ebe8740eab1b320e6a1d6c98c255ad70f (patch)
treeb98daca4feaf4165e518f62a12bc39a9aec872e6
parent03357432210eecc5f370f812f473bc5d0a062d64 (diff)
downloadpuppet-14d8186ebe8740eab1b320e6a1d6c98c255ad70f.tar.gz
puppet-14d8186ebe8740eab1b320e6a1d6c98c255ad70f.tar.xz
puppet-14d8186ebe8740eab1b320e6a1d6c98c255ad70f.zip
Making paths work a little more intelligently
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@739 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--Rakefile314
-rw-r--r--lib/puppet.rb4
-rw-r--r--lib/puppet/log.rb17
-rw-r--r--lib/puppet/type.rb11
-rw-r--r--lib/puppet/type/component.rb11
-rw-r--r--lib/puppet/type/pfile.rb12
-rwxr-xr-xtest/language/snippets.rb4
7 files changed, 196 insertions, 177 deletions
diff --git a/Rakefile b/Rakefile
index aa6a0ebe4..8523aa080 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,10 +1,10 @@
# Rakefile for Puppet
begin
- require 'rubygems'
- require 'rake/gempackagetask'
+ require 'rubygems'
+ require 'rake/gempackagetask'
rescue Exception
- nil
+ nil
end
require 'rake/clean'
@@ -15,16 +15,16 @@ require 'rake/testtask'
#CLOBBER.include('doc/*')
def announce(msg='')
- STDERR.puts msg
+ STDERR.puts msg
end
# Determine the current version
if `ruby -Ilib ./bin/puppet --version` =~ /\S+$/
- CURRENT_VERSION = $&
+ CURRENT_VERSION = $&
else
- CURRENT_VERSION = "0.0.0"
+ CURRENT_VERSION = "0.0.0"
end
if ENV['REL']
@@ -45,15 +45,15 @@ task :u => :unittests
task :a => :alltests
Rake::TestTask.new(:alltests) do |t|
- t.test_files = FileList['test/tc*.rb']
- t.warning = true
- t.verbose = false
+ t.test_files = FileList['test/tc*.rb']
+ t.warning = true
+ t.verbose = false
end
Rake::TestTask.new(:unittests) do |t|
- t.test_files = FileList['test/test']
- t.warning = true
- t.verbose = false
+ t.test_files = FileList['test/test']
+ t.warning = true
+ t.verbose = false
end
# SVN Tasks ----------------------------------------------------------
@@ -63,7 +63,7 @@ end
desc "Install the application"
task :install do
- ruby "install.rb"
+ ruby "install.rb"
end
# Create a task to build the RDOC documentation tree.
@@ -82,75 +82,75 @@ end
# tar, zip and gem files.
PKG_FILES = FileList[
- 'install.rb',
- '[A-Z]*',
- 'lib/**/*.rb',
- 'test/**/*.rb',
- 'bin/**/*',
- 'examples/**/*'
+ 'install.rb',
+ '[A-Z]*',
+ 'lib/**/*.rb',
+ 'test/**/*.rb',
+ 'bin/**/*',
+ 'examples/**/*'
]
PKG_FILES.delete_if {|item| item.include?(".svn")}
if ! defined?(Gem)
- puts "Package Target requires RubyGEMs"
+ puts "Package Target requires RubyGEMs"
else
- spec = Gem::Specification.new do |s|
-
- #### Basic information.
-
- s.name = 'puppet'
- s.version = PKG_VERSION
- s.summary = "Puppet is a server configuration management tool."
- s.description = <<-EOF
- Puppet is a declarative language for expressing system configuration,
- a client and server for distributing it, and a library for realizing
- the configuration.
- EOF
- s.platform = Gem::Platform::RUBY
-
- #### Dependencies and requirements.
-
- s.add_dependency('facter', '>= 1.0.0')
- #s.requirements << ""
-
- s.files = PKG_FILES.to_a
-
- #### Load-time details: library and application (you will need one or both).
-
- s.require_path = 'lib' # Use these for libraries.
-
- s.bindir = "bin" # Use these for applications.
- s.executables = ["puppet", "puppetd", "puppetmasterd", "puppetdoc",
- "puppetca"]
- s.default_executable = "puppet"
- s.autorequire = 'puppet'
-
- #### Documentation and testing.
-
- s.has_rdoc = false
- #s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
- #s.rdoc_options <<
- # '--title' << 'Puppet - Configuration Management' <<
- # '--main' << 'README' <<
- # '--line-numbers'
- s.test_file = "test/test"
-
- #### Signing key and cert chain
- #s.signing_key = '/..../gem-private_key.pem'
- #s.cert_chain = ['gem-public_cert.pem']
-
- #### Author and project details.
-
- s.author = "Luke Kanies"
- s.email = "dev@reductivelabs.com"
- s.homepage = "http://reductivelabs.com/projects/puppet"
- #s.rubyforge_project = "puppet"
- end
-
- Rake::GemPackageTask.new(spec) do |pkg|
- #pkg.need_zip = true
- pkg.need_tar = true
- end
+ spec = Gem::Specification.new { |s|
+
+ #### Basic information.
+
+ s.name = 'puppet'
+ s.version = PKG_VERSION
+ s.summary = "Puppet is a server configuration management tool."
+ s.description = <<-EOF
+Puppet is a declarative language for expressing system configuration,
+a client and server for distributing it, and a library for realizing
+the configuration.
+ EOF
+ s.platform = Gem::Platform::RUBY
+
+ #### Dependencies and requirements.
+
+ s.add_dependency('facter', '>= 1.0.0')
+ #s.requirements << ""
+
+ s.files = PKG_FILES.to_a
+
+ #### Load-time details: library and application (you will need one or both).
+
+ s.require_path = 'lib' # Use these for libraries.
+
+ s.bindir = "bin" # Use these for applications.
+ s.executables = ["puppet", "puppetd", "puppetmasterd", "puppetdoc",
+ "puppetca"]
+ s.default_executable = "puppet"
+ s.autorequire = 'puppet'
+
+ #### Documentation and testing.
+
+ s.has_rdoc = false
+ #s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
+ #s.rdoc_options <<
+ # '--title' << 'Puppet - Configuration Management' <<
+ # '--main' << 'README' <<
+ # '--line-numbers'
+ s.test_file = "test/test"
+
+ #### Signing key and cert chain
+ #s.signing_key = '/..../gem-private_key.pem'
+ #s.cert_chain = ['gem-public_cert.pem']
+
+ #### Author and project details.
+
+ s.author = "Luke Kanies"
+ s.email = "dev@reductivelabs.com"
+ s.homepage = "http://reductivelabs.com/projects/puppet"
+ #s.rubyforge_project = "puppet"
+ }
+
+ Rake::GemPackageTask.new(spec) { |pkg|
+ #pkg.need_zip = true
+ pkg.need_tar = true
+ }
end
# Misc tasks =========================================================
@@ -169,22 +169,22 @@ end
# Support Tasks ------------------------------------------------------
def egrep(pattern)
- Dir['**/*.rb'].each do |fn|
- count = 0
- open(fn) do |f|
- while line = f.gets
- count += 1
- if line =~ pattern
- puts "#{fn}:#{count}:#{line}"
- end
- end
+ Dir['**/*.rb'].each do |fn|
+ count = 0
+ open(fn) do |f|
+ while line = f.gets
+ count += 1
+ if line =~ pattern
+ puts "#{fn}:#{count}:#{line}"
+ end
+ end
+ end
end
- end
end
desc "Look for TODO and FIXME tags in the code"
task :todo do
- egrep "/#.*(FIXME|TODO|TBD)/"
+ egrep "/#.*(FIXME|TODO|TBD)/"
end
#desc "Look for Debugging print lines"
@@ -203,88 +203,90 @@ end
desc "Make a new release"
task :release => [
- :prerelease,
- :clobber,
- :alltests,
- :update_version,
- :package,
- :tag] do
+ :prerelease,
+ :clobber,
+ :alltests,
+ :update_version,
+ :package,
+ :tag
+ ] do
- announce
- announce "**************************************************************"
- announce "* Release #{PKG_VERSION} Complete."
- announce "* Packages ready to upload."
- announce "**************************************************************"
- announce
+ announce
+ announce "**************************************************************"
+ announce "* Release #{PKG_VERSION} Complete."
+ announce "* Packages ready to upload."
+ announce "**************************************************************"
+ announce
end
# Validate that everything is ready to go for a release.
task :prerelease do
- announce
- announce "**************************************************************"
- announce "* Making RubyGem Release #{PKG_VERSION}"
- announce "* (current version #{CURRENT_VERSION})"
- announce "**************************************************************"
- announce
-
- # Is a release number supplied?
- unless ENV['REL']
- fail "Usage: rake release REL=x.y.z [REUSE=tag_suffix]"
- end
-
- # Is the release different than the current release.
- # (or is REUSE set?)
- if PKG_VERSION == CURRENT_VERSION && ! ENV['REUSE']
- fail "Current version is #{PKG_VERSION}, must specify REUSE=tag_suffix to reuse version"
- end
-
- # Are all source files checked in?
- if ENV['RELTEST']
- announce "Release Task Testing, skipping checked-in file test"
- else
- announce "Checking for unchecked-in files..."
- data = `svn -q update`
- unless data =~ /^$/
- fail "SVN update is not clean ... do you have unchecked-in files?"
+ announce
+ announce "**************************************************************"
+ announce "* Making RubyGem Release #{PKG_VERSION}"
+ announce "* (current version #{CURRENT_VERSION})"
+ announce "**************************************************************"
+ announce
+
+ # Is a release number supplied?
+ unless ENV['REL']
+ fail "Usage: rake release REL=x.y.z [REUSE=tag_suffix]"
end
- announce "No outstanding checkins found ... OK"
- end
-end
-task :update_version => [:prerelease] do
- if PKG_VERSION == CURRENT_VERSION
- announce "No version change ... skipping version update"
- else
- announce "Updating Puppet version to #{PKG_VERSION}"
- open("lib/puppet.rb") do |rakein|
- open("lib/puppet.rb.new", "w") do |rakeout|
- rakein.each do |line|
- if line =~ /^PUPPETVERSION\s*=\s*/
- rakeout.puts "PUPPETVERSION = '#{PKG_VERSION}'"
- else
- rakeout.puts line
- end
- end
- end
+ # Is the release different than the current release.
+ # (or is REUSE set?)
+ if PKG_VERSION == CURRENT_VERSION && ! ENV['REUSE']
+ fail "Current version is #{PKG_VERSION}, must specify REUSE=tag_suffix to reuse version"
end
- mv "lib/puppet.rb.new", "lib/puppet.rb"
+
+ # Are all source files checked in?
if ENV['RELTEST']
- announce "Release Task Testing, skipping commiting of new version"
+ announce "Release Task Testing, skipping checked-in file test"
+ else
+ announce "Checking for unchecked-in files..."
+ data = `svn -q update`
+ unless data =~ /^$/
+ fail "SVN update is not clean ... do you have unchecked-in files?"
+ end
+ announce "No outstanding checkins found ... OK"
+ end
+end
+
+task :update_version => [:prerelease] do
+ if PKG_VERSION == CURRENT_VERSION
+ announce "No version change ... skipping version update"
else
- sh %{svn commit -m "Updated to version #{PKG_VERSION}" lib/puppet.rb}
+ announce "Updating Puppet version to #{PKG_VERSION}"
+ open("lib/puppet.rb") do |rakein|
+ open("lib/puppet.rb.new", "w") do |rakeout|
+ rakein.each do |line|
+ if line =~ /^PUPPETVERSION\s*=\s*/
+ rakeout.puts "PUPPETVERSION = '#{PKG_VERSION}'"
+ else
+ rakeout.puts line
+ end
+ end
+ end
+ end
+
+ mv "lib/puppet.rb.new", "lib/puppet.rb"
+ if ENV['RELTEST']
+ announce "Release Task Testing, skipping commiting of new version"
+ else
+ sh %{svn commit -m "Updated to version #{PKG_VERSION}" lib/puppet.rb}
+ end
end
- end
end
desc "Tag all the SVN files with the latest release number (REL=x.y.z)"
task :tag => [:prerelease] do
- reltag = "REL_#{PKG_VERSION.gsub(/\./, '_')}"
- reltag << ENV['REUSE'].gsub(/\./, '_') if ENV['REUSE']
- announce "Tagging SVN copy with [#{reltag}]"
- if ENV['RELTEST']
- announce "Release Task Testing, skipping SVN tagging"
- else
- #sh %{svn copy ../trunk/ ../tags/#{reltag}}
- end
+ reltag = "REL_#{PKG_VERSION.gsub(/\./, '_')}"
+ reltag << ENV['REUSE'].gsub(/\./, '_') if ENV['REUSE']
+ announce "Tagging SVN copy with [#{reltag}]"
+ if ENV['RELTEST']
+ announce "Release Task Testing, skipping SVN tagging"
+ else
+ #sh %{svn copy ../trunk/ ../tags/#{reltag}}
+ end
end
diff --git a/lib/puppet.rb b/lib/puppet.rb
index 7fe07de3d..b66e00cb8 100644
--- a/lib/puppet.rb
+++ b/lib/puppet.rb
@@ -1,5 +1,3 @@
-#!/usr/local/bin/ruby -w
-
require 'singleton'
require 'puppet/log'
@@ -13,7 +11,7 @@ require 'puppet/log'
#
# it's also a place to find top-level commands like 'debug'
module Puppet
- PUPPETVERSION="0.9.0"
+ PUPPETVERSION="1.0.0"
def Puppet.version
return PUPPETVERSION
diff --git a/lib/puppet/log.rb b/lib/puppet/log.rb
index 7c30e88b5..c470dd5df 100644
--- a/lib/puppet/log.rb
+++ b/lib/puppet/log.rb
@@ -188,6 +188,22 @@ module Puppet # :nodoc:
end
when Puppet::Client::LogClient
unless msg.is_a?(String) or msg.remote
+ unless defined? @hostname
+ @hostname = Facter["hostname"].value
+ end
+ unless defined? @domain
+ @domain = Facter["domain"].value
+ if @domain
+ @hostname += "." + @domain
+ end
+ end
+ if msg.source =~ /^\//
+ msg.source = @hostname + ":" + msg.source
+ elsif msg.source == "Puppet"
+ msg.source = @hostname + " " + msg.source
+ else
+ msg.source = @hostname + " " + msg.source
+ end
begin
#puts "would have sent %s" % msg
#puts "would have sent %s" %
@@ -198,6 +214,7 @@ module Puppet # :nodoc:
puts "Could not dump: %s" % detail.to_s
return
end
+ # Add the hostname to the source
dest.addlog(tmp)
#dest.addlog(msg.to_s)
sleep(0.5)
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 73963d2aa..6ac98359e 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -918,9 +918,16 @@ class Type < Puppet::Element
def path
unless defined? @path
if defined? @parent
- @path = [@parent.path, self.name].flatten.to_s
+ if self.is_a?(Puppet::Type::Component)
+ @path = @parent.path + "/" + self.name
+ else
+ @path = @parent.path + "/" + self.class.name.to_s + "=" + self.name
+ end
else
- @path = self.name.to_s
+ # The top-level name is always puppet[top], so we don't bother with
+ # that. And we don't add the hostname here, it gets added
+ # in the log server thingy.
+ @path = "/"
end
end
diff --git a/lib/puppet/type/component.rb b/lib/puppet/type/component.rb
index c9b97f71f..c3a3440c3 100644
--- a/lib/puppet/type/component.rb
+++ b/lib/puppet/type/component.rb
@@ -90,8 +90,6 @@ module Puppet
# this is only called on one component over the whole system
# this also won't work with scheduling, but eh
def evaluate
- # but what about dependencies?
-
transaction = Puppet::Transaction.new(self.flatten)
transaction.component = self
return transaction
@@ -99,7 +97,14 @@ module Puppet
def name
#return self[:name]
- return "%s[%s]" % [self[:type],self[:name]]
+ unless defined? @name
+ if self[:type] == self[:name]
+ @name = self[:type]
+ else
+ @name = "%s[%s]" % [self[:type],self[:name]]
+ end
+ end
+ return @name
end
def push(*ary)
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index fd9831447..2c1a68a25 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -172,18 +172,6 @@ module Puppet
super
end
- def path
- if defined? @parent
- if @parent.is_a?(self.class)
- return [@parent.path, File.basename(self.name)].flatten.to_s
- else
- return [@parent.path, self.name].flatten.to_s
- end
- else
- return [self.name].to_s
- end
- end
-
def parambackup=(value)
case value
when false, "false":
diff --git a/test/language/snippets.rb b/test/language/snippets.rb
index 3d9808091..a9471ffea 100755
--- a/test/language/snippets.rb
+++ b/test/language/snippets.rb
@@ -221,7 +221,9 @@ class TestSnippets < Test::Unit::TestCase
}
assert_nothing_raised {
- assert_equal(%w{puppet[top] testing[testing] component[componentname] /tmp/classtest}.to_s, obj.path)
+ assert_equal(
+ "//testing/component[componentname]/file=/tmp/classtest",
+ obj.path)
#Puppet.err obj.path
}