1

I have a project using vcsrepo in puppet to copy to a server using puppet. So the entire git project copied down. I can limit it to just latest with depth=1.

vcsrepo {$docroot:
  ensure => latest,
  provider => git,
  source => 'git@www.github.com:my-repo.git',
  revision => 'mytag'
  depth => 1
  etc.
}

Ideally, I would like only the /mysubdirectory from the my-repo git repo copied to $docroot directory on the server.

This example shows what I think could work: How do I clone a subdirectory only of a Git repository? But it doesn't seem to be enough puppet options.

Or is there another approach:

Essentially copy git project somewhere else on the server and then copy the files from .git directory to the $docroot. I still just want the src that is attached to the mytag in git. (I technically don't need the git features such as push or pull repository on the server).

How would I do that with puppet code?

I do not want to use exec (or equivalent).

UPDATE:

I should have started by saying I am a git and puppet newbie. The purpose and reason I am doing this is I have a git project called myproject. In the project is a subdirectory called /src. In the git repository are tags like "mytag-20170517" and mytag-201705018". When I add the property revision=>'mytag' it copies the proper files, but it brings over too many files.

myproject\
  file-i-do-NOT-want-puppet-to-copy1.txt (tagged with mytag-2017-0518)
  file-i-do-NOT-want-puppet-to-copy2.txt (tagged with mytag-2017-0518)
  src\
    file-i-DO-want-puppet-to-copy1.txt  (tagged with mytag-2017-0518)
    file-i-DO-want-puppet-to-copy2.txt  (tagged with mytag-2017-0518)

Currently with vcsrepo it would copy ALL directories including the root files to my target server using puppet. Ideally, ONLY the files starting from /src. The files in the root of src are the files I want in the root of $docroot.

How do I solve that problem?

JeffJak
  • 2,008
  • 5
  • 28
  • 40

1 Answers1

1

If you do not want to use exec (I would use exec by the way), the only other option I can think of is to send a pull request to add the feature you need in here. Or, write a provider yourself in Ruby.

That said, you have not said why you want to do this, and I wonder if splitting the Git repo itself up into submodules, which are supported by vcsrepo, could be a better solution for you?

Alex Harvey
  • 14,494
  • 5
  • 61
  • 97
  • Good point. I didn't actually say why I wanted to do what I am requesting. I will update post. – JeffJak May 19 '17 at 18:59
  • Since I am a git newbie, I never heard of submodules. Thank you for the links. But that doesn't quite seem like what I am looking for. – JeffJak May 19 '17 at 19:16
  • Thanks for the update. However, your update does not say why it is important to you to have only a subnet of the files checked out, or what you mean exactly by "too many files". Normally, people just check out the whole repo and if some of those files are irrelevant, we ignore them. – Alex Harvey May 20 '17 at 10:16