[英]How to setup and checkout a git repository with vcsrepo in puppet using ssh
For test purposes I want to create a bare git repository with puppet and vcsrepo and check out its content on the same machine. 为了进行测试,我想使用puppet和vcsrepo创建一个裸露的git存储库,并在同一台计算机上检出其内容。 I have a site.pp
that looks as follows: 我有一个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'],
}
}
The git repository is created, but what must I do to clone it via ssh
? git存储库已创建,但是我该怎么做才能通过ssh
克隆它? I have added the public and private key of the user to .ssh
and added the public key to .ssh/authorized_keys
. 我已将用户的.ssh
和.ssh
添加到.ssh
,并将.ssh
添加到.ssh/authorized_keys
。 If I clone the repository via the shell with 如果我通过外壳克隆存储库
git clone ssh:\\localhost:22\srv\git\test.git`
I must give my password for accessing my private key and the content is checked out. 我必须输入密码才能访问我的私钥,并且内容已签出。 With puppet I get: 使用木偶,我得到:
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
I have also tried it with an unencrypted key... The same issue. 我也尝试过使用未加密的密钥...同样的问题。 There must be something which I have not yet understood. 肯定有些我还不了解的东西。 Has anybody a hint and can help me? 有任何提示,可以帮助我吗?
To make it possible for puppet
to make SSH connections using your private key, you need to generate one without a passphrase. 为了使puppet
可以使用您的私钥建立SSH连接,您需要生成一个没有密码短语的连接。
As puppet has no way to enter the passphrase, the connection attempt is bound to fail. 由于p无法输入密码,因此连接尝试必将失败。
To clone the git repository as myuser, you must specify that as a key => value in the Vcsrepo block. 要将git仓库克隆为myuser,必须在Vcsrepo块中将其指定为key => value。 Like below: 如下所示:
vcsrepo { "/var/tmp/x":
user => 'myuser',
provider => git,
ensure => present,
source => 'ssh://localhost:22/srv/git/test.git',
require => User['myuser'],
} }
The issue is with user rights, I got same error and when i changed my user to root it worked for me. 问题出在用户权限上,我遇到同样的错误,当我将用户更改为root时,它对我有用。 Like below: 如下所示:
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"],
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.