For test purposes I want to create a bare git repository with puppet and vcsrepo and check out its content on the same machine. I have a site.pp
that looks as follows:
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
? I have added the public and private key of the user to .ssh
and added the public key to .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.
As puppet has no way to enter the passphrase, the connection attempt is bound to fail.
To clone the git repository as myuser, you must specify that as a key => value in the Vcsrepo block. 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. 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"],
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.