cluster_chef-knife 3.0.12 → 3.0.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -53,7 +53,7 @@ class Chef
53
53
 
54
54
  @action_nodes = target.chef_nodes
55
55
  addresses = target.servers.map do |svr|
56
- if (svr.cloud.public_ip) then address = svr.cloud.public_ip ; end
56
+ if (svr.cloud.public_ip) then address = svr.cloud.public_ip ; end
57
57
  if (not address) && (svr.fog_server) then address = svr.fog_server.public_ip_address ; end
58
58
  if (not address) && (svr.chef_node) then address = format_for_display( svr.chef_node )[config[:attribute]] ; end
59
59
  address
@@ -64,8 +64,55 @@ class Chef
64
64
  session_from_list(addresses)
65
65
  end
66
66
 
67
+ #
68
+ # Override the one in Chef::Knife::Ssh to allow an err flag (prints in red
69
+ # if non-null)
70
+ #
71
+ def print_data(host, data, err=nil)
72
+ if data =~ /\n/
73
+ data.split(/\n/).each { |d| print_data(host, d, err) }
74
+ else
75
+ padding = @longest - host.length
76
+ str = ui.color(host, :cyan) + (" " * (padding + 1)) + (err ? ui.color(data, :red) : data)
77
+ ui.msg(str)
78
+ end
79
+ end
80
+
81
+ #
82
+ # Override the one in Chef::Knife::Ssh to give a big red warning if the
83
+ # process executes with badness
84
+ #
85
+ def ssh_command(command, subsession=nil)
86
+ subsession ||= session
87
+ command = fixup_sudo(command)
88
+ notifications = []
89
+ subsession.open_channel do |ch|
90
+ ch.request_pty
91
+ ch.exec command do |ch, success|
92
+ raise ArgumentError, "Cannot execute #{command}" unless success
93
+ # note: you can't do the stderr calback because requesting a pty
94
+ # squashes stderr and stdout together
95
+ ch.on_data do |ichannel, data|
96
+ print_data(ichannel[:host], data)
97
+ if data =~ /^knife sudo password: /
98
+ ichannel.send_data("#{get_password}\n")
99
+ end
100
+ end
101
+ ch.on_request "exit-status" do |ichannel, data|
102
+ exit_status = data.read_long
103
+ if exit_status != 0
104
+ command_snippet = (command.length < 70) ? command : (command[0..45] + ' ... ' + command[-19..-1])
105
+ notifications << [ichannel[:host], "'#{command_snippet.gsub(/[\r\n]+/, "; ")}' terminated with error status #{exit_status}", :err]
106
+ end
107
+ end
108
+ end
109
+ end
110
+ session.loop
111
+ notifications.each{|args| print_data(*args) }
112
+ end
113
+
67
114
  def cssh
68
- exec "cssh "+session.servers_for.map {|server| server.user ? "#{server.user}@#{server.host}" : server.host}.join(" ")
115
+ exec "cssh "+session.servers_for.map{|server| server.user ? "#{server.user}@#{server.host}" : server.host}.join(" ")
69
116
  end
70
117
 
71
118
  def run
@@ -27,6 +27,14 @@ class Chef
27
27
  def relevant?(server)
28
28
  server.startable?
29
29
  end
30
+
31
+ def perform_execution(target)
32
+ section("Starting machines")
33
+ super(target)
34
+ section("Announcing Chef nodes as started")
35
+ target.send(:delegate_to_servers, :announce_as_started)
36
+ end
37
+
30
38
  end
31
39
  end
32
40
  end
@@ -15,7 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  require File.expand_path(File.dirname(__FILE__)+"/generic_command.rb")
20
19
 
21
20
  class Chef
@@ -27,6 +26,13 @@ class Chef
27
26
  server.running?
28
27
  end
29
28
 
29
+ def perform_execution(target)
30
+ section("Stopping machines")
31
+ super(target)
32
+ section("Announcing Chef nodes as stopped")
33
+ target.send(:delegate_to_servers, :announce_as_stopped)
34
+ end
35
+
30
36
  def confirm_execution(target)
31
37
  ui.info " Unless these nodes are backed by EBS volumes, this will result in loss of all data"
32
38
  ui.info " not saved elsewhere. Even if they are EBS backed, there may still be some data loss."
