From 59ae275b6ed65cf6ac3d594f939bfef625548c26 Mon Sep 17 00:00:00 2001 From: whitestar Date: Mon, 17 Jul 2017 10:05:20 +0900 Subject: [PATCH] adds the Chef version pinning feature for the Debian family. --- cookbooks/chef_utils/.rubocop.yml | 8 +++++++- cookbooks/chef_utils/Rakefile | 6 +++++- cookbooks/chef_utils/metadata.rb | 9 ++++++++- cookbooks/chef_utils/recipes/chef-client.rb | 12 ++++++++++++ .../templates/default/etc/apt/preferences.d/chef.pref | 3 +++ cookbooks/chef_utils/version | 1 + 6 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 cookbooks/chef_utils/templates/default/etc/apt/preferences.d/chef.pref create mode 100644 cookbooks/chef_utils/version diff --git a/cookbooks/chef_utils/.rubocop.yml b/cookbooks/chef_utils/.rubocop.yml index 0314b29..394170e 100644 --- a/cookbooks/chef_utils/.rubocop.yml +++ b/cookbooks/chef_utils/.rubocop.yml @@ -23,6 +23,8 @@ Style/BlockDelimiters: Enabled: false Style/ExtraSpacing: Enabled: false +Style/EmptyCaseCondition: + Enabled: false Style/FileName: Enabled: false Style/LeadingCommentSpace: @@ -31,8 +33,12 @@ Style/RescueModifier: Enabled: false Style/SpaceBeforeFirstArg: Enabled: false +Style/SpaceInsideBlockBraces: + Enabled: false +Style/SpaceInsidePercentLiteralDelimiters: + Enabled: false Style/TrailingCommaInLiteral: - EnforcedStyleForMultiline: comma + EnforcedStyleForMultiline: consistent_comma Style/WordArray: Enabled: false diff --git a/cookbooks/chef_utils/Rakefile b/cookbooks/chef_utils/Rakefile index d60d1e4..88b7bcb 100644 --- a/cookbooks/chef_utils/Rakefile +++ b/cookbooks/chef_utils/Rakefile @@ -5,7 +5,11 @@ require 'stove/rake_task' namespace :style do desc 'Run Ruby style checks' - RuboCop::RakeTask.new(:ruby) + RuboCop::RakeTask.new(:ruby) do |t| + t.options = [ + '--auto-gen-config', # creates .rubocop_todo.yml + ] + end desc 'Run Chef style checks' FoodCritic::Rake::LintTask.new(:chef) do |t| diff --git a/cookbooks/chef_utils/metadata.rb b/cookbooks/chef_utils/metadata.rb index 593b47b..a7a8fbf 100644 --- a/cookbooks/chef_utils/metadata.rb +++ b/cookbooks/chef_utils/metadata.rb @@ -5,9 +5,16 @@ maintainer_email '' license 'Apache 2.0' description 'Installs/Configures chef_utils' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '0.8.1' +version IO.read(File.join(File.dirname(__FILE__), 'version')).chomp source_url 'http://scm.osdn.jp/gitroot/metasearch/grid-chef-repo.git' issues_url 'https://osdn.jp/projects/metasearch/ticket' +chef_version '>= 12' +%w( centos redhat ).each do |os| + supports os, '>= 7.0' +end +supports 'debian', '>= 8.0' +supports 'ubuntu', '>= 14.04' + depends 'build-essential' depends 'ssl_cert' diff --git a/cookbooks/chef_utils/recipes/chef-client.rb b/cookbooks/chef_utils/recipes/chef-client.rb index 42f8aad..081a429 100644 --- a/cookbooks/chef_utils/recipes/chef-client.rb +++ b/cookbooks/chef_utils/recipes/chef-client.rb @@ -31,6 +31,18 @@ omnitruck_installer_url = node['chef_utils']['chef-client']['omnitruck_installer expected_version = "[ \"$(chef-client -v | awk '{ print $2 }')\" = '#{version}' ]" status_file = '/tmp/install_chef-client_status' +# Pinning chef version +template '/etc/apt/preferences.d/chef.pref' do + source 'etc/apt/preferences.d/chef.pref' + owner 'root' + group 'root' + mode '0644' + variables( + pkg_name: 'chef' + ) + only_if { node['platform_family'] == 'debian' } +end + remote_file pkg_file_path do source release_url checksum file_checksum unless file_checksum.nil? diff --git a/cookbooks/chef_utils/templates/default/etc/apt/preferences.d/chef.pref b/cookbooks/chef_utils/templates/default/etc/apt/preferences.d/chef.pref new file mode 100644 index 0000000..1526ac2 --- /dev/null +++ b/cookbooks/chef_utils/templates/default/etc/apt/preferences.d/chef.pref @@ -0,0 +1,3 @@ +Package: <%= @pkg_name %> +Pin: version <%= node['chef_utils']['chef-client']['version'] %>* +Pin-Priority: 1001 diff --git a/cookbooks/chef_utils/version b/cookbooks/chef_utils/version new file mode 100644 index 0000000..100435b --- /dev/null +++ b/cookbooks/chef_utils/version @@ -0,0 +1 @@ +0.8.2 -- 2.11.0