knife-solo 0.3.0.pre1 → 0.3.0.pre2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,23 @@
1
1
  # 0.3.0: _In progress_
2
2
 
3
+ ## Changes and new features
4
+
5
+ * Moved root path configuration into `knife[:solo_path]` and use $HOME/chef-solo by default (#197)
6
+ * `--prerelease` option to allow pre-release versions of chef omnibus or rubygem to be installed (#205)
7
+ * Prepare/bootstrap now installs the same version of Chef that the workstation is running (#186)
8
+ * Switch `--omnibus-version` flag to `--bootstrap-version` (#185)
9
+ * Support --override-runlist option (#204)
10
+
11
+ ## Fixes
12
+
13
+ * FreeBSD 9.1 support
14
+ * Clear yum cache before installing rsync (#200)
15
+
16
+ ## Thanks to our contributors!
17
+
18
+ * [David Kinzer][dkinzer]
19
+ * [Naoya Ito][naoya]
20
+
3
21
  # 0.2.0: February 12, 2013
4
22
 
5
23
  ## Changes and new features
@@ -276,3 +294,5 @@ And a special thanks to [Teemu Matilainen][tmatilai] who is now on the list of d
276
294
  [tmatilai]: https://github.com/tmatilai
277
295
  [vjpr]: https://github.com/vjpr
278
296
  [zeph]: https://github.com/zeph
297
+ [dkinzer]: https://github.com/dkinzer
298
+ [naoya]: https://github.com/naoya
@@ -51,6 +51,11 @@ class Chef
51
51
  :long => '--why-run',
52
52
  :description => 'Enable whyrun mode'
53
53
 
54
+ option :override_runlist,
55
+ :short => '-o RunlistItem,RunlistItem...,',
56
+ :long => '--override-runlist',
57
+ :description => 'Replace current run list with specified items'
58
+
54
59
  def run
55
60
  @solo_config = KnifeSolo::Config.new
56
61
 
@@ -85,6 +90,22 @@ class Chef
85
90
  @chefignore ||= ::Chef::Cookbook::Chefignore.new("./")
86
91
  end
87
92
 
93
+ # cygwin rsync path must be adjusted to work
94
+ def adjust_rsync_path(path)
95
+ path_s = path.to_s
96
+ path_s.gsub(/^(\w):/) { "/cygdrive/#{$1}" }
97
+ end
98
+
99
+ def adjust_rsync_path_on_node(path)
100
+ return path unless windows_node?
101
+ adjust_rsync_path(path)
102
+ end
103
+
104
+ def adjust_rsync_path_on_client(path)
105
+ return path unless windows_client?
106
+ adjust_rsync_path(path)
107
+ end
108
+
88
109
  # see http://stackoverflow.com/questions/5798807/rsync-permission-denied-created-directories-have-no-permissions
89
110
  def rsync_permissions
90
111
  '--chmod=ugo=rwX' if windows_client?
@@ -138,7 +159,7 @@ class Chef
138
159
  end
139
160
 
140
161
  def rsync(source_path, target_path, extra_opts = '')
141
- cmd = %Q|rsync -rl #{rsync_permissions} --rsh="ssh #{ssh_args}" #{extra_opts} #{rsync_excludes.collect{ |ignore| "--exclude #{ignore} " }.join} #{source_path} :#{target_path}|
162
+ cmd = %Q{rsync -rl #{rsync_permissions} --rsh="ssh #{ssh_args}" #{extra_opts} #{rsync_excludes.collect{ |ignore| "--exclude #{ignore} " }.join} #{adjust_rsync_path_on_client(source_path)} :#{adjust_rsync_path_on_node(target_path)}}
142
163
  ui.msg cmd if debug?
143
164
  system! cmd
144
165
  end
@@ -161,6 +182,7 @@ class Chef
161
182
  cmd << " -l debug" if debug?
162
183
  cmd << " -N #{config[:chef_node_name]}" if config[:chef_node_name]
163
184
  cmd << " -W" if config[:why_run]
185
+ cmd << " -o #{config[:override_runlist]}" if config[:override_runlist]
164
186
 
165
187
  result = stream_command cmd
166
188
  raise "chef-solo failed. See output above." unless result.success?
@@ -18,6 +18,15 @@ class Chef
18
18
 
19
19
  banner "knife solo prepare [USER@]HOSTNAME [JSON] (options)"
20
20
 
21
+ option :bootstrap_version,
22
+ :long => '--bootstrap-version VERSION',
23
+ :description => 'The version of Chef to install',
24
+ :proc => lambda {|v| Chef::Config[:knife][:bootstrap_version] = v}
25
+
26
+ option :prerelease,
27
+ :long => '--prerelease',
28
+ :description => 'Install the pre-release Chef version'
29
+
21
30
  option :omnibus_url,
22
31
  :long => '--omnibus-url URL',
23
32
  :description => 'URL to download install.sh from'
@@ -28,11 +37,12 @@ class Chef
28
37
 
29
38
  option :omnibus_version,
30
39
  :long => '--omnibus-version VERSION',
31
- :description => 'The version of Omnibus to install'
40
+ :description => 'Deprecated. Replaced with --bootstrap-check.'
32
41
 
33
42
  def run
34
43
  if config[:omnibus_version]
35
- config[:omnibus_options] = "#{config[:omnibus_options]} -v #{config[:omnibus_version]}".strip
44
+ ui.warn '`--omnibus-version` is deprecated, please use `--bootstrap-version`.'
45
+ Chef::Config[:knife][:bootstrap_version] = config[:omnibus_version]
36
46
  end
37
47
 
38
48
  validate!
@@ -52,6 +62,14 @@ class Chef
52
62
  def operating_system
53
63
  run_command('uname -s').stdout.strip
54
64
  end
65
+
66
+ def chef_version
67
+ if (v = Chef::Config[:knife][:bootstrap_version])
68
+ v.empty? ? nil : v
69
+ else
70
+ Chef::VERSION
71
+ end
72
+ end
55
73
  end
56
74
  end
57
75
  end
@@ -35,6 +35,10 @@ module KnifeSolo
35
35
  prepare.ui
36
36
  end
37
37
 
38
+ def chef_version
39
+ prepare.chef_version
40
+ end
41
+
38
42
  def prepare
39
43
  @prepare
40
44
  end
@@ -43,7 +47,7 @@ module KnifeSolo
43
47
  module InstallCommands
44
48
 
45
49
  def bootstrap!
46
- run_pre_bootstrap_checks()
50
+ run_pre_bootstrap_checks
47
51
  send("#{distro[:type]}_install")
48
52
  end
49
53
 
@@ -51,8 +55,9 @@ module KnifeSolo
51
55
  raise "implement distro detection for #{self.class.name}"
52
56
  end
53
57
 
58
+ # gems to install before chef
54
59
  def gem_packages
55
- raise "implement gem packages for #{self.class.name}"
60
+ []
56
61
  end
57
62
 
58
63
  def http_client_get_url(url, file)
@@ -70,12 +75,24 @@ module KnifeSolo
70
75
  file = File.basename(url)
71
76
  http_client_get_url(url, file)
72
77
 
73
- install_command = "sudo bash #{file} #{prepare.config[:omnibus_options]}"
78
+ install_command = "sudo bash #{file} #{omnibus_options}"
74
79
  stream_command(install_command)
75
80
  end
76
81
 
82
+ def omnibus_options
83
+ options = prepare.config[:omnibus_options] || ""
84
+ if prepare.config[:prerelease]
85
+ options << " -p"
86
+ elsif chef_version
87
+ options << " -v #{chef_version}"
88
+ end
89
+ options
90
+ end
91
+
77
92
  def yum_omnibus_install
78
93
  omnibus_install
94
+ # Avoid rsync not being found in package cache.
95
+ run_command("sudo yum clean all")
79
96
  # Make sure we have rsync on builds that don't include it by default
80
97
  # (for example Scientific Linux minimal, CentOS minimal)
81
98
  run_command("sudo yum -y install rsync")
@@ -99,7 +116,16 @@ module KnifeSolo
99
116
  run_command("tar zxf #{file}")
100
117
  run_command("cd #{release} && sudo ruby setup.rb --no-format-executable")
101
118
  run_command("sudo rm -rf #{release} #{file}")
102
- run_command("sudo gem install --no-rdoc --no-ri #{gem_packages().join(' ')}")
119
+ run_command("sudo gem install --no-rdoc --no-ri #{gem_packages.join(' ')}") unless gem_packages.empty?
120
+ run_command("sudo gem install --no-rdoc --no-ri chef #{gem_options}")
121
+ end
122
+
123
+ def gem_options
124
+ if prepare.config[:prerelease]
125
+ "--prerelease"
126
+ elsif chef_version
127
+ "--version #{chef_version}"
128
+ end
103
129
  end
104
130
  end #InstallCommands
105
131
 
@@ -5,10 +5,6 @@ module KnifeSolo::Bootstraps
5
5
  run_command("sw_vers -productVersion").stdout.strip
6
6
  end
7
7
 
8
- def gem_packages
9
- ['chef']
10
- end
11
-
12
8
  def distro
13
9
  case issue
14
10
  when %r{10.5}
@@ -4,10 +4,6 @@ module KnifeSolo::Bootstraps
4
4
  run_command("uname -sr").stdout.strip
5
5
  end
6
6
 
7
- def gem_packages
8
- ['chef']
9
- end
10
-
11
7
  def prepare_make_conf
12
8
  ui.msg "Preparing make.conf"
13
9
  run_command <<-EOF
@@ -47,7 +43,7 @@ module KnifeSolo::Bootstraps
47
43
  def distro
48
44
  return @distro if @distro
49
45
  case issue
50
- when %r{FreeBSD 9.0-RELEASE}
46
+ when %r{FreeBSD 9\.[01]}
51
47
  {:type => 'freebsd_port'}
52
48
  else
53
49
  raise "#{issue} not supported"
@@ -19,7 +19,7 @@ module KnifeSolo::Bootstraps
19
19
  end
20
20
 
21
21
  def gem_packages
22
- ['ruby-shadow','chef']
22
+ ['ruby-shadow']
23
23
  end
24
24
 
25
25
  def emerge_gem_install
@@ -1,6 +1,6 @@
1
1
  module KnifeSolo
2
2
  def self.version
3
- '0.3.0.pre1'
3
+ '0.3.0.pre2'
4
4
  end
5
5
 
6
6
  def self.post_install_message
@@ -6,7 +6,6 @@ class KnifeSolo::Bootstraps::StubOS < KnifeSolo::Bootstraps::Base
6
6
  end
7
7
 
8
8
  class KnifeSolo::Bootstraps::StubOS2 < KnifeSolo::Bootstraps::Base
9
- def gem_packages ; ['chef'] ; end
10
9
  def distro ; {:type => 'gem', :version => 'Fanny Faker'} ; end
11
10
  def gem_install
12
11
  # dont' actually install anything
@@ -15,19 +14,13 @@ end
15
14
 
16
15
  class BootstrapsTest < TestCase
17
16
  def test_bootstrap_class_exists_for
18
- assert_equal true, KnifeSolo::Bootstraps.class_exists_for?('Stub OS')
19
- assert_equal false, KnifeSolo::Bootstraps.class_exists_for?('Mythical OS')
17
+ assert KnifeSolo::Bootstraps.class_exists_for?('Stub OS')
18
+ refute KnifeSolo::Bootstraps.class_exists_for?('Mythical OS')
20
19
  end
21
20
 
22
21
  def test_distro_raises_if_not_implemented
23
22
  assert_raises RuntimeError do
24
- bootstrap_instance.distro()
25
- end
26
- end
27
-
28
- def test_gem_packages_raises_if_not_implemented
29
- assert_raises RuntimeError do
30
- bootstrap_instance.gem_packages()
23
+ bootstrap_instance.distro
31
24
  end
32
25
  end
33
26
 
@@ -47,8 +40,7 @@ class BootstrapsTest < TestCase
47
40
  def test_bootstrap_delegates_to_knife_prepare
48
41
  prepare = mock('chef::knife::prepare')
49
42
  bootstrap = KnifeSolo::Bootstraps::StubOS2.new(prepare)
50
-
51
- assert prepare == bootstrap.prepare
43
+ assert_equal prepare, bootstrap.prepare
52
44
  end
53
45
 
54
46
  def test_darwin_checks_for_xcode_install_and_barfs_if_missing
@@ -72,6 +64,7 @@ class BootstrapsTest < TestCase
72
64
  bootstrap = bootstrap_instance
73
65
  bootstrap.stubs(:distro).returns({:type => "omnibus"})
74
66
  bootstrap.stubs(:http_client_get_url)
67
+ bootstrap.stubs(:chef_version)
75
68
 
76
69
  options = "-v 10.16.4"
77
70
  matcher = regexp_matches(/\s#{Regexp.quote(options)}(\s|$)/)
@@ -81,10 +74,44 @@ class BootstrapsTest < TestCase
81
74
  bootstrap.bootstrap!
82
75
  end
83
76
 
77
+ def test_combines_omnibus_options
78
+ bootstrap = bootstrap_instance
79
+ bootstrap.prepare.stubs(:chef_version).returns("0.10.8-3")
80
+ bootstrap.prepare.stubs(:config).returns({:omnibus_options => "-s"})
81
+ assert_equal "-s -v 0.10.8-3", bootstrap.omnibus_options
82
+ end
83
+
84
+ def test_passes_prerelease_omnibus_version
85
+ bootstrap = bootstrap_instance
86
+ bootstrap.prepare.stubs(:chef_version).returns("10.18.3")
87
+ bootstrap.prepare.stubs(:config).returns({:prerelease => true})
88
+ assert_equal "-p", bootstrap.omnibus_options.strip
89
+ end
90
+
91
+ def test_passes_gem_version
92
+ bootstrap = bootstrap_instance
93
+ bootstrap.prepare.stubs(:chef_version).returns("10.16.4")
94
+ assert_equal "--version 10.16.4", bootstrap.gem_options
95
+ end
96
+
97
+ def test_passes_prereleaes_gem_version
98
+ bootstrap = bootstrap_instance
99
+ bootstrap.prepare.stubs(:chef_version).returns("10.18.1")
100
+ bootstrap.prepare.stubs(:config).returns({:prerelease => true})
101
+ assert_equal "--prerelease", bootstrap.gem_options
102
+ end
103
+
104
+ def test_wont_pass_unset_gem_version
105
+ bootstrap = bootstrap_instance
106
+ bootstrap.prepare.stubs(:chef_version).returns(nil)
107
+ assert_equal "", bootstrap.gem_options.to_s
108
+ end
109
+
84
110
  # ***
85
111
 
86
112
  def bootstrap_instance
87
113
  prepare = mock('Knife::Chef::SoloPrepare')
114
+ prepare.stubs(:config).returns({})
88
115
  KnifeSolo::Bootstraps::StubOS.new(prepare)
89
116
  end
90
117
  end
@@ -8,7 +8,7 @@ module Apache2Bootstrap
8
8
 
9
9
  def test_apache2
10
10
  write_cheffile
11
- assert_subcommand "bootstrap --run-list=recipe[apache2] #{omnibus_options}"
11
+ assert_subcommand "bootstrap --run-list=recipe[apache2]"
12
12
  assert_match default_apache_message, http_response
13
13
  end
14
14
  end
@@ -122,6 +122,10 @@ class SoloCookTest < TestCase
122
122
  assert_chef_solo_option "--why-run", "-W"
123
123
  end
124
124
 
125
+ def test_passes_override_runlist_to_chef_solo
126
+ assert_chef_solo_option "--override-runlist=sandbox::default", "-o sandbox::default"
127
+ end
128
+
125
129
  # Asserts that the chef_solo_option is passed to chef-solo iff cook_option
126
130
  # is specified for the cook command
127
131
  def assert_chef_solo_option(cook_option, chef_solo_option)
@@ -12,17 +12,24 @@ class SoloPrepareTest < TestCase
12
12
  @host = 'someuser@somehost.domain.com'
13
13
  end
14
14
 
15
- def test_combines_omnibus_options
16
- in_kitchen do
17
- bootstrap_instance = mock('mock OS bootstrap instance')
18
- bootstrap_instance.stubs(:bootstrap!)
15
+ def test_uses_local_chef_version_by_default
16
+ Chef::Config[:knife][:bootstrap_version] = nil
17
+ assert_equal Chef::VERSION, command.chef_version
18
+ end
19
19
 
20
- run_command = command(@host, "--omnibus-version", "0.10.8-3", "--omnibus-options", "-s")
21
- run_command.stubs(:bootstrap).returns(bootstrap_instance)
22
- run_command.run
20
+ def test_uses_chef_version_from_knife_config
21
+ Chef::Config[:knife][:bootstrap_version] = "10.12.2"
22
+ assert_equal "10.12.2", command.chef_version
23
+ end
23
24
 
24
- assert_match "-s -v 0.10.8-3", run_command.config[:omnibus_options]
25
- end
25
+ def test_uses_chef_version_from_command_line_option
26
+ Chef::Config[:knife][:bootstrap_version] = "10.16.2"
27
+ assert_equal "0.4.2", command("--bootstrap-version", "0.4.2").chef_version
28
+ end
29
+
30
+ def test_chef_version_returns_nil_if_empty
31
+ Chef::Config[:knife][:bootstrap_version] = "10.12.2"
32
+ assert_nil command("--bootstrap-version", "").chef_version
26
33
  end
27
34
 
28
35
  def test_run_raises_if_operating_system_is_not_supported
@@ -72,14 +72,7 @@ class IntegrationTest < TestCase
72
72
 
73
73
  # The prepare command to use on this server
74
74
  def prepare_command
75
- "prepare #{omnibus_options}"
76
- end
77
-
78
- def omnibus_options
79
- return "" if ENV['CHEF_VERSION'].to_s.empty?
80
-
81
- v = `knife --version`.split(':')
82
- v[0].strip == 'Chef' ? "--omnibus-version=#{v[1].strip}" : ''
75
+ "prepare"
83
76
  end
84
77
 
85
78
  # Provides the path to the runner's key file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-solo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre1
4
+ version: 0.3.0.pre2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-12 00:00:00.000000000 Z
12
+ date: 2013-02-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -274,6 +274,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
274
274
  - - ! '>='
275
275
  - !ruby/object:Gem::Version
276
276
  version: '0'
277
+ segments:
278
+ - 0
279
+ hash: -3096439346196899405
277
280
  required_rubygems_version: !ruby/object:Gem::Requirement
278
281
  none: false
279
282
  requirements: