chef-solo-wrapper 0.0.5 → 0.0.6

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.
Files changed (3) hide show
  1. data/bin/cs +16 -13
  2. data/lib/config_helper.rb +24 -11
  3. metadata +3 -3
data/bin/cs CHANGED
@@ -16,7 +16,7 @@
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
18
 
19
- CHEF_SOLO_WRAPPER_VERSION = '0.0.5'
19
+ CHEF_SOLO_WRAPPER_VERSION = '0.0.6'
20
20
  COOKBOOKS_SRC_DEST = '/usr/src/chef-cookbooks'
21
21
 
22
22
  require 'rubygems'
@@ -147,7 +147,6 @@ end
147
147
 
148
148
  # when a rs server is specified
149
149
  if opts[:server]
150
-
151
150
  # import rest_connection
152
151
  puts 'Importing RestConnection RubyGem.' unless !opts.verbose
153
152
  require 'rest_connection'
@@ -193,9 +192,9 @@ if opts[:server]
193
192
  end
194
193
  }
195
194
  puts " DEBUG:\n#{p server_attributes}" unless !opts.debug
196
-
197
195
  end
198
196
 
197
+ # merge attributes
199
198
  if server_attributes
200
199
  puts server_attributes.to_json
201
200
  puts ' DEBUG: Merging attributes.' unless !opts.debug
@@ -204,19 +203,22 @@ else
204
203
  puts ' DEBUG: No server attributes to merge.' unless !opts.debug
205
204
  end
206
205
 
207
- if opts.run
208
- # override runlist
209
- attributes['run_list'] = "#{opts.run}"
206
+ # override runlist
207
+ if opts[:run]
208
+ attributes['run_list'] = "#{opts[:run]}"
210
209
  end
211
210
 
212
211
  # write attributes back to local node.json
213
- if opts.write and server_attributes
212
+ if opts[:write] and server_attributes
214
213
  node_json = JSON.pretty_generate(attributes)
215
- puts "Node Attributes: \n #{node_json}" unless !opts.debug
216
- # open file for write back
217
- fh = File.new(node_file, "w")
218
- fh.write(node_json)
219
- fh.close
214
+ puts " DEBUG: Node Attributes: \n #{node_json}" if opts[:debug]
215
+ puts " DEBUG: Writing attributes to #{json_file}" if opts[:debug]
216
+ begin
217
+ # open file for write back
218
+ fh = File.new(json_file, "w")
219
+ fh.write(node_json)
220
+ fh.close
221
+ end
220
222
  end
221
223
 
222
224
  # pre append options
@@ -225,6 +227,7 @@ chef_json = " -j #{opts[:json]}" if opts[:json]
225
227
 
226
228
  # set the chef-solo command depending if rs sandbox
227
229
  if opts[:sandbox]
230
+ puts ' DEBUG: Using sandbox ruby/chef.' if opts[:debug]
228
231
  cs = '/opt/rightscale/sandbox/bin/ruby /opt/rightscale/sandbox/bin/chef-solo'
229
232
  else
230
233
  cs = 'chef-solo'
@@ -245,7 +248,7 @@ if Process.uid != 0
245
248
  end
246
249
 
247
250
  # finally, run chef-solo
248
- puts 'Starting Chef Solo.' unless !(opts.verbose || opts.debug)
251
+ puts 'Starting Chef Solo.' unless !(opts[:verbose] || opts[:debug])
249
252
  unless opts[:dry]
250
253
  system(cmd)
251
254
  else
data/lib/config_helper.rb CHANGED
@@ -30,18 +30,31 @@ class ConfigHelper
30
30
  def install_chef
31
31
  puts
32
32
  puts '=> Setting up Chef Solo.'
33
- puts 'Installing Chef RubyGem...'
34
- gem = 'chef'
35
- begin
36
- puts "#{gem} already installed, version: #{Gem::Specification.find_by_name(gem).version}."
37
- rescue Gem::LoadError
38
- install_gem(gem)
39
- rescue
40
- install_gem(gem) unless Gem.available?(gem)
41
- rescue
42
- raise 'Failed to install Chef Rubygem!'
33
+ case "#{`lsb_release -si`.strip}"
34
+ when 'Ubuntu'
35
+ puts 'Ubuntu detected; installing from opscode apt.'
36
+ system("DEBIAN_FRONTEND=noninteractive")
37
+ system("sudo mkdir -p /etc/apt/trusted.gpg.d")
38
+ system("gpg --keyserver keys.gnupg.net --recv-keys 83EF826A")
39
+ system("gpg --export packages@opscode.com | sudo tee /etc/apt/trusted.gpg.d/opscode-keyring.gpg > /dev/null")
40
+ system('echo "deb http://apt.opscode.com/ $(lsb_release -cs)-0.10 main" > /etc/apt/sources.list.d/opscode.list')
41
+ system("sudo apt-get -y update")
42
+ system("sudo apt-get -y upgrade")
43
+ system("sudo apt-get -y install chef")
44
+ exit
45
+ else
46
+ puts 'Installing Chef RubyGem...'
47
+ gem = 'chef'
48
+ begin
49
+ puts "#{gem} already installed, version: #{Gem::Specification.find_by_name(gem).version}."
50
+ rescue Gem::LoadError
51
+ install_gem(gem)
52
+ rescue
53
+ install_gem(gem) unless Gem.available?(gem)
54
+ rescue
55
+ raise 'Failed to install Chef Rubygem!'
56
+ end
43
57
  end
44
- puts
45
58
  end
46
59
 
47
60
  def setup_solo_rb(file, auto=@setup_defaults)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-solo-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chris Fordham