繁体   English   中英

如何使用ssh在Puppet中使用vcsrepo设置和签出git存储库

[英]How to setup and checkout a git repository with vcsrepo in puppet using ssh

为了进行测试,我想使用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添加到.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

我也尝试过使用未加密的密钥...同样的问题。 肯定有些我还不了解的东西。 有任何提示,可以帮助我吗?

为了使puppet可以使用您的私钥建立SSH连接,您需要生成一个没有密码短语的连接。

由于p无法输入密码,因此连接尝试必将失败。

要将git仓库克隆为myuser,必须在Vcsrepo块中将其指定为key => value。 如下所示:

vcsrepo { "/var/tmp/x":
   user => 'myuser',
   provider => git,
   ensure => present,
   source  => 'ssh://localhost:22/srv/git/test.git',
   require => User['myuser'],

}

问题出在用户权限上,我遇到同样的错误,当我将用户更改为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"],
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM