Skip to content

Instantly share code, notes, and snippets.

@jtimberman
Last active February 5, 2020 18:31
Show Gist options
  • Save jtimberman/7471348 to your computer and use it in GitHub Desktop.
Save jtimberman/7471348 to your computer and use it in GitHub Desktop.
displays whether cookbooks are frozen on the chef server for a given version. put this in ~/.chef/plugins/knife.
#
# Author: Joshua Timberman <joshua@opscode.com>
# Copyright (c) 2013, Opscode, Inc <legal@opscode.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# displays whether cookbooks are frozen on the chef server for a given
# version.
require 'chef/knife'
module KnifePlugins
class Cbfrozen < Chef::Knife
banner "knife cbfrozen [COOKBOOK] [VERSION]"
def run
if @name_args.size == 0
rest.get_rest("cookbooks").each_pair do |cookbook, an_hash|
ui.output "#{cookbook}: #{cookbook_frozen(cookbook)}"
end
else
cookbook_name = @name_args[0]
cookbook_version = @name_args.length > 1 ? @name_args[1] : '_latest'
ui.output "#{cookbook_name}: #{cookbook_frozen(cookbook_name, cookbook_version)}"
end
end
def cookbook_frozen(cb, ver = '_latest')
rest.get_rest("cookbooks/#{cb}/#{ver}").frozen_version?
end
end
end
@ls-brentsmith
Copy link

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment