出于测试目的,我想创建一个带有puppet和vcsrepo的裸git存储库,并在同一台机器上查看其内容。我的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_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
我也用未加密的密钥尝试过它......同样的问题。必须有一些我尚未理解的东西。有人提示并可以帮助我吗?
答案 0 :(得分:2)
为了使puppet
能够使用您的私钥建立SSH连接,您需要生成一个没有密码短语的连接。
由于puppet无法输入密码,因此连接尝试将失败。
答案 1 :(得分:0)
要将git存储库克隆为myuser,必须将其指定为key => Vcsrepo块中的值。如下所示:
vcsrepo { "/var/tmp/x":
user => 'myuser',
provider => git,
ensure => present,
source => 'ssh://localhost:22/srv/git/test.git',
require => User['myuser'],
}
答案 2 :(得分:0)
问题在于用户权限,我得到了相同的错误,当我将用户更改为root时,它对我有用。如下所示:
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"],
}