knife-stackbuilder 0.5.5 → 0.5.6

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: d37ed80ef1cb53ed78edd9f6aaa36c040f3c1b58
4
- data.tar.gz: 5dffdd2a2ece7d841f14ee49a96a9339ff63cbb9
3
+ metadata.gz: 209a8ea8c3e0ab99bbe754f70003ed242e435052
4
+ data.tar.gz: 7e17e996e03499a4e9c7432ccd7354780d392b7f
5
5
  SHA512:
6
- metadata.gz: 86517b2af9acd7742908d48aef39a8a88d2642db9320110a933e5b5f2afbf0fc8c04a12ea96411e7c643fb1393d23b83c565d0935615665327f70992f00d47ca
7
- data.tar.gz: 50fd131a84aeecca06ba2f826a6beac455140e03e4a7de0dd1f8ac557be818bbe00d30ec5cf4df07b3da57f8f91063fa1bfcfc378cc1e10dc811723d96a1c1cf
6
+ metadata.gz: 65bc78b0ed9f4ae0a8a27f95734f5c3b84632c6d39188d8e3025e692051f43b04e2dd973e485308e89be641b7aa4d28dc616bcc3d40cc8852fb231a571d6cfcc
7
+ data.tar.gz: d5b245863b3a171884b481668482de92bdddcb49d10a36bdbf1db48d00093237c520fe44c9318edffbc33742460adbcfde0ba73186f8ba2e877d49825113a15e
@@ -56,8 +56,11 @@ class Chef
56
56
  repo_path = getConfig(:repo_path)
57
57
  environment = getConfig(:environment) || '_default'
58
58
 
59
+ stack_id = getConfig(:stack_id) || ENV['STACK_ID']
60
+ stack_overrides = getConfig(:overrides) || ENV['STACK_OVERRIDES']
61
+
59
62
  stack_file = name_args.first
60
- if stack_file=~/[-_+=.0-9a-zA-Z]+/
63
+ if stack_file=~/^[-_+=.0-9a-zA-Z]+$/
61
64
  stack_file = Dir.getwd + '/' + stack_file + (stack_file.end_with?('.yml') ? '' : '.yml')
62
65
  end
63
66
  unless File.exist?(stack_file)
@@ -78,9 +81,6 @@ class Chef
78
81
  repo = StackBuilder::Chef::Repo.new(repo_path)
79
82
  repo.upload_environments(environment)
80
83
 