@@ -25,12 +25,12 @@ class Chef
25
25
 
26
26
  option :cloud,
27
27
  :long => "--[no-]cloud",
28
- :description => "Sync to the cloud (default syncs cloud; use --no-cloud to skip)",
28
+ :description => "Sync to the cloud (default is yes, sync cloud; use --no-cloud to skip)",
29
29
  :default => true,
30
30
  :boolean => true
31
31
  option :chef,
32
32
  :long => "--[no-]chef",
33
- :description => "Sync to the chef server (default syncs chef; use --no-chef to skip)",
33
+ :description => "Sync to the chef server (default is yes, sync chef; use --no-chef to skip)",
34
34
  :default => true,
35
35
  :boolean => true
36
36
  option :sync_all,
@@ -173,20 +173,17 @@ module ClusterChef
173
173
 
174
174
  module ClassMethods
175
175
  def sub_command
176
- self.to_s.gsub(/^.*::/, '').gsub!(/^Cluster/, '').downcase
176
+ self.to_s.gsub(/^.*::/, '').gsub(/^Cluster/, '').downcase
177
177
  end
178
178
 
179
179
  def import_banner_and_options(klass, options={})
180
180
  options[:except] ||= []
181
- klass.options.each do |name, info|
181
+ deps{ klass.load_deps }
182
+ klass.options.sort.each do |name, info|
182
183
  next if options.include?(name) || options[:except].include?(name)
183
184
  option name, info
184
185
  end
185
186
  banner "knife cluster #{sub_command} CLUSTER_NAME [FACET_NAME [INDEXES]] (options)"
186
-
187
- deps do
188
- klass.load_deps
189
- end
190
187
  end
191
188
  end
192
189
  def self.included(base)
metadata CHANGED
@@ -1,126 +1,125 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cluster_chef-knife
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.14
4
5
  prerelease:
5
- version: 3.0.12
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Infochimps
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-01-25 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-02-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: chef
17
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70259604124020 !ruby/object:Gem::Requirement
18
17
  none: false
19
- requirements:
18
+ requirements:
20
19
  - - ~>
21
- - !ruby/object:Gem::Version
20
+ - !ruby/object:Gem::Version
22
21
  version: 0.10.4
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *70259604124020
25
+ - !ruby/object:Gem::Dependency
27
26
  name: fog
28
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ requirement: &70259604122180 !ruby/object:Gem::Requirement
29
28
  none: false
30
- requirements:
29
+ requirements:
31
30
  - - ~>
32
- - !ruby/object:Gem::Version
31
+ - !ruby/object:Gem::Version
33
32
  version: 1.1.1
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *70259604122180
36
+ - !ruby/object:Gem::Dependency
38
37
  name: formatador
39
- requirement: &id003 !ruby/object:Gem::Requirement
38
+ requirement: &70259604119900 !ruby/object:Gem::Requirement
40
39
  none: false
41
- requirements:
40
+ requirements:
42
41
  - - ~>
43
- - !ruby/object:Gem::Version
42
+ - !ruby/object:Gem::Version
44
43
  version: 0.2.1
45
44
  type: :runtime
46
45
  prerelease: false
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
46
+ version_requirements: *70259604119900
47
+ - !ruby/object:Gem::Dependency
49
48
  name: gorillib
50
- requirement: &id004 !ruby/object:Gem::Requirement
49
+ requirement: &70259604119160 !ruby/object:Gem::Requirement
51
50
  none: false
52
- requirements:
51
+ requirements:
53
52
  - - ~>
54
- - !ruby/object:Gem::Version
53
+ - !ruby/object:Gem::Version
55
54
  version: 0.1.7
56
55
  type: :runtime
57
56
  prerelease: false
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
57
+ version_requirements: *70259604119160
58
+ - !ruby/object:Gem::Dependency
60
59
  name: bundler
61
- requirement: &id005 !ruby/object:Gem::Requirement
60
+ requirement: &70259604118180 !ruby/object:Gem::Requirement
62
61
  none: false
63
- requirements:
62
+ requirements:
64
63
  - - ~>
65
- - !ruby/object:Gem::Version
66
- version: "1"
64
+ - !ruby/object:Gem::Version
65
+ version: '1'
67
66
  type: :development
