- From: Benoit Caron <
>
- To: Adam Jacob <
>
- Cc:
- Subject: [chef] Re: Environment-specific Data bag?
- Date: Wed, 19 Oct 2011 13:00:40 -0400
Yes, its exactly what I'm doing.
I'm using the node.chef_environment to get the correct version of my applications to release.
But when retrofitting one of my first cookbooks where I had:
{
"id": "appname",
"releases": { "releasename": "git-tag", "releasename2": "another-git-tag"}
}
to
{
"id": "appname",
"releases": {
"production": { "releasename": "git-tag", "releasename2": "another-git-tag"},
"dev": { "releasename": "git-tag", "releasename2": "master"},
}
I had to break the structure; I could have just add another entry (say "releasesversion"), but I would not have had to do this if databag could be sticked to an environment.
But then, I'm not sure if having attributes defined in a roles would not be better. Of course, with data bag it's easier to build tools to allow non-technical people be able to push releases.
Anyway, thanks for the clarification!
On Wed, Oct 19, 2011 at 12:13 PM, Adam Jacob
<
">
> wrote:
You can do this just by changing the structure of the items to include the environment as a top level key:
{
"id": "paths"
"production": { "path": "/usr/local" },
"dev": { "path": "/usr/local"}
}
So when you de-reference it:
i = Chef::DataBagItem('bagname', 'paths')
i[node.chef_environment]["path"]
Best,
Adam
On Oct 19, 2011, at 8:40 AM, Benoit Caron wrote:
> Is it possible to have different values in a data bag per environment?
>
> I find it tricky to change something in the structure of a data bag: I can test the cookbook changes in my dev environment, but pushing the databag to my chef-server makes it available to the production nodes, which don't know about the change.
>
> This could also be a way to have different values for the respective environments (like say, a different path, IP address, etc.).
>
> Or am I using the data bag incorrectly?
>
> Benoit
Archive powered by MHonArc 2.6.16.