Reputation: 999
I am fairly new to chef and I'm looking for the correct way to upgrade java versions on our chef managed servers.
I have 3 chef managed playground environments (P1, P2, and P3) Normally they are kept the same. except when doing some upgrade like a DB or java upgrade
for each of the environments: The version of the cookbooks are normally identical in P1, P2, and P3. Usually if I update a cookbook, chef normally applies the cookbook change to all 3 environments. I need to apply the change just to the servers in P1.
How do I tell chef to apply the new version of the java cookbook only to the P1 environment?
Upvotes: 1
Views: 218
Reputation: 92
Java version can be specified by using an override attribute in your environment file.
"override_attributes": {
"java": {
"jdk_version": "8"
}
}
Upvotes: 0
Reputation: 37580
You can restrict the cookbook versions that are used per environment using the cookbook_versions
.
While "unpinned" (not restricted) in P1, you add the following to the other two environment definitions:
cookbook_versions({
'java' => '< 2.0.0'
})
This would restrict these environments to 1.x.y
versions of your java
cookbook. If everything works out, you release that version constraint by removing it from the other environments.
Optionally, become familiar with the environment cookbook pattern, which might be overkill for many of us, but IMHO provides a good impression of how an advanced workflow could look like.
Further, the relatively new concept of Policyfiles should also provide you means to solve that problem.
Upvotes: 3