68
67
  prerelease: false
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
68
+ version_requirements: *70259604118180
69
+ - !ruby/object:Gem::Dependency
71
70
  name: jeweler
72
- requirement: &id006 !ruby/object:Gem::Requirement
71
+ requirement: &70259604133600 !ruby/object:Gem::Requirement
73
72
  none: false
74
- requirements:
73
+ requirements:
75
74
  - - ~>
76
- - !ruby/object:Gem::Version
77
- version: "1.6"
75
+ - !ruby/object:Gem::Version
76
+ version: '1.6'
78
77
  type: :development
79
78
  prerelease: false
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
79
+ version_requirements: *70259604133600
80
+ - !ruby/object:Gem::Dependency
82
81
  name: rspec
83
- requirement: &id007 !ruby/object:Gem::Requirement
82
+ requirement: &70259604133000 !ruby/object:Gem::Requirement
84
83
  none: false
85
- requirements:
84
+ requirements:
86
85
  - - ~>
87
- - !ruby/object:Gem::Version
88
- version: "2.5"
86
+ - !ruby/object:Gem::Version
87
+ version: '2.5'
89
88
  type: :development
90
89
  prerelease: false
91
- version_requirements: *id007
92
- - !ruby/object:Gem::Dependency
90
+ version_requirements: *70259604133000
91
+ - !ruby/object:Gem::Dependency
93
92
  name: yard
94
- requirement: &id008 !ruby/object:Gem::Requirement
93
+ requirement: &70259604132480 !ruby/object:Gem::Requirement
95
94
  none: false
96
- requirements:
95
+ requirements:
97
96
  - - ~>
98
- - !ruby/object:Gem::Version
99
- version: "0.6"
97
+ - !ruby/object:Gem::Version
98
+ version: '0.6'
100
99
  type: :development
101
100
  prerelease: false
102
- version_requirements: *id008
103
- - !ruby/object:Gem::Dependency
101
+ version_requirements: *70259604132480
102
+ - !ruby/object:Gem::Dependency
104
103
  name: configliere
105
- requirement: &id009 !ruby/object:Gem::Requirement
104
+ requirement: &70259604131700 !ruby/object:Gem::Requirement
106
105
  none: false
107
- requirements:
106
+ requirements:
108
107
  - - ~>
109
- - !ruby/object:Gem::Version
108
+ - !ruby/object:Gem::Version
110
109
  version: 0.4.8
111
110
  type: :development
112
111
  prerelease: false
113
- version_requirements: *id009
114
- description: cluster_chef allows you to orchestrate not just systems but clusters of machines. It includes a powerful layer on top of knife and a collection of cloud cookbooks.
112
+ version_requirements: *70259604131700
113
+ description: cluster_chef-knife allows you to orchestrate not just systems but clusters
114
+ of machines. It includes a powerful layer on top of knife and a collection of cloud
115
+ cookbooks.
115
116
  email: coders@infochimps.com
116
117
  executables: []
117
-
118
118
  extensions: []
119
-
120
- extra_rdoc_files:
119
+ extra_rdoc_files:
121
120
  - LICENSE
122
121
  - README.md
123
- files:
122
+ files:
124
123
  - .gitignore
125
124
  - .rspec
126
125
  - CHANGELOG.md
@@ -132,10 +131,11 @@ files:
132
131
  - VERSION
133
132
  - chefignore
134
133
  - cluster_chef-knife.gemspec
135
- - clusters/website_demo.rb
136
134
  - config/client.rb
137
135
  - config/proxy.pac
138
- - lib/chef/knife/bootstrap/ubuntu10.04-basic.erb
136
+ - config/ubuntu10.04-cluster_chef.erb
137
+ - config/ubuntu11.10-cluster_chef.erb
138
+ - ironfan.gemspec
139
139
  - lib/chef/knife/bootstrap/ubuntu10.04-cluster_chef.erb
140
140
  - lib/chef/knife/bootstrap/ubuntu11.10-cluster_chef.erb
141
141
  - lib/chef/knife/cluster_bootstrap.rb
@@ -164,36 +164,37 @@ files:
164
164
  - tasks/chef_config.rake
