From 744f3cc4094062ef1f6a80c644d82b6284d2f7fc Mon Sep 17 00:00:00 2001 From: Felix Krull Date: Fri, 14 Feb 2014 22:12:42 +0100 Subject: Only add ssh options to commands that actually talk to the network. At least in Mercurial 2.8.2, --ssh seems to be a command-specific parameter in contrast to a global one. As a result, local commands error when seeing a --ssh parameter. This change passes --ssh only for commands that actually talk to the network ('incoming', 'pull' and 'clone' here). --- lib/puppet/provider/vcsrepo/hg.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/vcsrepo/hg.rb b/lib/puppet/provider/vcsrepo/hg.rb index 33f1e6a..6c6f936 100644 --- a/lib/puppet/provider/vcsrepo/hg.rb +++ b/lib/puppet/provider/vcsrepo/hg.rb @@ -37,7 +37,7 @@ Puppet::Type.type(:vcsrepo).provide(:hg, :parent => Puppet::Provider::Vcsrepo) d def latest at_path do begin - hg_wrapper('incoming', '--branch', '.', '--newest-first', '--limit', '1')[/^changeset:\s+(?:-?\d+):(\S+)/m, 1] + hg_wrapper('incoming', '--branch', '.', '--newest-first', '--limit', '1', { :remote => true })[/^changeset:\s+(?:-?\d+):(\S+)/m, 1] rescue Puppet::ExecutionFailure # If there are no new changesets, return the current nodeid self.revision @@ -66,7 +66,7 @@ Puppet::Type.type(:vcsrepo).provide(:hg, :parent => Puppet::Provider::Vcsrepo) d def revision=(desired) at_path do begin - hg_wrapper('pull') + hg_wrapper('pull', { :remote => true }) rescue end begin @@ -92,6 +92,7 @@ Puppet::Type.type(:vcsrepo).provide(:hg, :parent => Puppet::Provider::Vcsrepo) d end args.push(@resource.value(:source), @resource.value(:path)) + args.push({ :remote => true }) hg_wrapper(*args) end @@ -102,7 +103,11 @@ Puppet::Type.type(:vcsrepo).provide(:hg, :parent => Puppet::Provider::Vcsrepo) d end def hg_wrapper(*args) - if @resource.value(:identity) + options = { :remote => false } + if args.length > 0 and args[-1].is_a? Hash + options.merge!(args.pop) + end + if options[:remote] and @resource.value(:identity) args += ["--ssh", "ssh -oStrictHostKeyChecking=no -oPasswordAuthentication=no -oKbdInteractiveAuthentication=no -oChallengeResponseAuthentication=no -i #{@resource.value(:identity)}"] end if @resource.value(:user) and @resource.value(:user) != Facter['id'].value -- cgit v1.2.3