gusteau 0.3.9 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -4,6 +4,7 @@ Gusteau
4
4
  *"Anyone can cook."*
5
5
 
6
6
  [![Build Status](https://www.travis-ci.org/locomote/gusteau.png?branch=master)](https://www.travis-ci.org/locomote/gusteau)
7
+ [![Dependency Status](https://gemnasium.com/locomote/gusteau.png)](https://gemnasium.com/locomote/gusteau)
7
8
 
8
9
  Introduction
9
10
  ------------
@@ -80,6 +81,14 @@ You may choose to run a few recipes instead of full provisioning.
80
81
  gusteau node-name run redis::server ntp unicorn
81
82
  ```
82
83
 
84
+ SSH
85
+ ---
86
+ Gusteau provides a useful shortcut that you may use to ssh into a node. If you haven't got passwordless authentication set up, Gusteau will use `user` and `password` values from the node configuration.
87
+
88
+ ```
89
+ gusteau ssh node-name
90
+ ```
91
+
83
92
  Using with Vagrant
84
93
  ------------------
85
94
  At the moment Gusteau doesn't come with Vagrant integration. However, using it with Vagrant is easy, just make sure that you provide the correct IP address of the VM in node's YAML file.
@@ -23,6 +23,11 @@ class Gusteau::CLI < Optitron::CLI
23
23
  node(node_name).run(params, recipe)
24
24
  end
25
25
 
26
+ desc 'SSH into a node'
27
+ def ssh(node_name)
28
+ node(node_name).ssh
29
+ end
30
+
26
31
  desc 'Generate an example project (a bureau)'
27
32
  def generate(bureau_name)
28
33
  Gusteau::Bureau.new(bureau_name)
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/expect -f
2
+
3
+ set ssh_string [lrange $argv 0 0]
4
+ set port [lrange $argv 1 1]
5
+ set password [lrange $argv 2 2]
6
+
7
+ spawn ssh $ssh_string -p $port
8
+ if { $password != "" } {
9
+ match_max 100000
10
+ expect "*?assword:*"
11
+ send -- "$password\r"
12
+ }
13
+ interact
@@ -26,12 +26,17 @@ module Gusteau
26
26
  @server.chef.run opts, dna(false, recipes.flatten)
27
27
  end
28
28
 
29
+ def ssh
30
+ @server.ssh
31
+ end
32
+
29
33
  private
30
34
 
31
35
  def dna(include_all, recipes = [])
32
36
  node_dna = {
33
37
  :path => @dna_path,
34
38
  :hash => {
39
+ :name => @name,
35
40
  :instance_role => @name,
36
41
  :run_list => run_list(include_all, recipes)
37
42
  }.merge(@config['json'])
@@ -10,7 +10,7 @@ module Gusteau
10
10
 
11
11
  def initialize(config, opts={})
12
12
  @host = config['host']
13
- @port = (config['port'] || '22').to_i
13
+ @port = config['port'] || 22
14
14
  @user = config['user'] || 'root'
15
15
  @password = config['password']
16
16
  @chef = Gusteau::Chef.new(self, config['platform'])
@@ -34,5 +34,10 @@ module Gusteau
34
34
  end
35
35
  true
36
36
  end
37
+
38
+ def ssh
39
+ ssh_expect = File.expand_path("../../../bin/gusteau_ssh_expect", __FILE__)
40
+ Kernel.system "#{ssh_expect} #{@user}@#{@host} #{@port} #{@password}"
41
+ end
37
42
  end
38
43
  end
@@ -6,8 +6,8 @@ module Gusteau
6
6
  module SSH
7
7
  include Gusteau::CompressedTarStream
8
8
 
9
- def ssh
10
- @ssh ||= begin
9
+ def conn
10
+ @conn ||= begin
11
11
  opts = { :port => port }
12
12
  opts.update(:password => password) if @password
13
13
  log "#setting up ssh connection #{@user}@#{host}, #{opts.inspect})" do
@@ -18,7 +18,7 @@ module Gusteau
18
18
 
19
19
  def send_command(cmd)
20
20
  exit_code = -1
21
- ssh.open_channel do |ch|
21
+ conn.open_channel do |ch|
22
22
  ch.exec(prepared_cmd cmd) do |_, success|
23
23
  if success
24
24
  ch.on_data { |_,data| puts data }
@@ -29,12 +29,12 @@ module Gusteau
29
29
  end
30
30
  end
31
31
  end
32
- ssh.loop
32
+ conn.loop
33
33
  exit_code == 0
34
34
  end
35
35
 
36
36
  def send_files(files, dest_dir)
37
- ssh.open_channel { |ch|
37
+ conn.open_channel { |ch|
38
38
  ch.exec(prepared_cmd "tar zxf - -C #{dest_dir}")
39
39
  ch.send_data(compressed_tar_stream(files))
40
40
  ch.eof!
@@ -1,3 +1,3 @@
1
1
  module Gusteau
2
- VERSION = "0.3.9"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -4,7 +4,7 @@ describe Gusteau::Server do
4
4
  let(:config) do
5
5
  {
6
6
  'host' => 'demo.com',
7
- 'port' => '2222',
7
+ 'port' => 2222,
8
8
  'platform' => 'ubuntu'
9
9
  }
10
10
  end
@@ -31,7 +31,7 @@ describe Gusteau::Server do
31
31
  let(:config) do
32
32
  {
33
33
  'host' => 'demo.com',
34
- 'port' => '2222',
34
+ 'port' => 2222,
35
35
  'user' => 'oneiric',
36
36
  'platform' => 'ubuntu',
37
37
  }
@@ -66,4 +66,11 @@ describe Gusteau::Server do
66
66
  it { subject.must_equal "sudo -- sh -c 'cd /etc/chef && touch test'" }
67
67
  end
68
68
  end
69
+
70
+ describe "#ssh" do
71
+ it "should call gusteau_ssh_expect with connection arguments" do
72
+ Kernel.expects(:system).with { |arg| arg =~ /gusteau_ssh_expect root@demo.com 2222/ }
73
+ server.ssh
74
+ end
75
+ end
69
76
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gusteau
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-24 00:00:00.000000000 Z
13
+ date: 2013-02-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: optitron
@@ -130,6 +130,7 @@ email:
130
130
  - chris@locomote.com
131
131
  executables:
132
132
  - gusteau
133
+ - gusteau_ssh_expect
133
134
  extensions: []
134
135
  extra_rdoc_files: []
135
136
  files:
@@ -140,6 +141,7 @@ files:
140
141
  - README.md
141
142
  - Rakefile
142
143
  - bin/gusteau
144
+ - bin/gusteau_ssh_expect
143
145
  - bootstrap/centos.sh
144
146
  - bootstrap/gentoo.sh
145
147
  - bootstrap/redhat.sh