Reputation: 21
Apologies if this is obvious/a stupid question. Prior to this, I have never really worked with git.
For one of my work projects, my team wants to use git to handle configuration files. Think one "git server," users push security configurations to the server, and endpoints pull those config files to themselves.
I understand the process as so:
I've gotten this to work fine in my test environment and feel like I (to some degree) know what I'm doing.
My question:
When I pull from the git server to an endpoint, everything in the git server's repo gets put into one directory (repo) on the endpoint.
Is there a way to configure git to then move the files it pulled to different directories on my endpoint(e.g. file x,y, and z get put in /opt, file a, b, and c get put in /bin)?
I've looked into post-receive hooks a bit, but it seems this only has functionality on the git server once something is pushed to it. Am I incorrect on this? Is there another type of hook I should be investigating? Another idea I've played with is if the repo directory is placed "high" enough on the machine (like / on linux), that could maybe work? I feel like it would be taxing to push/pull that much each time and could mess with other files on the endpoints. Am I completely off the mark?
Thank you for any assistance in advance.
Upvotes: 0
Views: 66
Reputation: 52026
While git
is a very good versioning system, it makes for a rather poor deployment system -- and more specifically, git pull
will regularly bite you in the neck (we can agree on a larger anatomical scope).
For example: I don't know how critical the configuration files you are targetting on these servers are, but would your server work correctly if some conflict markers (<<<<<< HEAD , >>>>> eacf32b
) appeared in the middle of said config files ?
I would suggest to simply add scripts to deploy said configuration files from [something] to your server.
[something] can start being a checkout of your repo, either on target server (in a directory where you wouldn't break your existing services ...) or on a separate "provisioning" server, and could later become a tar archive (or a set of files) packed by your CI server.
Your scripts can start as simple bash or bat scripts, which just copy (local cp or remote scp) over files from one place to another, and may later gain the ability to instanciate some templates, or become actions in a bigger provisionning framework ...
Upvotes: 2