0

We have a single git repository on a test server (let's call it test1). The repository is very simple, just master no branches or anything fancy. The goal of this repo is to track changes to /etc/puppet and all of its sub folders. It's usually clean and synced with head.

Now we want to copy everything in test1:/etc/puppet to a production server (let's call it prod1) while maintaining a proper git workflow between to two machines. Whenever changes on test1 are ready for production, we want to use git to push them from test1 to prod1. The goal here is to be able to quickly revert back changes on prod1 if anything breaks.

This is what I have of so far:

  1. Setup a bare git repo (git init --bare) on test1:/opt/puppet.git to act as an intermediate server.
  2. Push data from test1:/etc/puppet to the bare.
  3. On prod1 init a new repo in /etc/puppet
  4. Add test1:/opt/puppet.git bare as remote to prod1:/etc/puppet
  5. Pull master data on from test1 to prod1 whenever we want to apply changes to production.

What are your thoughts? Should we continue to use a single master branch or we need to create a new devel branch? If we create devel branch, how do we use it with the newly created bare repo?

1

If I summarize your request, what you want, is to have an architecture with 1 git server which receives all the pushes from users, and automated pushes to prod when it's ready.

This is exactly what is done with architectire based on gerrit review system for instance. The workflow is as follow :

  1. Git pull from prod server
  2. Do you changes locally
  3. Git push to test server (always in dedicated branch)
  4. Assign reviewer to the commit and add extra hooks to launch for instance smoke test on jenkins (the hakks are added during installation pahse).
  5. When reviewers have accepted the code and the jenkins smoke test are ok, if trivial merge is still possible with master, push is done via gerrit automatically.

So the good point here is that nobody (if properly configured) can push to master without minimal review and basic test. So you master branch from prod is (almost) always clean.

0

I've actually sorted out this one by myself. After some testing, I've created an intermediate bare git repo (git init --bare) on test1. This will act kind of as a git server that will receive and push commits to test1 + prod1 repos at will.

To achieve this I did the following: On test1 machine: 1. mkdir /opt/puppet.git 2. cd /opt/puppet.git 3. git init --bare 4. cd /etc/puppet (where the current git repo with actual code is located) 5. useradd git && passwd git (to allow push/pull from remote hosts) 6. git remote add origin git@test1:/opt/puppet.git 7. git push origin --all I now have all my code stored in the bare repo at /opt/puppet.git On prod1 1. cd /etc 2. git clone git@test1:/opt/puppet.git 3. If I want to pull latest changes: git pull

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.