champu 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +0 -2
- data/lib/champu.rb +1 -1
- data/lib/champu/step.rb +27 -12
- data/lib/champu/version.rb +1 -1
- data/spec/champu/champu_spec.rb +8 -2
- metadata +2 -2
data/README.rdoc
CHANGED
data/lib/champu.rb
CHANGED
data/lib/champu/step.rb
CHANGED
@@ -10,38 +10,53 @@ require 'champu/monkeypatches/knife_ssh'
|
|
10
10
|
class Champu
|
11
11
|
class Step
|
12
12
|
|
13
|
-
attr_reader :title
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
def initialize(config,title)
|
13
|
+
attr_reader :title
|
14
|
+
|
15
|
+
def initialize(title)
|
19
16
|
@title=title
|
20
|
-
@config=config
|
21
17
|
Chef::Config[:color]=true
|
18
|
+
@config={}
|
22
19
|
end
|
20
|
+
|
23
21
|
def ui
|
24
22
|
@ui ||= Chef::Knife::UI.new(STDOUT,STDERR,STDIN,Champu::Config)
|
25
23
|
end
|
24
|
+
|
25
|
+
def nodes
|
26
|
+
@nodes
|
27
|
+
end
|
28
|
+
|
29
|
+
def config(opts={})
|
30
|
+
@config.merge!(opts) unless opts.empty?
|
31
|
+
@config
|
32
|
+
end
|
33
|
+
|
34
|
+
def config_value(key)
|
35
|
+
@config.key?(key) ? @config[key] : Champu::Config[key]
|
36
|
+
end
|
37
|
+
|
26
38
|
def search(term)
|
27
|
-
Chef::Config[:knife][:ssh_attribute] =
|
28
|
-
Chef::Config[:knife][:ssh_user]=
|
39
|
+
Chef::Config[:knife][:ssh_attribute] = config_value(:ssh_attribute)
|
40
|
+
Chef::Config[:knife][:ssh_user]= config_value :ssh_user
|
29
41
|
@nodes=Chef::Search::Query.new.search(:node,term).first
|
30
42
|
end
|
43
|
+
|
31
44
|
def execute(command)
|
45
|
+
Chef::Config[:knife][:ssh_attribute] = config_value :ssh_attribute
|
46
|
+
Chef::Config[:knife][:ssh_user]= config_value :ssh_user
|
32
47
|
ui.msg(ui.color("Executing command:",:magenta) + ui.color(command,:yellow))
|
33
48
|
c=Chef::Knife::Ssh.new
|
34
49
|
c.configure_attribute
|
35
50
|
c.configure_user
|
36
51
|
c.configure_identity_file
|
37
|
-
c.config[:attribute]=
|
52
|
+
c.config[:attribute]= config_value :ssh_attribute
|
38
53
|
c.action_nodes(nodes)
|
39
54
|
|
40
55
|
longest=0
|
41
56
|
nodes.collect{|n|c.format_for_display(n)[c.config[:attribute]]}.each do |item|
|
42
|
-
hostspec = "
|
57
|
+
hostspec = "#{config_value(:ssh_user)}@#{item}"
|
43
58
|
session_opts = {}
|
44
|
-
session_opts[:keys] =
|
59
|
+
session_opts[:keys] = config_value :identity_file
|
45
60
|
session_opts[:keys_only] = true
|
46
61
|
session_opts[:logger] = Chef::Log.logger
|
47
62
|
session_opts[:paranoid] = false
|
data/lib/champu/version.rb
CHANGED
data/spec/champu/champu_spec.rb
CHANGED
@@ -35,13 +35,19 @@ describe Champu do
|
|
35
35
|
end
|
36
36
|
it "should allow user to execute a command for a step" do
|
37
37
|
q=double('query')
|
38
|
-
q.stub(:search).with(:node,"some criteria").and_return([
|
38
|
+
q.stub(:search).with(:node,"some criteria").and_return([Chef::Node.new])
|
39
39
|
Chef::Search::Query.stub(:new).with(no_args()).and_return(q)
|
40
40
|
Chef::Knife::Ssh.stub(:ssh_command).with("some command")
|
41
|
-
step=Champu::Step.new(
|
41
|
+
step=Champu::Step.new("title")
|
42
42
|
step.search("some criteria")
|
43
43
|
step.execute("some command")
|
44
44
|
end
|
45
|
+
it "should allow user to specify step specific ssh config" do
|
46
|
+
opts={:user=>'user',:identity_file=>'xx.pem'}
|
47
|
+
step=Champu::Step.new("title")
|
48
|
+
step.config(opts)
|
49
|
+
step.config.should == opts
|
50
|
+
end
|
45
51
|
it "should allow user to set the type of the step" do
|
46
52
|
pending
|
47
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: champu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
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: 2012-07-
|
12
|
+
date: 2012-07-16 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A simple orchestration/workflow dsl on top of knife ssh
|
15
15
|
email: dey.ranjib@gmail.com
|