runbook 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c6c617aa11aeff1ab914c2f6d4d7b4db2cc5f46e6c70acc67a97eda7ba5b3a6
4
- data.tar.gz: 3d68b0e53afbddc94ac0fa7c56eab9a8ac78ad104830c551f79c477314a81c4f
3
+ metadata.gz: 11c80dcba3596671291c8d9dbd40a33ae5691963b27dffdd7459cb4f4ebd94be
4
+ data.tar.gz: a8a578797429344e1fa29c84cb395db5c9c725f4b35b00440e26708328fdca26
5
5
  SHA512:
6
- metadata.gz: cd186e2e3d0bde065b1ed0cccecce8c5943ec6ca626dac0cfa38725f4dd4050f5208df8343e770c602f2ec6cf7b38be9b01fee69ac0f304a16a14fe6c610378a
7
- data.tar.gz: 4ce8c856c8cbd26cbffdfc1f7c2fe1b1fad5f6d5cdfc511d3be731d8db43db5ddeff1abf1d1ab2738374ac5eac27dbe33151e99f97abd604f3ddebb10394bf8c
6
+ metadata.gz: bda3ee51331bcac0c38f338e4ddcf001847328f07093ff1163b8a8b4394e523b116c05b88de449d7072dc90fbe51da3049f00778933a8e8d0b8d3eac39c935c0
7
+ data.tar.gz: 11420133d97afa081df1105bbf3dc1364b5722aa50e57f49777f761c2df88b152b50b4db80c2da81a8d10328bc85b46de51721a010113d26b965411243a51e68
data/.travis.yml CHANGED
@@ -3,26 +3,23 @@ language: ruby
3
3
  services:
4
4
  - docker
5
5
  rvm:
6
- - 2.2.10
7
6
  - 2.3.8
8
- - 2.4.6
9
- - 2.5.5
10
- - 2.6.3
7
+ - 2.4.10
8
+ - 2.5.8
9
+ - 2.6.6
10
+ - 2.7.2
11
+ - 3.0.0
11
12
  gemfile:
12
13
  - gemfiles/activesupport_5.gemfile
13
14
  - gemfiles/activesupport_6.gemfile
14
15
  matrix:
15
16
  exclude:
16
- - rvm: 2.2.3
17
- gemfile: gemfiles/activesupport_6.gemfile
18
- - rvm: 2.2.10
19
- gemfile: gemfiles/activesupport_6.gemfile
20
17
  - rvm: 2.3.8
21
18
  gemfile: gemfiles/activesupport_6.gemfile
22
- - rvm: 2.4.6
19
+ - rvm: 2.4.10
23
20
  gemfile: gemfiles/activesupport_6.gemfile
24
21
 
25
- before_install: gem install bundler -v 1.15.4
22
+ before_install: gem install bundler -v 2.2.16
26
23
 
27
24
  script:
28
25
  - bundle exec rake spec_all
data/CHANGELOG.md CHANGED
@@ -4,6 +4,23 @@ This log maintains a list of all substantive changes to Runbook. The log include
4
4
 
5
5
  ## master
6
6
 
7
+ ## `v1.1.0` (2021-05-21)
8
+
9
+ ### Breaking Changes:
10
+
11
+ * Removes `runbook install` (should have happened in v1.0.0)
12
+ * Drops support for Ruby 2.2 and bundler < 2.2
13
+
14
+ ### Features:
15
+
16
+ * Add support for Ruby 3.0.0 (thanks @pblesi!)
17
+ * Add metadata argument that saves TMUX panes: keep_panes (thanks @ClashTheBunny)
18
+
19
+ ### Documentation:
20
+
21
+ * Update assert parameters description
22
+ * Update example for module class method (thanks @voodoologic!)
23
+
7
24
  ## `v1.0.0` (2020-07-24)
8
25
 
9
26
  ### Breaking Changes:
data/README.md CHANGED
@@ -321,16 +321,16 @@ In the above example, the `note` statement must be wrapped in a `ruby_command` s
321
321
 
322
322
  ##### Assert
323
323
 
