Ask Your Question
0

exec "git clone" fails.

asked 2014-10-29 09:17:07 -0600

Krist van Besien gravatar image

updated 2014-10-29 12:14:32 -0600

I have /etc/ under version control, and want to clone it to a shared dir (/opt/backup). for this I use the following code:

exec {'git.clone':
    path     => '/usr/bin',
    cwd      => '/etc',
    creates  => "/opt/backup/$::fqdn.etckeeper.git",
    command  => "git clone --bare . /opt/backup/$::fqdn.etckeeper.git",
}

This fails with the following output:

Debug: Exec[git.clone](provider=posix): Executing 'git clone --bare . /opt/backup/bast.etckeeper.git'
Debug: Executing 'git clone --bare . /opt/backup/bast.etckeeper.git'
Notice: /Stage[main]/Sws::Base::Etckeeper/Exec[git.clone]/returns: Initialized empty Git repository in /opt/backup/bast.etckeeper.git/
Notice: /Stage[main]/Sws::Base::Etckeeper/Exec[git.clone]/returns: error: cannot run git-upload-pack '/etc/.git': No such file or directory
Notice: /Stage[main]/Sws::Base::Etckeeper/Exec[git.clone]/returns: fatal: unable to fork
Error: git clone --bare . /opt/backup/bast.etckeeper.git returned 128 instead of one of [0]
Error: /Stage[main]/Sws::Base::Etckeeper/Exec[git.clone]/returns: change from notrun to 0 failed: git clone --bare . /opt/backup/bast.etckeeper.git returned 128 instead of one of [0]

When I executed the command "git clone --bare . /opt/backup/bast.etckeeper.git" myself it works.

What I also noticed is that it takes some time before the error appears. In that time the directory /opt/backup/bast.etckeeper.git gets created, but then when the command fails it gets removed again. When cloning git starts a subprocess to copy over all the objects, and it is this "fork" which seems to fail.

Any idea why? What can I do about this?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2016-10-05 00:37:28 -0600

binford2k gravatar image

A better pattern is to use a tool that's already designed for this instead of writing your own exec. What you want probably looks something like the following, though it's untested.

vcsrepo { "/opt/backup/${::fqdn}.etckeeper.git":
    ensure   => bare,
    provider => git,
    source   => '/etc',
}

https://forge.puppet.com/puppetlabs/v...

edit flag offensive delete link more
0

answered 2014-10-29 10:44:47 -0600

spuder gravatar image

One thing that jumps out is this line:

 Initialized empty Git repository in /opt/backup/bast-.etckeeper.git

Your fqdn likely doesn't end in a trailing dash (-)

Are you running puppet as root?
Is puppet able to write to the /opt/backup directory?

Try running the puppet apply from the command line

puppet apply -e 'include foo' --modulepath=foo --debug --verbose --detailed-exitcodes
edit flag offensive delete link more

Comments

the "-" was a typo. I had to edit out the real hostnames. (I have already had complaints about internal hostnames turning up on google searches.) Puppet runs as root, and can write in /opt/backup. The problem is that it cannot fork.

Krist van Besien gravatar imageKrist van Besien ( 2014-10-29 12:16:23 -0600 )edit

puppet apply from the command line, is something I have never done, I'll need to look in to this. We are using puppet together with foreman, so there isn't really a manifest to apply...

Krist van Besien gravatar imageKrist van Besien ( 2014-10-29 12:17:35 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-10-29 09:17:07 -0600

Seen: 1,575 times

Last updated: Oct 05 '16