sshkit 1.19.1 → 1.20.0

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
  SHA256:
3
- metadata.gz: 1b8cc968102708cd224132592b522e059c57c29a68b7c0feced32ef905fb6f1e
4
- data.tar.gz: d5a2ad7b2a09ba796ad5def0a211e793e7e27334fdf2296cc557fc92e9e92597
3
+ metadata.gz: 15fa13df6228673b8f0f084b8df88cadaff79d93bb78b83fcaf37d5c4f390419
4
+ data.tar.gz: 42f9c9401241796a150ef6c3f0d7f735c8fac91eed61975f22654df33c4200f5
5
5
  SHA512:
6
- metadata.gz: 67f29e165c1d9612f157323a638a04054688a50c0bb302620756c3590a854929fcbac166b3f9f7671f32c21de2a22c5ca2e3ba7c3edb35c8918f7fc4ddc38d1d
7
- data.tar.gz: 70c0ada0ed66f2b92032f7fc9adda13f3a2bb1d31207733072772817a795f7342de7b88acee6dc154c52a14c4aaaef051c4922118a87669c433320606ea2e0e6
6
+ metadata.gz: eb3b2a5df2f9706fc659e4cd901ffcea0487cae4009431f14b8606edd650d99229b63ff893ac45c6ce2501b860504d651430b2b98cb8f2368782e4f656dd50bd
7
+ data.tar.gz: 466488b99bfa4a768d2901edf9e63924e0aa76f099b5ba67f938d15881fc548d39c7dd26e89782eafa63d0f35a55f0dca8ff58b4be0272e63e6e61e05c0f10fa
@@ -7,6 +7,10 @@ appear at the top.
7
7
 
8
8
  * Your contribution here!
9
9
 
