[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

James Turnbull james at lovedthanlost.net
Wed Jul 14 10:29:30 UTC 2010


The following commit has been merged in the upstream branch:
commit 0f6181680974f8307eb4ef5e4f6b75b58a195321
Author: Rein Henrichs <reinh at reinh.com>
Date:   Thu Oct 15 16:38:44 2009 -0700

    Fix #2649 Allow ssl dir creation in --noop mode
    
    Wrap Puppet::Settings.use in a block that disables noop mode during the
    execution of the block and ensures that noop returns to its original
    value afterwards. This allows internal puppet catalog operations like
    ssl directory creation to occur even when puppet is run in --noop mode.
    This should actually solve a broader class of related bugs.

diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index e80c7cc..f2c513b 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -157,6 +157,14 @@ class Puppet::Util::Settings
         set_value(str, value, :cli)
     end
 
+    def without_noop
+        old_noop = value(:noop,:cli)
+        set_value(:noop, false, :cli)
+        yield
+    ensure
+        set_value(:noop, old_noop, :cli)
+    end
+
     def include?(name)
         name = name.intern if name.is_a? String
         @config.include?(name)
@@ -632,7 +640,7 @@ Generated on #{Time.now}.
                 return
             end
 
-            begin
+            without_noop do
                 catalog.host_config = false
                 catalog.apply do |transaction|
                     if transaction.any_failed?
diff --git a/spec/integration/bin/puppetmasterd.rb b/spec/integration/bin/puppetmasterd.rb
index b5a3f96..2dcd593 100755
--- a/spec/integration/bin/puppetmasterd.rb
+++ b/spec/integration/bin/puppetmasterd.rb
@@ -107,4 +107,27 @@ describe "puppetmasterd" do
     end
 
     it "should exit with return code 1 after parsing if --parseonly is set and there are errors"
+
+    describe "when run for the first time" do
+        before do
+            @ssldir = File.join(@dir, 'ssl')
+            FileUtils.rm_r(@ssldir) if File.exists?(@ssldir)
+        end
+
+        describe "with noop" do
+            it "should create its ssl directory" do
+                File.directory?(@ssldir).should be_false
+                start(' --noop')
+                File.directory?(@ssldir).should be_true
+            end
+        end
+
+        describe "without noop" do
+            it "should create its ssl directory" do
+                File.directory?(@ssldir).should be_false
+                start
+                File.directory?(@ssldir).should be_true
+            end
+        end
+    end
 end
diff --git a/spec/unit/util/settings.rb b/spec/unit/util/settings.rb
index aa2101f..7527031 100755
--- a/spec/unit/util/settings.rb
+++ b/spec/unit/util/settings.rb
@@ -718,6 +718,7 @@ describe Puppet::Util::Settings do
         before do
             @settings = Puppet::Util::Settings.new
             @settings.stubs(:service_user_available?).returns true
+            @settings.setdefaults :main, :noop => [false, ""]
             @settings.setdefaults :main, :maindir => ["/maindir", "a"], :seconddir => ["/seconddir", "a"]
             @settings.setdefaults :main, :user => ["suser", "doc"], :group => ["sgroup", "doc"]
             @settings.setdefaults :other, :otherdir => {:default => "/otherdir", :desc => "a", :owner => "service", :group => "service", :mode => 0755}
@@ -999,4 +1000,20 @@ describe Puppet::Util::Settings do
 
         it "should cache the result"
     end
+
+    describe "#without_noop" do
+        before do
+            @settings = Puppet::Util::Settings.new
+            @settings.setdefaults :main, :noop => [true, ""]
+        end
+
+        it "should set noop to false for the duration of the block" do
+            @settings.without_noop { @settings.value(:noop, :cli).should be_false }
+        end
+
+        it "should ensure that noop is returned to its previous value" do
+            @settings.without_noop { raise } rescue nil
+            @settings.value(:noop, :cli).should be_true
+        end
+    end
 end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list