Hello, i would like to ask for your advice. I hav...
# puppet
o
Hello, i would like to ask for your advice. I have next use case: • some scripts located in git repo "terraform" (3 bash scripts in terraform/aws-backup/scripts/backup and 3 bash scripts in terraform/aws-backup/scripts/restore) • puppet code and all the good stuff located in "controlrepo" repository I need to put these scripts on certain servers with Puppet agents installed. Scripts itself rarely changed, but sometimes changes may happen. (i.e. external team pushes commits to git repo "terraform") My goal is to try to distribute latest versions to of the scripts from git repo "terraform" via puppet without extra manual work. (i.e. without doing manual sync changes from git repo "terraform" to git repo "controlrepo" I kind of know how to do "old way", for example manage content of files via Puppet and specify "content" or "source" parameters. But it will lead to problem that when another team will make changes to these scripts -> we will have to manually update them inside our "controlrepo". Which means that we will have to do extra work and most likely developers or someone else will eventually forget about it). Is there any better way how it can be done? (to somehow sync changes and when files updated in repo "terraform/aws-backup/scripts/*" to distribute them to the nodes?
y
This is more of a process problem than a Puppet one. If folks make changes to the script on $randomServer but don't check those changes into a version control repository, they shouldn't get upset when Puppet replaces their changes with the version from the repo.
Puppet gives you three options: 1. Don't manage the file 2. Manage the file 3. Place the file but ignore changes to it If none of those solve the problem, change the problem.
😱 1
b
Why do you sync the files to the control repo?
Checkout the terraform repo on your nodes?
o
"Checkout the terraform repo on your nodes?" I was thinking about it, but i though that it may be tricky, because scripts are in private git repo, to checkout them on the target nodes i will have to create cron jobs and pass SSH key to make git clone / git pull So i though maybe i can do it one time on Puppet server and then target nodes will just pick up changes
h
So do that, checkout repo on server and install files as content. ?
y
Good point. I forgot about the vcsrepo module.
👀 1
o
Thanks, looking into vcsrepo module
I don't quite understand how to pass SSH key using vcsrepo module (called "deployment" SSH key in Bitbucket terminology, which only allow Read). Also there is an aspect that inside git repo "terraform" structure is: • "name_of_the_repo/aws-backup/scripts/backup" • "name_of_the_repo/aws-backup/scripts/restore" And i need to place those files to: • /opt/username/scripts/backup • /opt/username/scripts/restore So seems that some sort of "post-processing" is needed in one way or another to checkout only needed folders from git and place them into proper directory. In README to vcsrepo module such features only for SVN repo, not git repo. So my thinking process circles back to idea of just running "git clone & git pull" on Puppet server via cron job, and then use this folder as "Fileserver" as source to distribute scripts to target nodes. This way only 1 git checkout will be needed instead of hundreds of VMs doing it periodically It will work, i guess i will have to stick to this method (?)
b
Your process sounds overly complicated and broken