[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5
Dominic Cleal
dcleal at redhat.com
Tue May 10 08:05:23 UTC 2011
The following commit has been merged in the experimental branch:
commit 45cba13ee6d67c9c48e6db7b810f2fc55b1b14b8
Author: Dominic Cleal <dcleal at redhat.com>
Date: Fri Feb 25 22:06:28 2011 +0000
(#6494) Add defvar command to Augeas provider
Uses Augeas' native defvar command to define variables for certain expressions
that can then be referenced later with $variable.
diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb
index 4619682..89f08ac 100644
--- a/lib/puppet/provider/augeas/augeas.rb
+++ b/lib/puppet/provider/augeas/augeas.rb
@@ -36,6 +36,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do
"clear" => [ :path ],
"insert" => [ :string, :string, :path ],
"get" => [ :path, :comparator, :string ],
+ "defvar" => [ :string, :path ],
"match" => [ :path, :glob ],
"size" => [:comparator, :int],
"include" => [:string],
@@ -354,6 +355,10 @@ Puppet::Type.type(:augeas).provide(:augeas) do
debug("sending command '#{command}' with params #{[label, where, path].inspect}")
rv = aug.insert(path, label, before)
fail("Error sending command '#{command}' with params #{cmd_array.inspect}") if (rv == -1)
+ when "defvar"
+ debug("sending command '#{command}' with params #{cmd_array.inspect}")
+ rv = aug.defvar(cmd_array[0], cmd_array[1])
+ fail("Error sending command '#{command}' with params #{cmd_array.inspect}") if (!rv)
else fail("Command '#{command}' is not supported")
end
rescue SystemExit,NoMemoryError
diff --git a/spec/unit/provider/augeas/augeas_spec.rb b/spec/unit/provider/augeas/augeas_spec.rb
index 9fcc856..a65af99 100644
--- a/spec/unit/provider/augeas/augeas_spec.rb
+++ b/spec/unit/provider/augeas/augeas_spec.rb
@@ -433,5 +433,28 @@ describe provider_class do
@augeas.expects(:close)
@provider.execute_changes.should == :executed
end
+
+ it "should handle defvar commands" do
+ command = "defvar myjar Jar/Jar"
+ context = "/foo/"
+ @resource.expects(:[]).times(2).returns(command).then.returns(context)
+ @augeas.expects(:defvar).with("myjar", "/foo/Jar/Jar").returns(true)
+ @augeas.expects(:save).returns(true)
+ @augeas.expects(:close)
+ @provider.execute_changes.should == :executed
+ end
+
+ it "should pass through augeas defvar variables without context" do
+ command = ["defvar myjar Jar/Jar","set $myjar/Binks 1"]
+ context = "/foo/"
+ @resource.expects(:[]).times(2).returns(command).then.returns(context)
+ @augeas.expects(:defvar).with("myjar", "/foo/Jar/Jar").returns(true)
+ # this is the important bit, shouldn't be /foo/$myjar/Binks
+ @augeas.expects(:set).with("$myjar/Binks", "1").returns(true)
+ @augeas.expects(:save).returns(true)
+ @augeas.expects(:close)
+ @provider.execute_changes.should == :executed
+ end
+
end
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list