summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBlake Barnett <bdb@bdb-debvm1.stanford.edu>2008-02-28 22:54:12 -0800
committerBlake Barnett <bdb@bdb-debvm1.stanford.edu>2008-02-28 22:54:12 -0800
commit5d3dd9e718cbe69b2fe7f37bc3ec422c88a1080b (patch)
tree787bf2a1a6833a2d7e1f5ae9f9d4e4dfdeb91139 /lib
parent0139889be92add151e624710261ef6f8c0048586 (diff)
parent65b72676aef2d58314f546eb31780d1b9925b9b3 (diff)
downloadpuppet-5d3dd9e718cbe69b2fe7f37bc3ec422c88a1080b.tar.gz
puppet-5d3dd9e718cbe69b2fe7f37bc3ec422c88a1080b.tar.xz
puppet-5d3dd9e718cbe69b2fe7f37bc3ec422c88a1080b.zip
Merge branch '0.24.x' of git://reductivelabs.com/puppet into 0.24.x
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet.rb1
-rw-r--r--lib/puppet/defaults.rb7
-rw-r--r--lib/puppet/file_serving/file_base.rb1
-rw-r--r--lib/puppet/network.rb3
-rw-r--r--lib/puppet/network/client.rb2
-rw-r--r--lib/puppet/network/client/master.rb11
-rw-r--r--lib/puppet/parser/ast/astarray.rb24
-rw-r--r--lib/puppet/parser/compiler.rb5
-rw-r--r--lib/puppet/parser/interpreter.rb6
-rw-r--r--lib/puppet/parser/resource.rb7
-rw-r--r--lib/puppet/provider/interface/redhat.rb130
-rw-r--r--lib/puppet/provider/package/yumhelper.py14
-rwxr-xr-xlib/puppet/type/exec.rb5
-rw-r--r--lib/puppet/type/service.rb9
14 files changed, 118 insertions, 107 deletions
diff --git a/lib/puppet.rb b/lib/puppet.rb
index 18037cdc1..57f84d5f7 100644
--- a/lib/puppet.rb
+++ b/lib/puppet.rb
@@ -423,6 +423,7 @@ module Puppet
end
require 'puppet/type'
+require 'puppet/network'
require 'puppet/module'
require 'puppet/util/storage'
require 'puppet/parser/interpreter'
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index 520a18d1a..77792172f 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -140,8 +140,6 @@ module Puppet
:show_diff => [false, "Whether to print a contextual diff when files are being replaced. The diff
is printed on stdout, so this option is meaningless unless you are running Puppet interactively.
This feature currently requires the ``diff/lcs`` Ruby library."],
- :yamldir => {:default => "$vardir/yaml", :owner => "$user", :group => "$user", :mode => "750",
- :desc => "The directory in which YAML data is stored, usually in a subdirectory."},
:daemonize => { :default => true,
:desc => "Send the process into the background. This is the default.",
:short => "D"
@@ -672,5 +670,10 @@ module Puppet
:rrdinterval => ["$runinterval", "How often RRD should expect data.
This should match how often the hosts report back to the server."]
)
+
+ Puppet.setdefaults(:yaml,
+ :yamldir => {:default => "$vardir/yaml", :owner => "$user", :group => "$user", :mode => "750",
+ :desc => "The directory in which YAML data is stored, usually in a subdirectory."}
+ )
end
diff --git a/lib/puppet/file_serving/file_base.rb b/lib/puppet/file_serving/file_base.rb
index 06b3ad9ef..e87d683aa 100644
--- a/lib/puppet/file_serving/file_base.rb
+++ b/lib/puppet/file_serving/file_base.rb
@@ -46,6 +46,7 @@ class Puppet::FileServing::FileBase
# Determine how we deal with links.
attr_reader :links
def links=(value)
+ value = :manage if value == :ignore
raise(ArgumentError, ":links can only be set to :manage or :follow") unless [:manage, :follow].include?(value)
@links = value
end
diff --git a/lib/puppet/network.rb b/lib/puppet/network.rb
new file mode 100644
index 000000000..8993b8869
--- /dev/null
+++ b/lib/puppet/network.rb
@@ -0,0 +1,3 @@
+# Just a stub, so we can correctly scope other classes.
+module Puppet::Network # :nodoc:
+end
diff --git a/lib/puppet/network/client.rb b/lib/puppet/network/client.rb
index 0a0a72345..cf1782f79 100644
--- a/lib/puppet/network/client.rb
+++ b/lib/puppet/network/client.rb
@@ -7,6 +7,8 @@ require 'puppet/util/subclass_loader'
require 'puppet/util/methodhelper'
require 'puppet/sslcertificates/support'
+require 'puppet/network/handler'
+
require 'net/http'
# Some versions of ruby don't have this method defined, which basically causes
diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb
index 390f3d4e2..913c51b3d 100644
--- a/lib/puppet/network/client/master.rb
+++ b/lib/puppet/network/client/master.rb
@@ -26,14 +26,15 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
down = Puppet[:downcasefacts]
- facts = {}
- Facter.each { |name,fact|
+ facts = Facter.to_hash.inject({}) do |newhash, array|
+ name, fact = array
if down
- facts[name] = fact.to_s.downcase
+ newhash[name] = fact.to_s.downcase
else
- facts[name] = fact.to_s
+ newhash[name] = fact.to_s
end
- }
+ newhash
+ end
# Add our client version to the list of facts, so people can use it
# in their manifests
diff --git a/lib/puppet/parser/ast/astarray.rb b/lib/puppet/parser/ast/astarray.rb
index b66fd6bba..8f09aa922 100644
--- a/lib/puppet/parser/ast/astarray.rb
+++ b/lib/puppet/parser/ast/astarray.rb
@@ -16,16 +16,6 @@ class Puppet::Parser::AST
# Evaluate our children.
def evaluate(scope)
- rets = nil
- # We basically always operate declaratively, and when we
- # do we need to evaluate the settor-like statements first. This
- # is basically variable and type-default declarations.
- # This is such a stupid hack. I've no real idea how to make a
- # "real" declarative language, so I hack it so it looks like
- # one, yay.
- settors = []
- others = []
-
# Make a new array, so we don't have to deal with the details of
# flattening and such
items = []
@@ -34,22 +24,14 @@ class Puppet::Parser::AST
@children.each { |child|
if child.instance_of?(AST::ASTArray)
child.each do |ac|
- if ac.class.settor?
- settors << ac
- else
- others << ac
- end
+ items << ac
end
else
- if child.class.settor?
- settors << child
- else
- others << child
- end
+ items << child
end
}
- rets = [settors, others].flatten.collect { |child|
+ rets = items.flatten.collect { |child|
child.safeevaluate(scope)
}
return rets.reject { |o| o.nil? }
diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb
index 132ec15db..70cd6e11a 100644
--- a/lib/puppet/parser/compiler.rb
+++ b/lib/puppet/parser/compiler.rb
@@ -366,9 +366,8 @@ class Puppet::Parser::Compiler
# Make sure all of our resources and such have done any last work
# necessary.
def finish
- @catalog.resources.each do |name|
- resource = @catalog.resource(name)
-
+ #@catalog.resources.each do |name|
+ @catalog.vertices.each do |resource|
# Add in any resource overrides.
if overrides = resource_overrides(resource)
overrides.each do |over|
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
index d4655c403..f27c1c5c8 100644
--- a/lib/puppet/parser/interpreter.rb
+++ b/lib/puppet/parser/interpreter.rb
@@ -61,7 +61,11 @@ class Puppet::Parser::Interpreter
# If a parser already exists, than assume that we logged the
# exception elsewhere and reuse the parser. If one doesn't
# exist, then reraise.
- raise detail unless @parsers[environment]
+ if @parsers[environment]
+ Puppet.err detail
+ else
+ raise detail
+ end
end
end
@parsers[environment]
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index 46be89ca2..b001e165b 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -82,12 +82,19 @@ class Puppet::Parser::Resource
# Do any finishing work on this object, called before evaluation or
# before storage/translation.
def finish
+ return if finished?
+ @finished = true
add_defaults()
add_metaparams()
add_scope_tags()
validate()
end
+ # Has this resource already been finished?
+ def finished?
+ defined?(@finished) and @finished
+ end
+
def initialize(options)
# Set all of the options we can.
options.each do |option, value|
diff --git a/lib/puppet/provider/interface/redhat.rb b/lib/puppet/provider/interface/redhat.rb
index aa217620e..4a9fcb491 100644
--- a/lib/puppet/provider/interface/redhat.rb
+++ b/lib/puppet/provider/interface/redhat.rb
@@ -5,7 +5,7 @@ Puppet::Type.type(:interface).provide(:redhat) do
desc "Manage network interfaces on Red Hat operating systems. This provider
parses and generates configuration files in ``/etc/sysconfig/network-scripts``."
- INTERFACE_DIR = "/etc/sysconfig/network-scripts"
+ INTERFACE_DIR = "/etc/sysconfig/network-scripts"
confine :exists => INTERFACE_DIR
defaultfor :operatingsystem => [:fedora, :centos, :redhat]
@@ -43,52 +43,52 @@ NETMASK=<%= self.netmask %>
BROADCAST=
LOOPBACKDUMMY
- # maximum number of dummy interfaces
- @max_dummies = 10
+ # maximum number of dummy interfaces
+ @max_dummies = 10
- # maximum number of aliases per interface
- @max_aliases_per_iface = 10
+ # maximum number of aliases per interface
+ @max_aliases_per_iface = 10
- @@dummies = []
- @@aliases = Hash.new { |hash, key| hash[key] = [] }
+ @@dummies = []
+ @@aliases = Hash.new { |hash, key| hash[key] = [] }
- # calculate which dummy interfaces are currently already in
- # use prior to needing to call self.next_dummy later on.
- def self.instances
- # parse all of the config files at once
- Dir.glob("%s/ifcfg-*" % INTERFACE_DIR).collect do |file|
- record = parse(file)
+ # calculate which dummy interfaces are currently already in
+ # use prior to needing to call self.next_dummy later on.
+ def self.instances
+ # parse all of the config files at once
+ Dir.glob("%s/ifcfg-*" % INTERFACE_DIR).collect do |file|
+ record = parse(file)
- # store the existing dummy interfaces
+ # store the existing dummy interfaces
@@dummies << record[:ifnum] if (record[:interface_type] == :dummy and ! @@dummies.include?(record[:ifnum]))
@@aliases[record[:interface]] << record[:ifnum] if record[:interface_type] == :alias
new(record)
- end
- end
-
- # return the next avaliable dummy interface number, in the case where
- # ifnum is not manually specified
- def self.next_dummy
- @max_dummies.times do |i|
- unless @@dummies.include?(i.to_s)
- @@dummies << i.to_s
- return i.to_s
- end
- end
- end
-
- # return the next available alias on a given interface, in the case
- # where ifnum if not manually specified
- def self.next_alias(interface)
- @max_aliases_per_iface.times do |i|
- unless @@aliases[interface].include?(i.to_s)
- @@aliases[interface] << i.to_s
- return i.to_s
- end
- end
- end
+ end
+ end
+
+ # return the next avaliable dummy interface number, in the case where
+ # ifnum is not manually specified
+ def self.next_dummy
+ @max_dummies.times do |i|
+ unless @@dummies.include?(i.to_s)
+ @@dummies << i.to_s
+ return i.to_s
+ end
+ end
+ end
+
+ # return the next available alias on a given interface, in the case
+ # where ifnum if not manually specified
+ def self.next_alias(interface)
+ @max_aliases_per_iface.times do |i|
+ unless @@aliases[interface].include?(i.to_s)
+ @@aliases[interface] << i.to_s
+ return i.to_s
+ end
+ end
+ end
# base the ifnum, for dummy / loopback interface in linux
# on the last octect of the IP address
@@ -139,14 +139,14 @@ LOOPBACKDUMMY
# on whether we are adding an alias to a real interface, or a loopback
# address (also dummy) on linux. For linux it's quite involved, and we
# will use an ERB template
- def generate
+ def generate
itype = self.interface_type == :alias ? :alias : :normal
self.class.template(itype).result(binding)
- end
+ end
# Where should the file be written out?
- # This defaults to INTERFACE_DIR/ifcfg-<namevar>, but can have a
- # more symbolic name by setting interface_desc in the type.
+ # This defaults to INTERFACE_DIR/ifcfg-<namevar>, but can have a
+ # more symbolic name by setting interface_desc in the type.
def file_path
if resource and val = resource[:interface_desc]
desc = val
@@ -185,16 +185,16 @@ LOOPBACKDUMMY
end
end
- # create the device name, so this based on the IP, and interface + type
- def device
- case @resource.should(:interface_type)
- when :loopback
- @property_hash[:ifnum] ||= self.class.next_dummy
- return "dummy" + @property_hash[:ifnum]
- when :alias
- @property_hash[:ifnum] ||= self.class.next_alias(@resource[:interface])
- return @resource[:interface] + ":" + @property_hash[:ifnum]
- end
+ # create the device name, so this based on the IP, and interface + type
+ def device
+ case @resource.should(:interface_type)
+ when :loopback
+ @property_hash[:ifnum] ||= self.class.next_dummy
+ return "dummy" + @property_hash[:ifnum]
+ when :alias
+ @property_hash[:ifnum] ||= self.class.next_alias(@resource[:interface])
+ return @resource[:interface] + ":" + @property_hash[:ifnum]
+ end
end
# Set the name to our ip address.
@@ -202,19 +202,19 @@ LOOPBACKDUMMY
@property_hash[:name] = value
end
- # whether the device is to be brought up on boot or not. converts
- # the true / false of the type, into yes / no values respectively
- # writing out the ifcfg-* files
- def on_boot
- case @property_hash[:onboot].to_s
- when "true"
- return "yes"
- when "false"
- return "no"
- else
- return "neither"
- end
- end
+ # whether the device is to be brought up on boot or not. converts
+ # the true / false of the type, into yes / no values respectively
+ # writing out the ifcfg-* files
+ def on_boot
+ case @property_hash[:onboot].to_s
+ when "true"
+ return "yes"
+ when "false"
+ return "no"
+ else
+ return "neither"
+ end
+ end
# Mark whether the interface should be started on boot.
def on_boot=(value)
diff --git a/lib/puppet/provider/package/yumhelper.py b/lib/puppet/provider/package/yumhelper.py
index 1142401b9..962b96ce4 100644
--- a/lib/puppet/provider/package/yumhelper.py
+++ b/lib/puppet/provider/package/yumhelper.py
@@ -13,8 +13,7 @@ OVERRIDE_OPTS = {
'logfile': '/dev/null'
}
-def pkg_lists():
- my = yum.YumBase()
+def pkg_lists(my):
my.doConfigSetup()
for k in OVERRIDE_OPTS.keys():
@@ -28,10 +27,13 @@ def pkg_lists():
return my.doPackageLists('updates')
try:
- ypl = pkg_lists()
+ try:
+ my = yum.YumBase()
+ ypl = pkg_lists(my)
+ for pkg in ypl.updates:
+ print "_pkg %s %s %s %s %s" % (pkg.name, pkg.epoch, pkg.version, pkg.release, pkg.arch)
+ finally:
+ my.closeRpmDB()
except IOError, e:
print "_err IOError %d %s" % (e.errno, e)
sys.exit(1)
-
-for pkg in ypl.updates:
- print "_pkg %s %s %s %s %s" % (pkg.name, pkg.epoch, pkg.version, pkg.release, pkg.arch)
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb
index f8049236f..2772b54a8 100755
--- a/lib/puppet/type/exec.rb
+++ b/lib/puppet/type/exec.rb
@@ -211,10 +211,7 @@ module Puppet
log the output when the command reports an error. Values are
**true**, *false*, *on_failure*, and any legal log level."
- values = [:true, :false, :on_failure]
- # And all of the log levels
- Puppet::Util::Log.eachlevel { |level| values << level }
- newvalues(*values)
+ newvalues(:true, :false, :on_failure)
end
newparam(:refresh) do
diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb
index c41a7883b..1b625cc41 100644
--- a/lib/puppet/type/service.rb
+++ b/lib/puppet/type/service.rb
@@ -28,6 +28,8 @@ module Puppet
feature :enableable, "The provider can enable and disable the service",
:methods => [:disable, :enable, :enabled?]
+ feature :controllable, "The provider uses a control variable."
+
newproperty(:enable, :required_features => :enableable) do
desc "Whether a service should be enabled to start at boot.
This property behaves quite differently depending on the platform;
@@ -163,6 +165,13 @@ module Puppet
desc "Specify a *stop* command manually."
end
+ newparam(:control) do
+ desc "The control variable used to manage services (originally for HP-UX).
+ Defaults to the upcased service name plus ``START`` replacing dots with
+ underscores, for those providers that support the ``controllable`` feature."
+ defaultto { resource.name.gsub(".","_").upcase + "_START" if resource.provider.controllable? }
+ end
+
newparam :hasrestart do
desc "Specify that an init script has a ``restart`` option. Otherwise,
the init script's ``stop`` and ``start`` methods are used."