324
- Runs the provided `cmd` repeatedly until it returns true. A timeout and maximum number of attempts can be set. You can specify a command to be run if a timeout occurs or the maximum number of attempts is hit. Commands can optionally be specified as `raw`. This tells SSHKit to not perform auto-wrapping of the commands, but execute the exact string on the remote server. See SSHKit's documentation for more details.
324
+ Runs the provided `cmd` repeatedly until it returns true. A timeout and maximum number of attempts can be set. When either the attempt or timeout limit is hit, a command can be specified that will be run. If no command is specified, the process will fail. Commands can optionally be specified as `raw`. This tells SSHKit to not perform auto-wrapping of the commands, but execute the exact string on the remote server. See SSHKit's documentation for more details.
325
325
 
326
326
  ```ruby
327
327
  assert(
328
328
  'service nginx status | grep "is running"',
329
329
  cmd_ssh_config: {servers: ["host1.prod"], parallelization: {strategy: :parallel}},
330
330
  cmd_raw: false,
331
- interval: 3, # seconds
332
- timeout: 300, # seconds
333
- attempts: 3,
331
+ interval: 3, # How often, in seconds, to wait between tries
332
+ timeout: 300, # Total time, in seconds, to keep trying command, after which it will fail
333
+ attempts: 3, # Total number of attempts after which the process will fail
334
334
  abort_statement: Runbook::Statements::Command.new(
335
335
  "echo 'help' | mail -s 'need help' page-me@page-me.com",
336
336
  ssh_config: {servers: [:local], parallelization: {strategy: :parallel}},
@@ -443,6 +443,7 @@ Metadata at execution time is structured as follows:
443
443
  noop: false, # A boolean indicating if you are running in noop mode. ruby_command blocks are never evaluated in noop mode
444
444
  auto: false, # A boolean indicating if you are running in auto mode
445
445
  paranoid: true, # A boolean indicating if you are running in paranoid mode (prompting before each step)
446
+ keep_panes: false, # A boolean indicating whether panes should be kept open after completion
446
447
  start_at: 0, # A string representing the step where nodes should start being processed
447
448
  toolbox: Runbook::Toolbox.new, # A collection of methods to invoke side-effects such as printing and collecting input
448
449
  layout_panes: {}, # A map of pane names to pane ids. `layout_panes` is used by the `tmux_command` to identify which tmux pane to send the command to
@@ -1208,7 +1209,7 @@ When defining and referencing your own functions in a runbook, functions should
1208
1209
 
1209
1210
  ```ruby
1210
1211
  module Adder
1211
- def add(x, y)
1212
+ def self.add(x, y)
1212
1213
  x + y
1213
1214
  end
1214
1215
  end
@@ -1,4 +1,4 @@
1
- FROM ruby:2.5
1
+ FROM ruby:3.0
2
2
  RUN apt-get update -qq && apt-get install -y build-essential tmux
3
3
 
4
4
  RUN mkdir /runbook
data/lib/runbook.rb CHANGED
@@ -2,8 +2,10 @@ require "tmpdir"
2
2
  require "yaml"
3
3
  require "thread"
4
4
 
5
+ require "active_support/deprecation"
5
6
  require "active_support/inflector"
6
7
  require "method_source"
8
+ require "ruby2_keywords"
7
9
  require "pastel"
8
10
  require "sshkit"
9
11
  require "sshkit/sudo"
data/lib/runbook/cli.rb CHANGED
@@ -82,17 +82,6 @@ module Runbook
82
82
  invoke(Runbook::Initializer)
83
83
  end
84
84
 
85
- desc "install", "Install Runbook in an existing project", hide: true
86
- Runbook::Initializer.class_options.values.each do |co|
87
- method_option co.name, desc: co.description, required: co.required,
88
- default: co.default, aliases: co.aliases, type: co.type,
89
- banner: co.banner, hide: co.hide
90
- end
91
- def install
92
- Runbook.deprecator.deprecation_warning(:install, :init)
93
- invoke(Runbook::Initializer)
94
- end
95
-
96
85
  desc "--version", "Print runbook's version"
97
86
  def __print_version
98
87
  puts "Runbook v#{Runbook::VERSION}"
@@ -26,7 +26,7 @@ module Runbook
26
26
  @items ||= []
27
27
  end
28
28
 
29
- def method_missing(method, *args, &block)
29
+ ruby2_keywords def method_missing(method, *args, &block)
30
30
  if dsl.respond_to?(method)
31
31
  dsl.send(method, *args, &block)
32
32
  else
@@ -1,7 +1,7 @@
1
1
  module Runbook::Extensions
