Ask Your Question

Do I need to use 'environment' with r10k?

asked 2016-12-19 10:27:05 -0600

evil_del gravatar image

updated 2016-12-19 10:27:30 -0600


We would like to start using r10k. The only problem is that we would have to change the use of environment in our code base.

Current situation

We use environment to distinguish between production/accreditation/stress_test environments. We roll out the master branch of our repo to the puppet master. We can only roll out one branch at any one time. Each environment is defined using the following files:

  • environments/accreditation/manifests/site.pp
  • environments/production/manifests/site.pp
  • environments/stress_test/manifests/site.pp


We would like to use r10k so we can access multiple branches at the same time. The problem is that would need to change every occurrence of environment to use a different name e.g. int_environment. r10k maps branches 1:1 with environments. It would be better if we could use r10k and instead of it relying on environment, we could replace it with branch or some other term.

I'm aware that this probably seems like a strange question. I just dont see how we can use r10k without a major refactor of the code base and that means either: a. subverting that problem, or b. investing the effort to refactor. So worth me asking.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-12-19 11:34:01 -0600

lupin gravatar image

It would be better if we could use r10k and instead of it relying on environment, we could replace it with branch or some other term.

This exactly what r10k do - create an environment base on the git branches. Did I missed something on your question? On your current situation, those environment can be converted into git branches with those name.

edit flag offensive delete link more


Yeah, at the moment the only branch that is authoritative is the master branch. We have a monolithic repo for all Puppet code. All other branches are treated as feature branches. So if we converted each environment to a branch, this would then make releasing more complex.

evil_del gravatar imageevil_del ( 2016-12-19 13:51:37 -0600 )edit

If we need to make a change to production and accreditation, then we need to merge one change into two branches at least. Where as at the moment, we have one master branch we merge to when we release.

evil_del gravatar imageevil_del ( 2016-12-19 13:53:46 -0600 )edit

Then you should invest the effort to refactor your code into modules that can be deployed by r10k. Your monolithic code base is your real problem, not your references to environments in your file paths.

lavaman gravatar imagelavaman ( 2016-12-19 18:53:35 -0600 )edit

Also, $environment is a variable that puppet has defined in it's own scope, overriding that is not recommended. A talk from pconf 2013 by espn they had espn_env or some specific indicator to differentiate their own 'environment' from the puppet environment

DarylW gravatar imageDarylW ( 2016-12-20 09:37:53 -0600 )edit

I second lavaman's suggestion above, the monolithic install is part of the problem. the r10k workflow does feel a bit 'inside out' to me, I like the workflow used in where he used r10k to 'build' the env..

DarylW gravatar imageDarylW ( 2016-12-20 09:39:46 -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


Asked: 2016-12-19 10:27:05 -0600

Seen: 75 times

Last updated: Dec 19 '16