165
165
  - tasks/jeweler_use_alt_branch.rake
166
166
  homepage: http://infochimps.com/labs
167
- licenses:
167
+ licenses:
168
168
  - apachev2
169
- post_install_message:
169
+ post_install_message: ! "!! This gem has been renamed 'ironfan' (from cluster_chef).
170
+ \n It will not be updated after Feb. 2012. \n Sorry for the inconvenience."
170
171
  rdoc_options: []
171
-
172
- require_paths:
172
+ require_paths:
173
173
  - lib
174
- required_ruby_version: !ruby/object:Gem::Requirement
174
+ required_ruby_version: !ruby/object:Gem::Requirement
175
175
  none: false
176
- requirements:
177
- - - ">="
178
- - !ruby/object:Gem::Version
179
- hash: 373181579172920968
180
- segments:
176
+ requirements:
177
+ - - ! '>='
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ segments:
181
181
  - 0
182
- version: "0"
183
- required_rubygems_version: !ruby/object:Gem::Requirement
182
+ hash: 115206257048957134
183
+ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  none: false
185
- requirements:
186
- - - ">="
187
- - !ruby/object:Gem::Version
188
- version: "0"
185
+ requirements:
186
+ - - ! '>='
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
189
  requirements: []
190
-
191
190
  rubyforge_project:
192
191
  rubygems_version: 1.8.15
193
192
  signing_key:
194
193
  specification_version: 3
195
- summary: cluster_chef allows you to orchestrate not just systems but clusters of machines. It includes a powerful layer on top of knife and a collection of cloud cookbooks.
196
- test_files:
194
+ summary: cluster_chef-knife allows you to orchestrate not just systems but clusters
195
+ of machines. It includes a powerful layer on top of knife and a collection of cloud
196
+ cookbooks.
197
+ test_files:
197
198
  - spec/cluster_chef/cluster_spec.rb
198
199
  - spec/cluster_chef/facet_spec.rb
199
200
  - spec/cluster_chef/server_slice_spec.rb
@@ -1,65 +0,0 @@
1
- ClusterChef.cluster 'webserver_demo' do
2
- cloud :ec2 do
3
- defaults
4
- availability_zones ['us-east-1d']
5
- flavor 't1.micro' # change to something larger for serious use
6
- backing 'ebs'
7
- image_name 'natty'
8
- bootstrap_distro 'ubuntu10.04-cluster_chef'
9
- chef_client_script 'client.rb'
10
- mount_ephemerals(:tags => { :scratch_dirs => true })
11
- end
12
-
13
- role "nfs_client"
14
- recipe "package_set"
15
-
16
- facet :webnode do
17
- instances 6
18
- role "nginx"
19
- role "redis_client"
20
- role "mysql_client"
21
- role "elasticsearch_client"
22
- role "awesome_website"
23
- role "web_server" # this triggers opening appropriate ports
24
- # Rotate nodes among availability zones
25
- azs = ['us-east-1d', 'us-east-1b', 'us-east-1c']
26
- (0...instances).each do |idx|
27
- server(idx).cloud.availability_zones [azs[ idx % azs.length ]]
28
- end
29
- # Rote nodes among A/B testing groups
30
- (0..instances).each do |idx|
31
- server(idx).chef_node.normal[:split_testing] = ( (idx % 2 == 0) ? 'A' : 'B' )
32
- end
33
- end
34
-
35
- facet :dbnode do
36
- instances 2
37
- role "mysql_server"
38
- role "redis_client"
39
- # burly master, wussier slaves
40
- cloud.flavor "m1.large"
41
- server(0) do
42
- cloud.flavor "c1.xlarge"
43
- end
44
-
45
- volume(:data) do
46
- size 50
47
- keep true
48
- device '/dev/sdi'
49
- mount_point '/data/db'
50
- mount_options 'defaults,nouuid,noatime'
51
- fstype 'xfs'
52
- snapshot_id 'snap-d9c1edb1'
53
- end
54
- end
55
-
56
- facet :esnode do
57
- instances 1
58
- role "nginx"
59
- role "redis_server"
60
- role "elasticsearch_data_esnode"
61
- role "elasticsearch_http_esnode"
62
- #
63
- cloud.flavor "m1.large"
64
- end
65
- end