refactor things for >2.7

This commit is contained in:
mh 2012-06-08 13:19:37 -03:00
parent f5761c532a
commit 0965fda26f
4 changed files with 7 additions and 4 deletions

View file

@ -19,7 +19,10 @@ Puppet::Parser::Functions::newfunction(:tinc_keygen, :type => :rvalue, :doc =>
raise Puppet::ParseError, "#{path} is a directory" if File.directory?(path)
end
Puppet::Util.recmkdir(dir,0700) unless File.directory?(dir)
unless File.directory?(dir)
require 'fileutils'
FileUtils.mkdir_p(dir, :mode => 0700)
end
unless [private_key_path,public_key_path].all?{|path| File.exists?(path) }
output = Puppet::Util.execute(['/usr/sbin/tincd', '-c', dir, '-n', name, '-K'])
raise Puppet::ParseError, "Something went wrong during key generation! Output: #{output}" unless output =~ /Generating .* bits keys/

View file

@ -83,7 +83,7 @@ define tinc::vpn_net(
if $key_source_path == 'absent' {
fail("You need to set \$key_source_prefix for $name to generate keys on the master!")
}
$tinc_keys = tinc_keygen($name,"${key_source_path}/${name}/${fqdn}")
$tinc_keys = tinc_keygen($name,"${key_source_path}/${name}/${::fqdn}")
file{"/etc/tinc/${name}/rsa_key.priv":
content => $tinc_keys[0],
notify => Service[tinc],

View file

@ -74,7 +74,7 @@ describe "the tinc_keygen function" do
File.stubs(:exists?).with("/tmp/a/b/rsa_key.priv").returns(false)
File.stubs(:exists?).with("/tmp/a/b/rsa_key.pub").returns(false)
File.stubs(:directory?).with("/tmp/a/b").returns(false)
Puppet::Util.expects(:recmkdir).with("/tmp/a/b",0700)
FileUtils.expects(:mkdir_p).with("/tmp/a/b", :mode => 0700)
Puppet::Util.expects(:execute).returns("foo\nbar\nGenerating 2048 bits keys\n++++\n---")
result = @scope.function_tinc_keygen(['foo','/tmp/a/b'])
result.length.should == 2

View file

@ -1,4 +1,4 @@
Address = <%= scope.lookupvar("ipaddress_#{tinc_interface}") %>
Address = <%= scope.lookupvar("::ipaddress_#{tinc_interface}") %>
Port = <%= port %>
Compression = <%= compression %> # 0=no,11=best lzo
#