2
2
  module Statements
3
3
  module DSL
4
- def method_missing(name, *args, &block)
4
+ ruby2_keywords def method_missing(name, *args, &block)
5
5
  if (klass = Statements::DSL._statement_class(name))
6
6
  klass.new(*args, &block).tap do |statement|
7
7
  parent.add(statement)
@@ -22,15 +22,20 @@ module Runbook::Generators
22
22
  desc: "Target directory for shared runbook code"
23
23
  class_option :test, type: :string, enum: ["rspec", "minitest"],
24
24
  default: "rspec", desc: %Q{Test-suite, "rspec" or "minitest"}
25
+ class_option :ci, type: :string, enum: ["github", "travis", "gitlab", "circle"],
26
+ default: "github", desc: %Q{CI Service, "github", "travis", "gitlab", or "circle"}
25
27
 
26
28
  def init_gem
27
29
  bundle_exists = "which bundle 2>&1 1>/dev/null"
28
30
  raise "Please ensure bundle is installed" unless system(bundle_exists)
31
+ bundler_version = Gem::Version.new(Bundler::VERSION)
29
32
 
30
33
  inside(parent_options[:root]) do
31
34
  test = "--test #{options[:test]}"
35
+ ci = "--ci #{options[:ci]}"
36
+ changelog = "--no-changelog" if bundler_version >= Gem::Version.new("2.2.8")
32
37
  continue = (
33
- run("bundle gem #{_name} #{test} --no-coc --no-mit") ||
38
+ run("bundle gem #{_name} #{test} #{ci} --rubocop #{changelog} --no-coc --no-mit") ||
34
39
  options[:pretend]
35
40
  )
36
41
  exit 1 unless continue
@@ -53,6 +58,9 @@ module Runbook::Generators
53
58
  remove_file(readme)
54
59
 
55
60
  gemfile = File.join(*dirs, "Gemfile")
61
+ if File.exist?(gemfile)
62
+ @gemfile_file_contents = File.readlines(gemfile)
63
+ end
56
64
  remove_file(gemfile)
57
65
 
58
66
  base_file = File.join(*dirs, "lib", "#{_name}.rb")
@@ -102,14 +110,25 @@ module Runbook::Generators
102
110
  template("templates/Gemfile.tt", target)
103
111
 
104
112
  # Add development dependencies from gemspec
105
- return unless @gemspec_file_contents
106
- gems = @gemspec_file_contents.select do |line|
107
- line =~ / spec.add_development_dependency/
108
- end.map do |line|
109
- line.gsub(/ spec.add_development_dependency/, "gem")
110
- end.join
111
-
112
- append_to_file(target, "\n#{gems}", verbose: false)
113
+ if @gemspec_file_contents
114
+ gems = @gemspec_file_contents.select do |line|
115
+ line =~ / spec.add_development_dependency/
116
+ end.map do |line|
117
+ line.gsub(/ spec.add_development_dependency/, "gem")
118
+ end.join
119
+
120
+ append_to_file(target, "\n#{gems}", verbose: false)
121
+ end
122
+
123
+ # Add gemfile gems
124
+ if @gemfile_file_contents
125
+ gems = @gemfile_file_contents.select do |line|
126
+ line =~ /^gem /
127
+ end.join
128
+
129
+ append_to_file(target, "\n#{gems}", verbose: false)
130
+ end
131
+
113
132
  end
114
133
 
115
134
  def create_base_file
data/lib/runbook/run.rb CHANGED
@@ -258,7 +258,7 @@ module Runbook
258
258
  :after,
259
259
  Runbook::Entities::Book,
260
260
  ) do |object, metadata|
261
- next if metadata[:noop] || metadata[:layout_panes].none?
261
+ next if metadata[:noop] || metadata[:layout_panes].none? || metadata[:keep_panes]
262
262
  if metadata[:auto]
263
263
  metadata[:toolbox].output("Killing all opened tmux panes...")
264
264
  kill_all_panes(metadata[:layout_panes])
@@ -11,6 +11,7 @@ module Runbook
11
11
  noop: false,
12
12
  auto: false,
13
13
  paranoid: true,
14
+ keep_panes: false,
14
15
  start_at: "0"
15
16
  )
16
17
  run = "Runbook::Runs::#{run.to_s.camelize}".constantize
