Merge pull request #25 from ejhayes/master
Checkout git repository as user, fixed ensure latest, ssh options
This commit is contained in:
@@ -4,9 +4,10 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
|
|||||||
desc "Supports Git repositories"
|
desc "Supports Git repositories"
|
||||||
|
|
||||||
##TODO modify the commands below so that the su - is included
|
##TODO modify the commands below so that the su - is included
|
||||||
optional_commands :git => 'git'
|
optional_commands :git => 'git',
|
||||||
|
:su => 'su'
|
||||||
defaultfor :git => :exists
|
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
|
def create
|
||||||
if !@resource.value(:source)
|
if !@resource.value(:source)
|
||||||
@@ -95,7 +96,8 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
|
|||||||
|
|
||||||
def update_references
|
def update_references
|
||||||
at_path do
|
at_path do
|
||||||
git_with_identity('fetch', '--tags', @resource.value(:remote))
|
checkout
|
||||||
|
git_with_identity('pull', @resource.value(:remote))
|
||||||
update_owner_and_excludes
|
update_owner_and_excludes
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -278,7 +280,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
|
|||||||
if @resource.value(:identity)
|
if @resource.value(:identity)
|
||||||
Tempfile.open('git-helper') do |f|
|
Tempfile.open('git-helper') do |f|
|
||||||
f.puts '#!/bin/sh'
|
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
|
f.close
|
||||||
|
|
||||||
FileUtils.chmod(0755, f.path)
|
FileUtils.chmod(0755, f.path)
|
||||||
@@ -291,6 +293,8 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
|
|||||||
|
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
elsif @resource.value(:user)
|
||||||
|
su(@resource.value(:user), '-c', "git #{args.join(' ')}" )
|
||||||
else
|
else
|
||||||
git(*args)
|
git(*args)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ Puppet::Type.newtype(:vcsrepo) do
|
|||||||
feature :ssh_identity,
|
feature :ssh_identity,
|
||||||
"The provider supports a configurable SSH identity file"
|
"The provider supports a configurable SSH identity file"
|
||||||
|
|
||||||
|
feature :user,
|
||||||
|
"The provider can run as a different user"
|
||||||
|
|
||||||
feature :modules,
|
feature :modules,
|
||||||
"The repository contains modules that can be chosen of"
|
"The repository contains modules that can be chosen of"
|
||||||
|
|
||||||
@@ -49,6 +52,7 @@ Puppet::Type.newtype(:vcsrepo) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
newvalue :present do
|
newvalue :present do
|
||||||
|
notice "Creating repository from present"
|
||||||
provider.create
|
provider.create
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -75,6 +79,7 @@ Puppet::Type.newtype(:vcsrepo) do
|
|||||||
notice "Updating to latest '#{reference}' revision"
|
notice "Updating to latest '#{reference}' revision"
|
||||||
provider.revision = reference
|
provider.revision = reference
|
||||||
else
|
else
|
||||||
|
notice "Creating repository from latest"
|
||||||
provider.create
|
provider.create
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -128,6 +133,10 @@ Puppet::Type.newtype(:vcsrepo) do
|
|||||||
desc "The group/gid that owns the repository files"
|
desc "The group/gid that owns the repository files"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
newparam :user do
|
||||||
|
desc "The user to run for repository operations"
|
||||||
|
end
|
||||||
|
|
||||||
newparam :excludes do
|
newparam :excludes do
|
||||||
desc "Files to be excluded from the repository"
|
desc "Files to be excluded from the repository"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user