81
- stack_id = getConfig(:stack_id) || ENV['STACK_ID']
82
- stack_overrides = getConfig(:overrides) || ENV['STACK_OVERRIDES']
83
-
84
84
  stack = StackBuilder::Stack::Stack.new(
85
85
  provider,
86
86
  stack_file,
@@ -100,13 +100,14 @@ class Chef
100
100
  end
101
101
 
102
102
  stack.orchestrate(events, node_name, node_scale)
103
+ stack_id = stack.id
103
104
  end
104
105
 
105
106
  ensure
106
107
  time_elapsed = Time.now - time_start
107
108
 
108
- $stdout.printf( "\nStack build for '%s' took %d minutes and '%.3f' seconds\n",
109
- stack_file, time_elapsed/60, time_elapsed%60 ) if !getConfig(:show_stack_file)
109
+ $stdout.printf( "\nStack '%s' build using the '%s' template took %d minutes and '%.3f' seconds\n",
110
+ stack_id, stack_file, time_elapsed/60, time_elapsed%60 ) if !getConfig(:show_stack_file)
110
111
  end
111
112
  end
112
113
 
@@ -12,13 +12,13 @@ class Chef
12
12
  banner 'knife stack initialize repo (options)'
13
13
 
14
14
  option :repo_path,
15
- :long => "--repo_path REPO_PATH",
15
+ :long => "--repo-path REPO_PATH",
16
16
  :description => "The path where a skeleton Chef Berkshelf repo will be created. " +
17
17
  "If this is no provided the current working directory will be initialized.",
18
18
  :default => '.'
19
19
 
20
20
  option :cert_path,
21
- :long => "--cert_path CERT_PATH",
21
+ :long => "--cert-path CERT_PATH",
22
22
  :description => "Path containing folders with server certificates. Each folder " +
23
23
  "within this path should be named after the server for which the certs are " +
24
24
  "meant post-fixed by _{ENV_NAME}. If name is not post-fixed then the cert " +
@@ -29,8 +29,8 @@ class Chef
29
29
  :description => "Comma separated list of server names for which self-signed " +
30
30
  "certificates will be generated."
31
31
 
32
- option :envs,
33
- :long => "--stack_envs ENVIRONMENTS",
32
+ option :stack_environments,
33
+ :long => "--stack-environments ENVIRONMENTS",
34
34
  :description => "Comma separated list of environments to generate"
35
35
 
36
36
  option :cookbooks,
@@ -53,7 +53,7 @@ class Chef
53
53
  StackBuilder::Chef::Repo.new(
54
54
  getConfig(:repo_path),
55
55
  cert_path.nil? ? certs : cert_path,
56
- getConfig(:envs),
56
+ getConfig(:stack_environments),
57
57
  getConfig(:cookbooks) )
58
58
  end
59
59
  end
@@ -79,8 +79,9 @@ module StackBuilder::Chef
79
79
  envfile = ERB.new(envfile_template, nil, '-<>').result(binding)
80
80
  File.open("#{@repo_path}/environments/#{env_name}.rb", 'w+') { |f| f.write(envfile) }
81
81
 
82
+ @stack_name = 'stack' + i.to_s
82
83
  stackfile = ERB.new(stackfile_template, nil, '-<>').result(binding)
83
- File.open("#{@repo_path}/stack#{i}.yml", 'w+') { |f| f.write(stackfile) }
84
+ File.open("#{@repo_path}/#{@stack_name}.yml", 'w+') { |f| f.write(stackfile) }
84
85
  i += 1
85
86
  end
86
87
  @environment = nil
@@ -99,7 +100,10 @@ module StackBuilder::Chef
99
100
 
100
101
  # TODO: Handle JSON environment files. JSON files should be processed similar to roles.
101
102
 
102
- knife_cmd.name_args = [ "#{@repo_path}/environments/#{env_name}.rb" ]
103
+ env_file = "#{@repo_path}/environments/#{env_name}.rb"
104
+ FileUtils.touch(env_file)
105
+
106
+ knife_cmd.name_args = [ env_file ]
103
107
  run_knife(knife_cmd)
104
108
  puts "Uploaded environment '#{env_name}' to '#{Chef::Config.chef_server_url}'."
105
109
  end
@@ -138,10 +142,12 @@ module StackBuilder::Chef
138
142
 
139
143
  environments = (environment.nil? ? @environments : [ environment ])
140
144
  environments.each do |env_name|
145
+ FileUtils.touch("#{@repo_path}/environments/#{env_name}.rb")
141
146
  upload_certificate(server_cert_dir, server_name, env_name)
142
147
  end
143
148
 
144
149
  elsif environment.nil? || environment==server_env_name
150
+ FileUtils.touch("#{@repo_path}/environments/#{server_env_name}.rb")
145
151
  upload_certificate(server_cert_dir, server_name, server_env_name)
146
152
  end
147
153
  end
@@ -163,6 +169,8 @@ module StackBuilder::Chef
163
169
 
164
170
  environments.each do |env_name|
165
171
 
172
+ FileUtils.touch("#{@repo_path}/environments/#{env_name}.rb")
173
+
166
174
  data_bag_env = data_bag_name + '-' + env_name
167
175
  unless data_bag_list.include?(data_bag_env)
168
176
  knife_cmd = Chef::Knife::DataBagCreate.new
@@ -190,6 +198,8 @@ module StackBuilder::Chef
190
198
  berksfile_path = "#{@repo_path}/Berksfile"
191
199
  debug_flag = (@logger.debug? ? ' --debug' : '')
192
200
 
201
+ FileUtils.touch(Dir.glob("#{@repo_path}/environments/*.rb"))
202
+
193
203
  # Need to invoke Berkshelf from the shell as directly invoking it causes
194
204
  # cookbook validation to throw an exception when 'Berksfile.upload' is
195
205
  # called.
@@ -213,6 +223,8 @@ module StackBuilder::Chef
213
223
 
214
224
  def upload_roles(role = nil)
215
225
 
226
+ FileUtils.touch(Dir.glob("#{@repo_path}/environments/*.rb"))
227
+
216
228
  if role.nil?
217
229
  Dir["#{@repo_path}/roles/*.json"].each do |role_file|
218
230
  upload_role(role_file)
@@ -374,7 +386,8 @@ module StackBuilder::Chef
374
386
 
375
387
  knife_cmd = Chef::Knife::DataBagFromFile.new
376
388
  knife_cmd.name_args = [ data_bag_name, tmpfile ]
377
- knife_cmd.config[:secret] = get_secret(server_env_name)
389
+ knife_cmd.config[:encrypt] = true
390
+ Chef::Config[:knife][:secret] = get_secret(server_env_name)
378
391
  run_knife(knife_cmd)
379
392
 
380
393
  puts "Uploaded '#{server_env_name}' certificate for server '#{server_name}' " +
@@ -402,7 +415,8 @@ module StackBuilder::Chef
402
415
 
403
416
  knife_cmd = Chef::Knife::DataBagFromFile.new
404
417
  knife_cmd.name_args = [ data_bag_name, tmpfile ]
405
- knife_cmd.config[:secret] = secret
418
+ knife_cmd.config[:encrypt] = true
419
+ Chef::Config[:knife][:secret] = secret
406
420
  run_knife(knife_cmd)
407
421
 
408
422
  File.delete(tmpfile)
@@ -419,7 +433,7 @@ module StackBuilder::Chef
419
433
 
420
434
  def upload_role(role_file)
421
435
 
422
- role_content = eval_map_values(JSON.load(File.new(role_file, 'r')), ENV)
436
+ role_content = eval_map_values(JSON.load(File.new(role_file, 'r')).to_hash, ENV.to_hash)
423
437
 
424
438
  role_name = role_content.is_a?(Chef::Role) ? role_content.name : role_content['name']
425
439
  @logger.debug("Uploading role '#{role_name}' with contents:\n#{role_content.to_yaml}")
@@ -0,0 +1,156 @@
1
+ # Copyright (c) 2014 Mevan Samaratunga
2
+
3
+ include StackBuilder::Common::Helpers
4
+
5
+ module StackBuilder::Chef
6
+
7
+ class ContainerNodeManager < StackBuilder::Chef::NodeManager
8
+
9
+ def initialize(id, node_config, repo_path, environment)
10
+
11
+ super(id, node_config, repo_path, environment)
12
+
13
+ @env_file_path = repo_path + '/environments/' + environment + '.rb'
14
+
15
+ docker_image_dir = repo_path + '/.docker_images'
16
+ FileUtils.mkdir_p(docker_image_dir)
17
+ @docker_image_path = docker_image_dir + '/' + @name + '.gz'
18
+ end
19
+
20
+ def process(index, events, attributes, target = nil)
21
+
22
+ @@sync ||= Mutex.new
23
+ @@sync.synchronize {
24
+
25
+ unless @build_complete ||
26
+ (File.exist?(@docker_image_path) && File.exist?(@env_file_path) && \
27
+ File.mtime(@docker_image_path) > File.mtime(@env_file_path) )
28
+
29
+ if is_os_x? || !is_nix_os?
30
+
31
+ raise ArgumentError, "DOCKER_HOST environment variable not set." \
32
+ unless ENV['DOCKER_HOST']
33
+ raise ArgumentError, "DOCKER_CERT_PATH environment variable not set." \
34
+ unless ENV['DOCKER_CERT_PATH']
35
+ raise ArgumentError, "DOCKER_TLS_VERIFY environment variable not set." \
36
+ unless ENV['DOCKER_TLS_VERIFY']
37
+ end
38
+
39
+ begin
40
+ build_role = Chef::Role.new
41
+ build_role.name(@name + '_build')
42
+ build_role.override_attributes(attributes)
43
+ build_role.save
44
+
45
+ dockerfiles_path = File.join(Dir.home, '/.knife/container')
46
+
47
+ build_exists = @name==`docker images | awk '/#{@name}/ { print $1 }'`.strip
48
+
49
+ knife_cmd = Chef::Knife::ContainerDockerInit.new
50
+ knife_cmd.name_args = [ @name ]
51
+
52
+ knife_cmd.config[:local_mode] = false
53
+ knife_cmd.config[:base_image] = build_exists ? @name : @knife_config['image']
54
+ knife_cmd.config[:force] = true
55
+ knife_cmd.config[:generate_berksfile] = false
56
+ knife_cmd.config[:include_credentials] = false
57
+
58
+ knife_cmd.config[:dockerfiles_path] = dockerfiles_path
59
+ knife_cmd.config[:run_list] = @knife_config['run_list'] + [ "role[#{build_role.name}]" ]
60
+
61
+ knife_cmd.config[:encrypted_data_bag_secret] = IO.read(@env_key_file) \
62
+ unless File.exist? (@env_key_file)
63
+
64
+ run_knife(knife_cmd)
65
+
66
+ if @knife_config.has_key?('inline_dockerfile')
67
+
68
+ dockerfile_path = dockerfiles_path + "/#{@name}/Dockerfile"
69
+ docker_file = IO.read(dockerfile_path).lines
70
+
71
+ docker_file_new = [ ]
72
+ while docker_file.size>0
73
+ l = docker_file.delete_at(0)
74
+ docker_file_new << l
75
+ if l.start_with?('FROM ')
76
+ docker_file_new += @knife_config['inline_dockerfile'].lines.map { |ll| ll.strip + "\n" }
77
+ break
78
+ end
79
+ end
80
+ docker_file_new += docker_file
81
+
82
+ File.open(dockerfile_path, 'w+') { |f| f.write(docker_file_new.join) }
83
+ end
84
+
85
+ knife_cmd = Chef::Knife::ContainerDockerBuild.new
86
+ knife_cmd.name_args = [ @name ]
87
+
88
+ knife_cmd.config[:run_berks] = false
89
+ knife_cmd.config[:force_build] = true
90
+ knife_cmd.config[:dockerfiles_path] = dockerfiles_path
91
+ knife_cmd.config[:cleanup] = true
92
+
93
+ result = run_knife(knife_cmd)
94
+
95
+ ensure
96
+ build_role.destroy unless build_role.nil?
97
+ end
98
+
99
+ # TODO: Errors are currently not detected as knife-container sends all chef-client output to stdout
100
+ if result.rindex('Chef run process exited unsuccessfully (exit code 1)')
101
+
102
+ if @logger.level>=::Logger::WARN
103
+ puts "Knife execution failed with an error."
104
+ puts "#{result.string}"
105
+ end
106
+
107
+ `for i in $(docker ps -a | awk '/chef-in/ { print $1 }'); do docker rm -f $i; done`
108
+ `for i in $(docker images | awk '/<none>/ { print $3 }'); do docker rmi $i; done`
109
+
110
+ raise StackBuilderError, 'Container build has errors.'
111
+ end
112
+
113
+ `docker save #{@name} | gzip -9 > #{@docker_image_path}`
114
+ end
115
+ @build_complete = true
116
+ }
117
+
118
+ if @build_complete && !target.nil?
119
+
120
+ node = Chef::Node.load("#{target.node_id}-#{index}")
121
+ ipaddress = node.attributes['ipaddress']
122
+
123
+ if target.ssh_password.nil?
124
+ ssh = Net::SSH.start(ipaddress, target.ssh_user,
125
+ {
126
+ :key_data => IO.read(target.ssh_identity_file),
127
+ :user_known_hosts_file => "/dev/null"
128
+ } )
129
+ else
130
+ ssh = Net::SSH.start(ipaddress, target.ssh_user,
131
+ {
132
+ :password => target.ssh_password,
133
+ :user_known_hosts_file => "/dev/null"
134
+ } )
135
+ end
136
+
137
+ ssh.open_channel do |channel|
138
+
139
+ channel.exec('gunzip | sudo docker load') do |ch, success|
140
+ channel.on_data do |ch, data|
141
+ res << data
142
+ end
143
+
144
+ channel.send_data IO.binread(@docker_image_path)
145
+ channel.eof!
146
+ end
147
+ end
148
+ ssh.loop
149
+ end
150
+
151
+ super(index, events, attributes, target)
152
+ end
153
+
154
+
155
+ end
156
+ end
@@ -9,10 +9,15 @@ module StackBuilder::Chef
9
9
  include ERB::Util
10
10
 
11
11
  attr_accessor :name
12
+ attr_accessor :node_id
12
13
 
13
14
  attr_accessor :run_list
14
15
  attr_accessor :run_on_event
15
16
 
17
+ attr_accessor :ssh_user
18
+ attr_accessor :ssh_password
19
+ attr_accessor :ssh_identity_file
20
+
16
21
  def initialize(id, node_config, repo_path, environment)
17
22
 
18
23
  @logger = StackBuilder::Common::Config.logger
@@ -25,7 +30,7 @@ module StackBuilder::Chef
25
30
  @run_on_event = node_config['run_on_event']
26
31
 
27
32
  @knife_config = node_config['knife']
28
- if @knife_config
33
+ if @knife_config && @knife_config.has_key?('options')
29
34
 
30
35
  raise ArgumentError, 'An ssh user needs to be provided for bootstrap and knife ssh.' \
31
36
  unless @knife_config['options'].has_key?('ssh_user')
@@ -36,11 +41,12 @@ module StackBuilder::Chef
36
41
 
37
42
  @ssh_user = @knife_config['options']['ssh_user']
38
43
  @ssh_password = @knife_config['options']['ssh_password']
39
- @identity_file = @knife_config['options']['identity_file']
40
-
41
- @env_key_file = "#{repo_path}/secrets/#{environment}"
42
- @env_key_file = nil unless File.exist?(@env_key_file)
44
+ @ssh_identity_file = @knife_config['options']['identity_file']
45
+ @ssh_identity_file.gsub!(/~\//, Dir.home + '/') unless @ssh_identity_file.nil?
43
46
  end
47
+
48
+ @env_key_file = "#{repo_path}/secrets/#{environment}"
49
+ @env_key_file = nil unless File.exist?(@env_key_file)
44
50
  end
45
51
 
46
52
  def get_name
@@ -73,7 +79,9 @@ module StackBuilder::Chef
73
79
 
74
80
  unless @env_key_file.nil?
75
81
  env_key = IO.read(@env_key_file)
76
- knife_ssh(name, "echo '#{env_key}' > /etc/chef/encrypted_data_bag_secret")
82
+ knife_ssh( name,
83
+ "echo '#{env_key}' > /etc/chef/encrypted_data_bag_secret\n" +
84
+ "chmod 0600 /etc/chef/encrypted_data_bag_secret" )
77
85
  end
78
86
 
79
87
  rescue Exception => msg
@@ -84,7 +92,7 @@ module StackBuilder::Chef
84
92
  end
85
93
 
86
94
  def create_vm(name, knife_config)
87
- raise NotImplemented, 'HostNodeManager.create_vm'
95
+ raise StackBuilder::Common::NotImplemented, 'HostNodeManager.create_vm'
88
96
  end
89
97
 
90
98
  def process(index, events, attributes, target = nil)
@@ -172,7 +180,7 @@ module StackBuilder::Chef
172
180
  end
173
181
 
174
182
  def delete_vm(name, knife_config)
175
- raise NotImplemented, 'HostNodeManager.delete_vm'
183
+ raise StackBuilder::Common::NotImplemented, 'HostNodeManager.delete_vm'
176
184
  end
177
185
 
178
186
  def config_knife(knife_cmd, options)
@@ -13,6 +13,9 @@ module StackBuilder::Chef
13
13
  @repo_path = File.expand_path(repo_path)
14
14
  @environment = environment
15
15
 
16
+ Chef::Config[:environment] = @environment
17
+ Chef::Config[:environment_path] = @repo_path + '/environments'
18
+
16
19
  env_file = "#{@repo_path}/etc/#{@environment}.yml"
17
20
  if File.exist?(env_file)
18
21
 
@@ -37,9 +40,6 @@ module StackBuilder::Chef
37
40
  raise ArgmentError, "Stack file is fixed to the environment '#{stack_environment}', " +
38
41
  " which it does not match the environment '#{@environment}' provided." \
39
42
  unless stack_environment.nil? || stack_environment==@environment
40
-
41
- Chef::Config[:chef_server_url] = stack['chef_server_url'] if stack.has_key?('chef_server_url')
42
- Chef::Config[:environment] = @environment
43
43
  end
44
44
 
45
45
  def get_env_vars
@@ -57,7 +57,12 @@ module StackBuilder::Chef
57
57
 
58
58
  case knife_config['plugin']
59
59
  when 'vagrant'
60
- return StackBuilder::Chef::VagrantNodeManager.new(@id, node_config, @repo_path, @environment)
60
+ return StackBuilder::Chef::VagrantNodeManager.new(
61
+ @id, node_config, @repo_path, @environment)
62
+
63
+ when 'container'
64
+ return StackBuilder::Chef::ContainerNodeManager.new(
65
+ @id, node_config, @repo_path, @environment)
61
66
 
62
67
  # TODO: Refactor so that managers are pluggable from other gems
63
68
 
@@ -7,8 +7,13 @@ module StackBuilder::Common
7
7
  #
8
8
  # Returns whether platform is a nix OS
9
9
  #
10
- def is_nix_os
11
- return RbConfig::CONFIG["host_os"] =~ /linux|freebsd|darwin|unix/
10
+ def is_nix_os?
11
+ RbConfig::CONFIG["host_os"] =~ /linux|freebsd|darwin|unix/
12
+ end
13
+
14
+ # Return whether platform is a OS X
15
+ def is_os_x?
16
+ RbConfig::CONFIG["host_os"] =~ /darwin/
12
17
  end
13
18
 
14
19
  #
@@ -0,0 +1,6 @@
1
+ source 'https://supermarket.getchef.com'
2
+
3
+ cookbook 'ohai', '~> 2.0.1'
4
+ <% @berks_cookbooks.each do |cookbook| -%>
5
+ cookbook '<%= cookbook[0] %>'<% unless cookbook[1].empty? %>, '<%= cookbook[1] %>'<% end %>
6
+ <% end -%>
@@ -0,0 +1,4 @@
1
+ ---
2
+ # Externalized environment configuration for Chef '<%= @environment %>' environment.
3
+
4
+ key: some value for <%= @environment %>
@@ -0,0 +1,21 @@
1
+ name "<%= @environment %>"
2
+ description "Chef '<%= @environment %>' environment."
3
+
4
+ env = YAML.load_file(File.expand_path('../../etc/<%= @environment %>.yml', __FILE__))
5
+
6
+ override_attributes(
7
+
8
+ # Add attributes here as ruby map
9
+ #
10
+ # "attr" => {
11
+ # "key" => ..
12
+ # ...
13
+ # }
14
+ # ...
15
+ #
16
+ # Use this ruby template to load externalized variables from a yaml file
17
+
18
+ 'attr' => {
19
+ 'key' => "#{env['key']}"
20
+ }
21
+ )
@@ -0,0 +1,44 @@
1
+ # Stack
2
+ name: <%= @stack_name %>
3
+ environment: <%= @environment %>
4
+
5
+ # Knife bootstrap and ssh attributes. The plugin attribute
6
+ # is used to determine which knife plugin to use for node
7
+ # creation. If a plugin is not provided it would be assumed
8
+ # that the host exists.
9
+ knife: &knife
10
+ plugin: vagrant
11
+ options:
12
+ box: chef/ubuntu-14.04
13
+ box_url: https://vagrantcloud.com/chef/boxes/ubuntu-14.04
14
+ # Vagrant sets up a NAT for the VM. We need to setup a host
15
+ # only network so the vm can talk to chef zero on host.
16
+ subnet: 192.168.50.0/24
17
+ identity_file: ~/.vagrant/insecure_key
18
+ ssh_user: vagrant
19
+ sudo: true
20
+ # inline config to use vagrant-ohai plugin to install ohai
21
+ # plugin to capture ip from eth1 instead of eth0 as well
22
+ # as run an apt update.
23
+ inline_config: |
24
+ config.ohai.enable = true
25
+ config.ohai.primary_nic = "eth1"
26
+ config.vm.provision "shell", inline: "mkdir -p /etc/chef"
27
+ config.vm.provision "shell", inline: "apt-get update"
28
+ # bootstrap run-list. This will be replaced
29
+ # if a node run list is provided. We run the
30
+ # ohai cookbook to ensure that the node's
31
+ # ipaddress is populated with the address
32
+ # of eth1 and not the default eth0
33
+ run_list:
34
+ - recipe[ohai]
35
+
36
+ stack:
37
+
38
+ - node: <%= @stack_name %>-node
39
+ knife: *knife
40
+ run_list:
41
+ <% @berks_cookbooks.each do |cookbook| -%>
42
+ - recipe[ohai]
43
+ - recipe[<%= cookbook[0] %>]
44
+ <% end -%>
@@ -0,0 +1,53 @@
1
+ [ ca ]
2
+ default_ca = testca
3
+
4
+ [ testca ]
5
+ dir = .
6
+ certificate = $dir/cacert.pem
7
+ database = $dir/index.txt
8
+ new_certs_dir = $dir/certs
9
+ private_key = $dir/private/cakey.pem
10
+ serial = $dir/serial
11
+
12
+ default_crl_days = 7
13
+ default_days = 365
14
+ default_md = sha1
15
+
16
+ policy = testca_policy
17
+ x509_extensions = certificate_extensions
18
+
19
+ [ testca_policy ]
20
+ commonName = supplied
21
+ stateOrProvinceName = optional
22
+ countryName = optional
23
+ emailAddress = optional
24
+ organizationName = optional
25
+ organizationalUnitName = optional
26
+
27
+ [ certificate_extensions ]
28
+ basicConstraints = CA:false
29
+
30
+ [ req ]
31
+ default_bits = 2048
32
+ default_keyfile = ./private/cakey.pem
33
+ default_md = sha1
34
+ prompt = yes
35
+ distinguished_name = root_ca_distinguished_name
36
+ x509_extensions = root_ca_extensions
37
+
38
+ [ root_ca_distinguished_name ]
39
+ commonName = hostname
40
+
41
+ [ root_ca_extensions ]
42
+ basicConstraints = CA:true
43
+ keyUsage = keyCertSign, cRLSign
44
+
45
+ [ client_ca_extensions ]
46
+ basicConstraints = CA:false
47
+ keyUsage = digitalSignature
48
+ extendedKeyUsage = 1.3.6.1.5.5.7.3.2
49
+
50
+ [ server_ca_extensions ]
51
+ basicConstraints = CA:false
52
+ keyUsage = keyEncipherment
53
+ extendedKeyUsage = 1.3.6.1.5.5.7.3.1
@@ -7,7 +7,7 @@ module StackBuilder::Stack
7
7
  class NodeManager
8
8
 
9
9
  def get_name
10
- raise NotImplemented, 'NodeManager.get_name'
10
+ raise StackBuilder::Common::NotImplemented, 'NodeManager.get_name'
11
11
  end
12
12
 
13
13
  def get_scale
@@ -19,19 +19,19 @@ module StackBuilder::Stack
19
19
  end
20
20
 
21
21
  def node_attributes
22
- raise NotImplemented, 'NodeManager.node_attributes'
22
+ raise StackBuilder::Common::NotImplemented, 'NodeManager.node_attributes'
23
23
  end
24
24
 
25
25
  def create(index)
26
- raise NotImplemented, 'NodeManager.create'
26
+ raise StackBuilder::Common::NotImplemented, 'NodeManager.create'
27
27
  end
28
28
 
29
29
  def process(index, events, attributes, target = nil)
30
- raise NotImplemented, 'NodeManager.process'
30
+ raise StackBuilder::Common::NotImplemented, 'NodeManager.process'
31
31
  end
32
32
 
33
33
  def delete(index)
34
- raise NotImplemented, 'NodeManager.delete'
34
+ raise StackBuilder::Common::NotImplemented, 'NodeManager.delete'
35
35
  end
36
36
 
37
37
  end
@@ -7,7 +7,7 @@ module StackBuilder::Stack
7
7
  class NodeProvider
8
8
 
9
9
  def set_stack(stack, id)
10
- raise NotImplemented, 'NodeProvider.set_stack_id'
10
+ raise StackBuilder::Common::NotImplemented, 'NodeProvider.set_stack_id'
11
11
  end
12
12
 
13
13
  def get_env_vars
@@ -15,7 +15,7 @@ module StackBuilder::Stack
15
15
  end
16
16
 
17
17
  def get_node_manager(node_config)
18
- raise NotImplemented, 'NodeProvider.get_node_manager'
18
+ raise StackBuilder::Common::NotImplemented, 'NodeProvider.get_node_manager'
19
19
  end
20
20
  end
21
21
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Knife
4
4
  module StackBuilder
5
- VERSION = "0.5.5"
5
+ VERSION = "0.5.6"
6
6
  MAJOR, MINOR, TINY = VERSION.split('.')
7
7
  end
8
8
  end
data/lib/stackbuilder.rb CHANGED
@@ -10,6 +10,7 @@ require 'erb'
10
10
  require 'securerandom'
11
11
  require 'fileutils'
12
12
  require 'tmpdir'
13
+ require 'tempfile'
13
14
  require "stringio"
14
15
  require 'json'
15
16
  require 'openssl'
@@ -36,6 +37,8 @@ require 'chef/knife/attribute'
36
37
  require 'chef/knife/vagrant_server_create'
37
38
  require 'chef/knife/vagrant_server_delete'
38
39
  require 'chef/knife/vagrant_server_list'
40
+ require 'chef/knife/container_docker_init'
41
+ require 'chef/knife/container_docker_build'
39
42
 
40
43
  require 'stackbuilder/common/config'
41
44
  require 'stackbuilder/common/errors'
@@ -51,3 +54,4 @@ require 'stackbuilder/chef/stack_provider'
51
54
  require 'stackbuilder/chef/stack_node_manager'
52
55
  require 'stackbuilder/chef/stack_vagrant_node'
53
56
  require 'stackbuilder/chef/stack_generic_node'
57
+ require 'stackbuilder/chef/stack_container_node'
metadata CHANGED
@@ -1,57 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-stackbuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mevan Samaratunga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-08 00:00:00.000000000 Z
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 11.16.4
19
+ version: '12'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 11.16.4
26
+ version: '12'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: knife-attribute
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '='
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: knife-container
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: 1.0.3
47
+ version: '0'
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - '='
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
- version: 1.0.3
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: knife-vagrant3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: highline
43
71
  requirement: !ruby/object:Gem::Requirement
44
72
  requirements:
45
- - - "~>"
73
+ - - ">="
46
74
  - !ruby/object:Gem::Version
47
- version: 1.6.21
75
+ version: '0'
48
76
  type: :runtime
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
- - - "~>"
80
+ - - ">="
53
81
  - !ruby/object:Gem::Version
54
- version: 1.6.21
82
+ version: '0'
55
83
  description: Knife Stackbuilder plugin
56
84
  email: mevansam@gmail.com
57
85
  executables:
@@ -74,6 +102,7 @@ files:
74
102
  - lib/chef/knife/stackbuilder_base.rb
75
103
  - lib/stackbuilder.rb
76
104
  - lib/stackbuilder/chef/repo.rb
105
+ - lib/stackbuilder/chef/stack_container_node.rb
77
106
  - lib/stackbuilder/chef/stack_generic_node.rb
78
107
  - lib/stackbuilder/chef/stack_node_manager.rb
79
108
  - lib/stackbuilder/chef/stack_provider.rb
@@ -83,6 +112,11 @@ files:
83
112
  - lib/stackbuilder/common/helpers.rb
84
113
  - lib/stackbuilder/common/semaphore.rb
85
114
  - lib/stackbuilder/common/teeio.rb
115
+ - lib/stackbuilder/resources/Berksfile.erb
116
+ - lib/stackbuilder/resources/Config.yml.erb
117
+ - lib/stackbuilder/resources/Environment.rb.erb
118
+ - lib/stackbuilder/resources/Stack.yml.erb
119
+ - lib/stackbuilder/resources/openssl.cnf
86
120
  - lib/stackbuilder/stack/node_manager.rb
87
121
  - lib/stackbuilder/stack/node_provider.rb
88
122
  - lib/stackbuilder/stack/node_task.rb