@@ -21,6 +22,7 @@ module Runbook
21
22
  paranoid: Util::Glue.new(paranoid),
22
23
  start_at: Util::Glue.new(start_at || "0"),
23
24
  toolbox: Util::Glue.new(toolbox),
25
+ keep_panes: keep_panes,
24
26
  book_title: book.title,
25
27
  }).
26
28
  merge(Runbook::Entities::Book.initial_run_metadata).
@@ -1,3 +1,3 @@
1
1
  module Runbook
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
data/runbook.gemspec CHANGED
@@ -32,7 +32,8 @@ Gem::Specification.new do |spec|
32
32
  spec.require_paths = ["lib"]
33
33
 
34
34
  spec.add_runtime_dependency "activesupport", ">= 5.0.1.x", "< 7.0"
35
- spec.add_runtime_dependency "method_source", "~> 0.9"
35
+ spec.add_runtime_dependency "method_source", "~> 1.0"
36
+ spec.add_runtime_dependency "ruby2_keywords", "~> 0.0.4"
36
37
  spec.add_runtime_dependency "sshkit", "1.21.0"
37
38
  spec.add_runtime_dependency "sshkit-sudo", "~> 0.1"
38
39
  spec.add_runtime_dependency "airbrussh", "~> 1.4"
@@ -42,10 +43,10 @@ Gem::Specification.new do |spec|
42
43
 
43
44
  spec.add_development_dependency "appraisal", "~> 2.2"
44
45
  spec.add_development_dependency "aruba", "~> 0.14"
45
- spec.add_development_dependency "bundler", "~> 1.15"
46
+ spec.add_development_dependency "bundler", "~> 2.2"
46
47
  spec.add_development_dependency "bcrypt_pbkdf", ">= 1.0", "< 2.0"
47
48
  spec.add_development_dependency "ed25519", ">= 1.2", "< 2.0"
48
- spec.add_development_dependency "pry", "~> 0.11"
49
+ spec.add_development_dependency "pry", "~> 0.13"
49
50
  spec.add_development_dependency "pry-byebug", "~> 3.6"
50
51
  spec.add_development_dependency "rake", "~> 12.3"
51
52
  spec.add_development_dependency "rspec", "~> 3.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runbook
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pblesi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-24 00:00:00.000000000 Z
11
+ date: 2021-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -36,14 +36,28 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.9'
39
+ version: '1.0'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.9'
46
+ version: '1.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: ruby2_keywords
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 0.0.4
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.0.4
47
61
  - !ruby/object:Gem::Dependency
48
62
  name: sshkit
49
63
  requirement: !ruby/object:Gem::Requirement
@@ -162,14 +176,14 @@ dependencies:
162
176
  requirements:
163
177
  - - "~>"
164
178
  - !ruby/object:Gem::Version
165
- version: '1.15'
179
+ version: '2.2'
166
180
  type: :development
167
181
  prerelease: false
168
182
  version_requirements: !ruby/object:Gem::Requirement
169
183
  requirements:
170
184
  - - "~>"
171
185
  - !ruby/object:Gem::Version
172
- version: '1.15'
186
+ version: '2.2'
173
187
  - !ruby/object:Gem::Dependency
174
188
  name: bcrypt_pbkdf
175
189
  requirement: !ruby/object:Gem::Requirement
@@ -216,14 +230,14 @@ dependencies:
216
230
  requirements:
217
231
  - - "~>"
218
232
  - !ruby/object:Gem::Version
219
- version: '0.11'
233
+ version: '0.13'
220
234
  type: :development
221
235
  prerelease: false
222
236
  version_requirements: !ruby/object:Gem::Requirement
223
237
  requirements:
224
238
  - - "~>"
225
239
  - !ruby/object:Gem::Version
226
- version: '0.11'
240
+ version: '0.13'
227
241
  - !ruby/object:Gem::Dependency
228
242
  name: pry-byebug
229
243
  requirement: !ruby/object:Gem::Requirement
@@ -398,7 +412,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
398
412
  - !ruby/object:Gem::Version
399
413
  version: '0'
400
414
  requirements: []
401
- rubygems_version: 3.0.6
415
+ rubygems_version: 3.0.8
402
416
  signing_key:
403
417
  specification_version: 4
404
418
  summary: Write beautiful, executable runbooks for conducting system operations.