summaryrefslogtreecommitdiff
path: root/lib/puppet/provider/vcsrepo
diff options
context:
space:
mode:
authorEric Hayes <eric@inflection.com>2012-06-29 02:50:12 -0700
committerEric Hayes <eric@inflection.com>2012-06-29 02:50:12 -0700
commit4d2942edc26e7cd144a3178a1a7f6470ea401345 (patch)
treefb6c2e882f31389822259a8c1117086a2cb5a37a /lib/puppet/provider/vcsrepo
parent493dc2172bd01dcb4f47e4233292cd3dcdea08b9 (diff)
downloadpuppet-vcsrepo-4d2942edc26e7cd144a3178a1a7f6470ea401345.tar.gz
puppet-vcsrepo-4d2942edc26e7cd144a3178a1a7f6470ea401345.tar.bz2
Run git operations as a specific user (puppetlabs ticket 4773), added ssh options to ensure no prompting (also fixed in pull request #1 by riseuplabs), added ability to keep repository up to date with latest (puppetlabs ticket 11278)
Diffstat (limited to 'lib/puppet/provider/vcsrepo')
-rw-r--r--lib/puppet/provider/vcsrepo/git.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb
index 5febce2..afd9963 100644
--- a/lib/puppet/provider/vcsrepo/git.rb
+++ b/lib/puppet/provider/vcsrepo/git.rb
@@ -4,9 +4,10 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
desc "Supports Git repositories"
##TODO modify the commands below so that the su - is included
- optional_commands :git => 'git'
+ optional_commands :git => 'git',
+ :su => 'su'
defaultfor :git => :exists
- has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes
+ has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user
def create
if !@resource.value(:source)
@@ -95,7 +96,8 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
def update_references
at_path do
- git_with_identity('fetch', '--tags', @resource.value(:remote))
+ checkout
+ git_with_identity('pull', @resource.value(:remote))
update_owner_and_excludes
end
end
@@ -278,7 +280,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
if @resource.value(:identity)
Tempfile.open('git-helper') do |f|
f.puts '#!/bin/sh'
- f.puts "exec ssh -i #{@resource.value(:identity)} $*"
+ f.puts "exec ssh -oStrictHostKeyChecking=no -oPasswordAuthentication=no -oKbdInteractiveAuthentication=no -oChallengeResponseAuthentication=no -i #{@resource.value(:identity)} $*"
f.close
FileUtils.chmod(0755, f.path)
@@ -291,6 +293,8 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
return ret
end
+ elsif @resource.value(:user)
+ su(@resource.value(:user), '-c', "git #{args.join(' ')}" )
else
git(*args)
end