10
+ ## [1.20.0][] (2019-08-03)
11
+
12
+ * [#468](https://github.com/capistrano/sshkit/pull/468): Make `upload!` take a `:verbosity` option like `exec` does - [@grosser](https://github.com/grosser)
13
+
10
14
  ## [1.19.1][] (2019-07-02)
11
15
 
12
16
  * [#465](https://github.com/capistrano/sshkit/pull/456): Fix a regression in 1.19.0 that prevented `~` from being used in Capistrano paths, e.g. `:deploy_to`, etc. - [@grosser](https://github.com/grosser)
@@ -768,7 +772,8 @@ version `0.0.5`.
768
772
 
769
773
  First release.
770
774
 
771
- [Unreleased]: https://github.com/capistrano/sshkit/compare/v1.19.1...HEAD
775
+ [Unreleased]: https://github.com/capistrano/sshkit/compare/v1.20.0...HEAD
776
+ [1.20.0]: https://github.com/capistrano/sshkit/compare/v1.19.1...v1.20.0
772
777
  [1.19.1]: https://github.com/capistrano/sshkit/compare/v1.19.0...v1.19.1
773
778
  [1.19.0]: https://github.com/capistrano/sshkit/compare/v1.18.2...v1.19.0
774
779
  [1.18.2]: https://github.com/capistrano/sshkit/compare/v1.18.1...v1.18.2
data/README.md CHANGED
@@ -6,29 +6,31 @@ more servers.
6
6
  [![Gem Version](https://badge.fury.io/rb/sshkit.svg)](https://rubygems.org/gems/sshkit)
7
7
  [![Build Status](https://travis-ci.org/capistrano/sshkit.svg?branch=master)](https://travis-ci.org/capistrano/sshkit)
8
8
 
9
- ## How might it work?
9
+ ## Example
10
10
 
11
- The typical use-case looks something like this:
11
+ - Connect to 2 servers
12
+ - Execute commands as `deploy` user with `RAILS_ENV=production`
13
+ - Execute commands in serial (default is `:parallel`)
12
14
 
13
15
  ```ruby
14
16
  require 'sshkit'
15
17
  require 'sshkit/dsl'
16
18
  include SSHKit::DSL
17
19
 
18
- on %w{1.example.com 2.example.com}, in: :sequence, wait: 5 do |host|
20
+ on ["1.example.com", "2.example.com"], in: :sequence do |host|
21
+ puts "Now executing on #{host}"
19
22
  within "/opt/sites/example.com" do
20
23
  as :deploy do
21
- with rails_env: :production do
22
- rake "assets:precompile"
23
- runner "S3::Sync.notify"
24
- execute :node, "socket_server.js"
24
+ with RAILS_ENV: 'production' do
25
+ execute :rake, "assets:precompile"
26
+ execute :rails, "runner", "S3::Sync.notify"
25
27
  end
26
28
  end
27
29
  end
28
30
  end
29
31
  ```
30
32
 
31
- You can find many other examples of how to use SSHKit over in [EXAMPLES.md](EXAMPLES.md).
33
+ Many other examples are in [EXAMPLES.md](EXAMPLES.md).
32
34
 
33
35
  ## Basic usage
34
36
 
@@ -37,7 +39,7 @@ You can pass one or more hosts as parameters; this runs commands via SSH. Altern
37
39
  pass `:local` to run commands locally. By default SSKit will run the commands on all hosts in
38
40
  parallel.
39
41
 
40
- #### Running commands
42
+ ### Running commands
41
43
 
42
44
  All backends support the `execute(*args)`, `test(*args)` & `capture(*args)` methods
43
45
  for executing a command. You can call any of these methods in the context of an `on()`
@@ -63,7 +65,7 @@ end
63
65
  By default the `capture` methods strips whitespace. If you need to preserve whitespace
64
66
  you can pass the `strip: false` option: `capture(:ls, '-l', strip: false)`
65
67
 
66
- #### Transferring files
68
+ ### Transferring files
67
69
 
68
70
  All backends also support the `upload!` and `download!` methods for transferring files.
69
71
  For the remote backend, the file is transferred with scp.
@@ -75,7 +77,7 @@ on '1.example.com' do
75
77
  end
76
78
  ```
77
79
 
78
- #### Users, working directories, environment variables and umask
80
+ ### Users, working directories, environment variables and umask
79
81
 
80
82
  When running commands, you can tell SSHKit to set up the context for those
81
83
  commands using the following methods:
@@ -113,6 +115,11 @@ the raised error.
113
115
  Helpers such as `runner()` and `rake()` which expand to `execute(:rails, "runner", ...)` and
114
116
  `execute(:rake, ...)` are convenience helpers for Ruby, and Rails based apps.
115
117
 
118
+ ### Verbosity / Silence
119
+
120
+ - raise verbosity of a command: `execute "echo DEAD", verbosity: :ERROR`
121
+ - hide a command from output: `execute "echo HIDDEN", verbosity: :DEBUG`
122
+
116
123
  ## Parallel
117
124
 
118
125
  Notice on the `on()` call the `in: :sequence` option, the following will do
@@ -567,6 +574,20 @@ In order to do special gymnastics with SSH, tunneling, aliasing, complex options
567
574
 
568
575
  These system level files are the preferred way of setting up tunneling and proxies because the system implementations of these things are faster and better than the Ruby implementations you would get if you were to configure them through Net::SSH. In cases where it's not possible (Windows?), it should be possible to make use of the Net::SSH APIs to setup tunnels and proxy commands before deferring control to Capistrano/SSHKit..
569
576
 
577
+ ## Proxying
578
+
579
+ To connect to the target host via a jump/bastion host, use a `Net::SSH::Proxy::Jump`
580
+
581
+ ```ruby
582
+ host = SSHKit::Host.new(
583
+ hostname: 'target.host.com',
584
+ ssh_options: { proxy: Net::SSH::Proxy::Jump.new("proxy.bar.com") }
585
+ )
586
+ on [host] do
587
+ execute :echo, '1'
588
+ end
589
+ ```
590
+
570
591
  ## SSHKit Related Blog Posts
571
592
 
572
593
  [SSHKit Gem Basics](http://www.rubyplus.com/articles/591)
@@ -0,0 +1,10 @@
1
+ # tiny example so you can play with the sshkit or make a failing example for an issue
2
+ require 'bundler/setup'
3
+ require 'sshkit'
4
+ require 'sshkit/dsl'
5
+ include SSHKit::DSL
6
+
7
+ on [ENV.fetch("HOST")] do
8
+ execute "echo hello"
9
+ end
10
+
@@ -109,7 +109,8 @@ module SSHKit
109
109
  message = "#{action} #{name} #{percentage.round(2)}%"
110
110
  percentage_r = (percentage / log_percent).truncate * log_percent
111
111
  if percentage_r > 0 && (last_name != name || last_percentage != percentage_r)
112
- info message
112
+ verbosity = (options[:verbosity] || :INFO).downcase # TODO: ideally reuse command.rb logic
113
+ public_send verbosity, message
113
114
  last_name = name
114
115
  last_percentage = percentage_r
115
116
  else
@@ -1,3 +1,3 @@
1
1
  module SSHKit
2
- VERSION = "1.19.1".freeze
2
+ VERSION = "1.20.0".freeze
3
3
  end
@@ -54,6 +54,13 @@ module SSHKit
54
54
  end
55
55
  end
56
56
 
57
+ def test_transfer_summarizer_uses_verbosity
58
+ netssh = Netssh.new(Host.new('fake'))
59
+ summarizer = netssh.send(:transfer_summarizer, 'Transferring', verbosity: :ERROR)
60
+ netssh.expects(:error).with { |msg| msg.include?('Transferring afile 15.0%') }
61
+ summarizer.call(nil,'afile',15,100)
62
+ end
63
+
57
64
  if Net::SSH::Version::CURRENT >= Net::SSH::Version[3, 1, 0]
58
65
  def test_known_hosts_for_when_all_hosts_are_recognized
59
66
  perform_known_hosts_test('github', 'github.com')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sshkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.1
4
+ version: 1.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Hambley
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-07-02 00:00:00.000000000 Z
12
+ date: 2019-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-ssh
@@ -199,6 +199,7 @@ files:
199
199
  - Vagrantfile
200
200
  - examples/images/example_output.png
201
201
  - examples/images/logo.png
202
+ - examples/simple_connection.rb
202
203
  - lib/core_ext/array.rb
203
204
  - lib/core_ext/hash.rb
204
205
  - lib/sshkit.rb