Ask Your Question

How to alter a resource definition based on environment

asked 2014-01-13 13:32:30 -0600

jaksky gravatar image


I would be curious what is the best approach to alter a resource definition based on environment which is under the puppet control. Let me describe the use case in more detail. Suppose that we have an internal repository for a distribution of our artefacts e.g. rpm packages. For good reason we have a production environment completely separated. That means we have a different production internal repository just in case we run our manifests in production. We would like to run the same manifests in all environments without need of manual change as we want to minimize possible ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-01-14 08:22:09 -0600

wernerbahlke gravatar image


You might want to look at hiera to set variables based on environment. In your hiera file you would select based on an environment (development or production, for example) and then you need to set an environment variable. We do this through the PE console, I guess Foreman could do it too. Otherwise you might have to build a custom fact.

In your manifest you do simple $internalRepository = hiera('internalRepository) and you should get the value based on environment.

edit flag offensive delete link more


Hi I was also considering custom fact but it is not clear to me how the custom fact mechanics works. I do understand that new fact value is available but ...(more)

jaksky gravatar imagejaksky ( 2014-01-16 15:11:26 -0600 )edit

If your built your custom fact correctly it will automatically get loaded on execution of the module which includes it.

wernerbahlke gravatar imagewernerbahlke ( 2014-01-17 11:49:19 -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: 2014-01-13 13:32:30 -0600

Seen: 71 times

Last updated: Jan 14 '14