Hi,
I would like to enforce certain cookbook version requirements on
cookbooks in different environments from within a recipe.
i.e. All cookbooks on “production” environment must have an even minor
version. (i.e. 10.0.2 is valid but 10.0.3 is not). I also want to
require that cookbooks be locked or not. (i.e. cookbook referenced in
production environments must be frozen).
Doing something like
node.run_list.expand(node.chef_environment).recipes.with_versions.each
do |recipe|
p recipe
end
will only include the versions if they have been explicitly set and
will not allow me to check to see if the version is locked.
Anyone have a good idea how to do this?
–
Cheers,
Peter Donald
Why don't you use environments built in cookbook version locking for
this, instead of trying to do it from a recipe?
You can make 'freeze' the default by chucking it in your knife.rb
http://wiki.opscode.com/display/chef/Environments#Environments-cookbookversions
Cheers,
--AJ
On 8 February 2012 15:36, Peter Donald peter@realityforge.org wrote:
Hi,
I would like to enforce certain cookbook version requirements on
cookbooks in different environments from within a recipe.
i.e. All cookbooks on "production" environment must have an even minor
version. (i.e. 10.0.2 is valid but 10.0.3 is not). I also want to
require that cookbooks be locked or not. (i.e. cookbook referenced in
production environments must be frozen).
Doing something like
node.run_list.expand(node.chef_environment).recipes.with_versions.each
do |recipe|
p recipe
end
will only include the versions if they have been explicitly set and
will not allow me to check to see if the version is locked.
Anyone have a good idea how to do this?
--
Cheers,
Peter Donald
Hi,
I guess I wasn't exactly clear
On Wed, Feb 8, 2012 at 1:41 PM, AJ Christensen aj@junglist.gen.nz wrote:
Why don't you use environments built in cookbook version locking for
We do this to a small degree atm but want to do it across the board.
Each environment should lock the cookbooks to a particular version.
Each environment (with the exception? of development) should only
reference frozen cookbooks.
this, instead of trying to do it from a recipe?
What I want to do from the recipe is enforce that the above rules are
followed. I have a recipe that runs at the start of every run that
checks some assumptions. If any of these assumptions fail the the
chef run aborts.
--
Cheers,
Peter Donald
Interested to hear if people have a way to do this, but what I've
heard people do is instead have a post-commit hook on your revision
control that pushes to the server in only the ways you want and then
prevent people from uploading to the server manually to force them
through revision control and thus your other limitations.
KC
On Tue, Feb 7, 2012 at 6:52 PM, Peter Donald peter@realityforge.org wrote:
Hi,
I guess I wasn't exactly clear
On Wed, Feb 8, 2012 at 1:41 PM, AJ Christensen aj@junglist.gen.nz wrote:
Why don't you use environments built in cookbook version locking for
We do this to a small degree atm but want to do it across the board.
Each environment should lock the cookbooks to a particular version.
Each environment (with the exception? of development) should only
reference frozen cookbooks.
this, instead of trying to do it from a recipe?
What I want to do from the recipe is enforce that the above rules are
followed. I have a recipe that runs at the start of every run that
checks some assumptions. If any of these assumptions fail the the
chef run aborts.
--
Cheers,
Peter Donald
Hi,
I eventually got around to looking at this and have started to verify
that all cookbooks are frozen and have an explicit version if they are
not in the development environment. I have put the basics of it in a
gist for any one who is curious...
https://gist.github.com/2048310
On Wed, Feb 8, 2012 at 1:36 PM, Peter Donald peter@realityforge.org wrote:
Hi,
I would like to enforce certain cookbook version requirements on
cookbooks in different environments from within a recipe.
i.e. All cookbooks on "production" environment must have an even minor
version. (i.e. 10.0.2 is valid but 10.0.3 is not). I also want to
require that cookbooks be locked or not. (i.e. cookbook referenced in
production environments must be frozen).
Doing something like
node.run_list.expand(node.chef_environment).recipes.with_versions.each
do |recipe|
p recipe
end
will only include the versions if they have been explicitly set and
will not allow me to check to see if the version is locked.
Anyone have a good idea how to do this?
--
Cheers,
Peter Donald
--
Cheers,
Peter Donald