From 0965fda26fdb6108455392fe6b4c3cec6df88b70 Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 8 Jun 2012 13:19:37 -0300 Subject: [PATCH] refactor things for >2.7 --- lib/puppet/parser/functions/tinc_keygen.rb | 5 ++++- manifests/vpn_net.pp | 2 +- spec/unit/parser/functions/tinc_keygen.rb | 2 +- templates/host.erb | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/puppet/parser/functions/tinc_keygen.rb b/lib/puppet/parser/functions/tinc_keygen.rb index 3635865..d5c128d 100644 --- a/lib/puppet/parser/functions/tinc_keygen.rb +++ b/lib/puppet/parser/functions/tinc_keygen.rb @@ -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/ diff --git a/manifests/vpn_net.pp b/manifests/vpn_net.pp index eacb99a..9016dc4 100644 --- a/manifests/vpn_net.pp +++ b/manifests/vpn_net.pp @@ -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], diff --git a/spec/unit/parser/functions/tinc_keygen.rb b/spec/unit/parser/functions/tinc_keygen.rb index 6b6a5a7..f9f405e 100644 --- a/spec/unit/parser/functions/tinc_keygen.rb +++ b/spec/unit/parser/functions/tinc_keygen.rb @@ -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 diff --git a/templates/host.erb b/templates/host.erb index 9301211..6adeacd 100644 --- a/templates/host.erb +++ b/templates/host.erb @@ -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 #