如何使用ssh在puppet中使用vcsrepo设置和签出git存储库
出于测试目的,我想用puppet和vcsrepo创建一个裸git存储库,并在同一台机器上检查其内容。我有一个如何使用ssh在puppet中使用vcsrepo设置和签出git存储库,git,ssh,puppet,Git,Ssh,Puppet,出于测试目的,我想用puppet和vcsrepo创建一个裸git存储库,并在同一台机器上检查其内容。我有一个site.pp,如下所示: node 'gamma.localdomain' { include git vcsrepo { "/srv/git/test.git": provider => git, ensure => bare, require => Package['git'], } user { "
site.pp
,如下所示:
node 'gamma.localdomain' {
include git
vcsrepo { "/srv/git/test.git":
provider => git,
ensure => bare,
require => Package['git'],
}
user { "myuser":
ensure => present,
}
vcsrepo { "/var/tmp/x":
provider => git,
ensure => present,
source => 'ssh://localhost:22/srv/git/test.git',
require => User['myuser'],
}
}
git存储库已创建,但我必须如何通过ssh
克隆它?我已将用户的公钥和私钥添加到.ssh
,并将公钥添加到.ssh/authorized\u keys
。如果我使用
git clone ssh:\\localhost:22\srv\git\test.git`
我必须提供访问私钥的密码,并且内容已签出。有了木偶,我得到了:
Notice: /Stage[main]/Main/Node[gamma.localdomain]/Vcsrepo[/var/tmp/x]/ensure: Creating repository from present
Error: Execution of '/usr/bin/git clone ssh://localhost:22/srv/git/test.git /var/tmp/x' returned 128: Cloning into '/var/tmp/x'...
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: The remote end hung up unexpectedly
Error: /Stage[main]/Main/Node[gamma.localdomain]/Vcsrepo[/var/tmp/x]/ensure: change from absent to present failed: Execution of '/usr/bin/git clone ssh://localhost:22/srv/git/test.git /var/tmp/x' returned 128: Cloning into '/var/tmp/x'...
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: The remote end hung up unexpectedly
我也用一把未加密的钥匙试过。。。同样的问题。一定有什么事我还不明白。有人有什么提示可以帮我吗?要使
puppet
能够使用您的私钥进行SSH连接,您需要生成一个不带密码短语的连接
由于puppet无法输入密码短语,连接尝试肯定会失败。要将git存储库克隆为myuser,必须在Vcsrepo块中将其指定为key=>值。如下图所示:
vcsrepo { "/var/tmp/x":
user => 'myuser',
provider => git,
ensure => present,
source => 'ssh://localhost:22/srv/git/test.git',
require => User['myuser'],
file { "/root/.ssh/id_rsa": #This is required by vcsrepo in require sesion
ensure => present,
source => '/vagrant/id_rsa',
}
vcsrepo { '/tmp/test/':
ensure => latest,
provider => git,
source => 'git@gitlab.xyz.git',
user => 'root',
require => File["/root/.ssh/id_rsa"],
}
}问题在于用户权限,我遇到了相同的错误,当我将用户更改为root用户时,它对我有效。如下图所示:
vcsrepo { "/var/tmp/x":
user => 'myuser',
provider => git,
ensure => present,
source => 'ssh://localhost:22/srv/git/test.git',
require => User['myuser'],
file { "/root/.ssh/id_rsa": #This is required by vcsrepo in require sesion
ensure => present,
source => '/vagrant/id_rsa',
}
vcsrepo { '/tmp/test/':
ensure => latest,
provider => git,
source => 'git@gitlab.xyz.git',
user => 'root',
require => File["/root/.ssh/id_rsa"],
}