knife-zero 1.9.2 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22e6e86fa94daaa9c448d457064d019fce563dd6
4
- data.tar.gz: 3c5b8f78180ce1cf06fd1376f45c5a4bc0e06a7f
3
+ metadata.gz: 7f80ea294ea06067b3b8d8983f72592203be44e7
4
+ data.tar.gz: 77129a118ff5d6b8b803693d2c2cbd476e2ce3e9
5
5
  SHA512:
6
- metadata.gz: 5e0dc596b82124a4a478ec81f45a4a24e79cffe04422ce0b1f2e1c2a23c4c3b6c91cd28c9296b53c0f52795655333fc2d338b43fabb5534b660c190e5b663977
7
- data.tar.gz: 51ddf8d0e3e4b33104f7593f9b1dcefba73481f84e691238c4c2fbf16e5feae1151c72af48b800399d7694f55aa367afdc6e5355c34b471a413fa692db8afd49
6
+ metadata.gz: b34d72aef351bba43aeb8dc8ac013aa6d7982b5d2017f106797826d50688c05d84b6afc499155005eb41a3f7f4ee9f0d457d0b1d5da746b1c045aca8eb4c4bb0
7
+ data.tar.gz: 8a002267e5bd8ecc761e32fc24399a5c0beb9721f4f33d96e77d3246695f095bce1685122c5672e0f1f12f50b05f509cbb49361115071573dce5dc8df798f77b
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## v1.10.0
6
+
7
+ - Feature: Add new option `--client-version [latest|VERSION]` for reinstall chef-client.
8
+
5
9
  ## v1.9.2
6
10
 
7
11
  - Monkey: include Fixed host parsing to work with ipv6 addresses net-ssh/net-ssh-multi#9
@@ -1,6 +1,7 @@
1
1
  require 'chef/knife'
2
2
  require 'chef/knife/zero_base'
3
3
  require 'knife-zero/bootstrap_ssh'
4
+ require 'knife-zero/helper'
4
5
 
5
6
  class Chef
6
7
  class Knife
@@ -33,6 +34,18 @@ class Chef
33
34
  :default => nil,
34
35
  :proc => lambda { |o| o.to_s }
35
36
 
37
+ option :client_version,
38
+ :long => "--client-version [latest|VERSION]",
39
+ :description => "Up or downgrade omnibus chef-client before converge.",
40
+ :default => nil,
41
+ :proc => lambda { |o|
42
+ if ::Knife::Zero::Helper.chef_version_available?(o)
43
+ o.to_s
44
+ else
45
+ ui.error "Client version #{o} is not found."
46
+ exit 1
47
+ end
48
+ }
36
49
 
37
50
  def initialize(argv=[])
38
51
  super
@@ -11,6 +11,11 @@ class Chef
11
11
 
12
12
  def ssh_command(command, subsession=nil)
13
13
  begin
14
+
15
+ if config[:client_version]
16
+ super(%Q{/opt/chef/embedded/bin/ruby -ropen-uri -e 'puts open("https://chef.sh").read' | sudo sh -s -- -v #{config[:client_version]}})
17
+ end
18
+
14
19
  chef_zero_port = config[:chef_zero_port] ||
15
20
  Chef::Config[:knife][:chef_zero_port] ||
16
21
  URI.parse(Chef::Config.chef_server_url).port
@@ -1,3 +1,5 @@
1
+ require 'open-uri'
2
+
1
3
  module Knife
2
4
  module Zero
3
5
  module Helper
@@ -8,6 +10,19 @@ module Knife
8
10
  8889
9
11
  chef_zero_port + 10000
10
12
  end
13
+
14
+ def self.chef_version_available?(version)
15
+ return true if version == 'latest'
16
+ chefgem_metaurl = 'https://rubygems.org/api/v1/versions/chef.json'
17
+ begin
18
+ c_versions = JSON.parse(open(chefgem_metaurl).read).map {|v| v['number']}
19
+ c_versions.include?(version)
20
+ rescue => e
21
+ puts e.inspect
22
+ puts "Some Error occurerd while fetching versions from #{chefgem_metaurl}. Please try again later."
23
+ exit
24
+ end
25
+ end
11
26
  end
12
27
  end
13
28
  end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Zero
3
- VERSION = "1.9.2"
3
+ VERSION = "1.10.0"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-zero
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.2
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sawanoboly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-11 00:00:00.000000000 Z
11
+ date: 2015-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler