dream-ops 0.6.0 → 0.8.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
- SHA1:
3
- metadata.gz: 635291c5f60c092e9a6aadccbbb94b9c406f44aa
4
- data.tar.gz: b53af42711e3c850419e528221e568bf14c136b7
2
+ SHA256:
3
+ metadata.gz: e07301e3995e5b0cf1c52c79c24f23c13836f4d1f36e45b9882cc75df486636d
4
+ data.tar.gz: 825c82fcd97bf7d02582666cd997949836e3576140531a4a95b65e06bd924461
5
5
  SHA512:
6
- metadata.gz: dec24a3be06450e6b4aadd9907d65e5f3020681680337bf8c8e119e76ce1e39049fdfb22dc712195135d0a60b992aa365ad1652a9e99e1268efc44e1a681e1ad
7
- data.tar.gz: 52451f10fd6658f6b443ad632c60285c24be4b28d3117fafa45bc617638e40eeaa8e603d3543b4a9a53c737c8a95ff9ff65d6607983f4b50aa5d3e8abdb4c69f
6
+ metadata.gz: 9ddbdcf26a49a2ccd1f15dd1709c00ef1a54aa0c40842fcab8a76887e20e8dad8760e867cb116aa4ae8ab65a01f309c01057fb6ce57954d9065c462312911e69
7
+ data.tar.gz: 10a80d96c20276bdfe6729cfb024f153d2e6589234fb2feb1eee74c306a36cd4846f77034193bbdff32a05e7207bff24f5f0956c04d6df6ba5826f173628d642
data/CHANGELOG.md CHANGED
@@ -6,6 +6,29 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.8.0]
10
+
11
+ ### Changed
12
+ - Updated to use CINC instead of Chef Workstation
13
+ - Updated to `thor@1.x` which removes warnings when using ruby 3.x
14
+
15
+ ### Fixes
16
+ - Adds `solo` support for Ubuntu 22.04
17
+ - Better error handling of missing SSH key for `solo` commands
18
+
19
+ ## [0.7.0]
20
+
21
+ ### Changed
22
+ - Updated to use Chef Workstation instead of ChefDK
23
+
24
+ ### Fixes
25
+ - Adds `solo` support for Ubuntu 20.04
26
+
27
+ ## [0.6.1]
28
+
29
+ ### Fixes
30
+ - Now using thread-safe enum to avoid `FiberError`
31
+
9
32
  ## [0.6.0]
10
33
 
11
34
  ### Added
@@ -60,8 +83,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
60
83
  - Gem version badge to README
61
84
  - Usage documentation
62
85
 
63
- [Unreleased]: https://github.com/chris-allen/dream-ops/compare/v0.5.0...HEAD
64
- [0.4.2]: https://github.com/chris-allen/dream-ops/compare/v0.4.2...v0.5.0
86
+ [Unreleased]: https://github.com/chris-allen/dream-ops/compare/v0.8.0...HEAD
87
+ [0.8.0]: https://github.com/chris-allen/dream-ops/compare/v0.7.0...v0.8.0
88
+ [0.7.0]: https://github.com/chris-allen/dream-ops/compare/v0.6.1...v0.7.0
89
+ [0.6.1]: https://github.com/chris-allen/dream-ops/compare/v0.6.0...v0.6.1
90
+ [0.6.0]: https://github.com/chris-allen/dream-ops/compare/v0.5.0...v0.6.0
91
+ [0.5.0]: https://github.com/chris-allen/dream-ops/compare/v0.4.2...v0.5.0
65
92
  [0.4.2]: https://github.com/chris-allen/dream-ops/compare/v0.4.1...v0.4.2
66
93
  [0.4.1]: https://github.com/chris-allen/dream-ops/compare/v0.4.0...v0.4.1
67
94
  [0.4.0]: https://github.com/chris-allen/dream-ops/compare/v0.3.0...v0.4.0
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # DreamOps
2
2
  [![Gem Version](https://img.shields.io/gem/v/dream-ops.svg)][gem]
3
- [![Build Status](https://travis-ci.org/chris-allen/dream-ops.svg?branch=master)](https://travis-ci.org/chris-allen/dream-ops)
3
+ [![Build Status](https://travis-ci.com/chris-allen/dream-ops.svg?branch=master)](https://app.travis-ci.com/github/chris-allen/dream-ops)
4
4
 
5
5
  [gem]: https://rubygems.org/gems/dream-ops
6
6
 
@@ -74,11 +74,11 @@ Target: ip-172-31-53-232
74
74
  ```bash
75
75
  dream init solo -T ubuntu@example.com -i /path/to/key.pem
76
76
  Target: ip-172-31-53-232
77
- --- ChefDK Installed: false
77
+ --- Is chef-solo Installed: false
78
78
  --- Valid chef.json: false
79
79
  --- Valid role[setup]: false
80
80
  --- Valid role[deploy]: false
81
- ...Installing ChefDK [target="ubuntu@example.com"]
81
+ ...Installing chef-solo via CINC [target="ubuntu@example.com"]
82
82
  ...Creating boilerplate /var/chef/chef.json [target="ubuntu@example.com"]
83
83
  ...Creating boilerplate /var/chef/roles/setup.json [target="ubuntu@example.com"]
84
84
  ...Creating boilerplate /var/chef/roles/deploy.json [target="ubuntu@example.com"]
data/dream-ops.gemspec CHANGED
@@ -34,10 +34,13 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency "bundler", "~> 2.0"
35
35
  spec.add_development_dependency "rake", "~> 10.0"
36
36
 
37
- spec.add_dependency "rubyzip", "~> 1.2"
38
- spec.add_dependency "aws-sdk", "~> 2"
39
- spec.add_dependency "inifile", "~> 3.0"
40
- spec.add_dependency "berkshelf", "~> 7.0"
41
- spec.add_dependency "thor", "~> 0.20"
42
- spec.add_dependency "chef", "~> 13.6"
37
+ spec.add_dependency "rubyzip", "~> 1.2"
38
+ spec.add_dependency "aws-sdk-core"
39
+ spec.add_dependency "aws-sdk-configservice", "~> 1"
40
+ spec.add_dependency "aws-sdk-opsworks", "~> 1"
41
+ spec.add_dependency "aws-sdk-s3", "~> 1"
42
+ spec.add_dependency "inifile", "~> 3.0"
43
+ spec.add_dependency "berkshelf", "~> 7.0"
44
+ spec.add_dependency "thor", "~> 1.0"
45
+ spec.add_dependency "chef", "~> 13.6"
43
46
  end
data/lib/dream-ops/cli.rb CHANGED
@@ -55,7 +55,9 @@ module DreamOps
55
55
  if @options[:debug]
56
56
  ENV["DREAMOPS_DEBUG"] = "true"
57
57
  DreamOps.logger.level = ::Logger::DEBUG
58
+ Thread.report_on_exception = true
58
59
  else
60
+ Thread.report_on_exception = false
59
61
  Berkshelf.ui.mute!
60
62
  end
61
63
 
@@ -110,6 +112,10 @@ module DreamOps
110
112
  aliases: "-p",
111
113
  default: ""
112
114
 
115
+ def self.exit_on_failure?
116
+ false
117
+ end
118
+
113
119
  desc "version", "Display version"
114
120
  def version
115
121
  DreamOps.formatter.version
@@ -1,14 +1,16 @@
1
- require "dream-ops/utils/zip"
1
+ require 'dream-ops/utils/zip'
2
+ require 'dream-ops/utils/threaded_enum'
2
3
  require 'fileutils'
3
4
 
4
5
  module DreamOps
5
6
  class BaseDeployer
6
- @@spinner = Enumerator.new do |e|
7
+
8
+ @@spinner = ThreadedEnum.new do |e|
7
9
  loop do
8
- e.yield '|'
9
- e.yield '/'
10
- e.yield '-'
11
- e.yield '\\'
10
+ e << '|'
11
+ e << '/'
12
+ e << '-'
13
+ e << '\\'
12
14
  end
13
15
  end
14
16
 
@@ -1,4 +1,5 @@
1
- require "aws-sdk"
1
+ require "aws-sdk-opsworks"
2
+ require "aws-sdk-s3"
2
3
  require "uri"
3
4
 
4
5
  Aws.use_bundled_cert!
@@ -161,11 +161,16 @@ module DreamOps
161
161
 
162
162
  uuid = SecureRandom.uuid
163
163
 
164
+ chef_cmd = "cinc-solo"
165
+ if !system("ssh #{@ssh_opts} #{target[:host]} which cinc-solo #{@q_all}")
166
+ chef_cmd = "chef-solo --chef-license accept"
167
+ end
168
+
164
169
  pid = fork do
165
170
  if ! system(
166
171
  "ssh #{@ssh_opts} #{target[:host]} \"" +
167
172
  "set -o pipefail && " +
168
- "sudo chef-solo -j /var/chef/chef.json -o \"role[#{role}]\" 2>&1 | sudo tee /var/log/chef/#{uuid}.log #{@q_all}\""
173
+ "sudo #{chef_cmd} -j /var/chef/chef.json -o \"role[#{role}]\" 2>&1 | sudo tee /var/log/chef/#{uuid}.log #{@q_all}\""
169
174
  )
170
175
  exit 1
171
176
  end
@@ -178,9 +183,9 @@ module DreamOps
178
183
  end
179
184
 
180
185
  def deploy_target(target, cookbooks)
181
- # Bail if ChefDK is not installed
182
- if !system("ssh #{@ssh_opts} #{target[:host]} which chef #{@q_all}")
183
- __bail_with_fatal_error(ChefDKNotInstalledError.new(target[:host]))
186
+ # Bail if chef-solo is not installed
187
+ if !system("ssh #{@ssh_opts} #{target[:host]} which chef-solo #{@q_all}")
188
+ __bail_with_fatal_error(ChefSoloNotInstalledError.new(target[:host]))
184
189
  end
185
190
 
186
191
  # Bail if chef.json doesn't exist
@@ -66,7 +66,7 @@ module DreamOps
66
66
  end
67
67
  end
68
68
 
69
- class ChefDKNotInstalledError < DreamOpsError
69
+ class ChefSoloNotInstalledError < DreamOpsError
70
70
  set_status_code(14)
71
71
 
72
72
  def initialize(target)
@@ -75,14 +75,14 @@ module DreamOps
75
75
 
76
76
  def to_s
77
77
  [
78
- "ChefDK not installed on target \"#{@target}\". To initialize chef-solo, run:",
78
+ "chef-solo not installed on target \"#{@target}\". To initialize chef-solo, run:",
79
79
  "",
80
80
  "dream init solo -t #{@target} -i #{DreamOps.ssh_key}",
81
81
  ].join("\n")
82
82
  end
83
83
  end
84
84
 
85
- class ChefDKFailedError < DreamOpsError
85
+ class ChefSoloFailedError < DreamOpsError
86
86
  set_status_code(15)
87
87
 
88
88
  def initialize(target, wget_url)
@@ -92,7 +92,7 @@ module DreamOps
92
92
 
93
93
  def to_s
94
94
  [
95
- "Target \"#{@target}\" failed installing ChefDK from:",
95
+ "Target \"#{@target}\" failed installing chef-solo via CINC from:",
96
96
  "",
97
97
  @wget_url,
98
98
  ].join("\n")
@@ -25,7 +25,7 @@ module DreamOps
25
25
  # [
26
26
  # {
27
27
  # :host => "ubuntu@example.com"
28
- # :chefdk_installed => false,
28
+ # :solo_installed => false,
29
29
  # :solo_json_exists => false,
30
30
  # :setup_role_exists => true,
31
31
  # :deploy_role_exists => true
@@ -21,8 +21,8 @@ module DreamOps
21
21
 
22
22
  target_result = { host: target }
23
23
 
24
- target_result[:chefdk_installed] = system("ssh #{@ssh_opts} #{target} which chef #{@q_all}")
25
- DreamOps.ui.info "--- ChefDK Installed: #{target_result[:chefdk_installed]}"
24
+ target_result[:solo_installed] = system("ssh #{@ssh_opts} #{target} which chef-solo #{@q_all}")
25
+ DreamOps.ui.info "--- Is chef-solo Installed: #{target_result[:solo_installed]}"
26
26
 
27
27
  target_result[:solo_json_exists] = system("ssh #{@ssh_opts} #{target} stat /var/chef/chef.json #{@q_all}")
28
28
  DreamOps.ui.info "--- Valid chef.json: #{target_result[:solo_json_exists]}"
@@ -40,29 +40,37 @@ module DreamOps
40
40
  end
41
41
 
42
42
  def init_target(target, dryrun)
43
- # Install ChefDK if not already
44
- if !target[:chefdk_installed]
43
+ # Install chef-solo if not available
44
+ if !target[:solo_installed]
45
45
  if dryrun
46
- DreamOps.ui.warn "...WOULD Install ChefDK [target=\"#{target[:host]}\"]"
46
+ DreamOps.ui.warn "...WOULD Install chef-solo via CINC [target=\"#{target[:host]}\"]"
47
47
  else
48
- DreamOps.ui.warn "...Installing ChefDK [target=\"#{target[:host]}\"]"
48
+ DreamOps.ui.warn "...Installing chef-solo via CINC [target=\"#{target[:host]}\"]"
49
49
 
50
50
  # Get ubuntu version
51
51
  ubuntu_ver = `ssh #{@ssh_opts} #{target[:host]} "awk 'BEGIN { FS = \\"=\\" } /DISTRIB_RELEASE/ { print \\$2 }' /etc/lsb-release"`.chomp
52
52
 
53
53
  # Download and install the package
54
- chefdk_url = "https://packages.chef.io/files/stable/chefdk/3.3.23/ubuntu/#{ubuntu_ver}/chefdk_3.3.23-1_amd64.deb"
55
- if system("ssh #{@ssh_opts} #{target[:host]} \"wget #{chefdk_url} -P /tmp\" #{@q_all}")
56
- `ssh #{@ssh_opts} #{target[:host]} "sudo dpkg -i /tmp/chefdk_3.3.23-1_amd64.deb" #{@q_all}`
57
- `ssh #{@ssh_opts} #{target[:host]} "sudo rm /tmp/chefdk_3.3.23-1_amd64.deb" #{@q_all}`
54
+ deb_file = "cinc_17.10.0-1_amd64.deb"
55
+ cinc_url = "http://downloads.cinc.sh/files/stable/cinc/17.10.0/ubuntu/#{ubuntu_ver}/#{deb_file}"
56
+ if system("ssh #{@ssh_opts} #{target[:host]} \"wget #{cinc_url} -P /tmp\" #{@q_all}")
57
+ `ssh #{@ssh_opts} #{target[:host]} "sudo dpkg -i /tmp/#{deb_file}" #{@q_all}`
58
+ `ssh #{@ssh_opts} #{target[:host]} "sudo rm /tmp/#{deb_file}" #{@q_all}`
58
59
  else
59
- __bail_with_fatal_error(ChefDKFailedError.new(target, chefdk_url))
60
+ __bail_with_fatal_error(ChefSoloFailedError.new(target, cinc_url))
60
61
  end
61
62
  end
62
63
  end
63
64
 
64
65
  if !dryrun
66
+ `ssh #{@ssh_opts} #{target[:host]} sudo mkdir -p /var/chef/cookbooks`
65
67
  `ssh #{@ssh_opts} #{target[:host]} sudo mkdir -p /var/chef/roles`
68
+
69
+ if system("ssh #{@ssh_opts} #{target[:host]} which cinc-solo #{@q_all}")
70
+ `ssh #{@ssh_opts} #{target[:host]} sudo mkdir /var/cinc`
71
+ `ssh #{@ssh_opts} #{target[:host]} sudo ln -s /var/chef/cookbooks /var/cinc/cookbooks`
72
+ `ssh #{@ssh_opts} #{target[:host]} sudo ln -s /var/chef/roles /var/cinc/roles`
73
+ end
66
74
  end
67
75
 
68
76
  # Create empty json file for chef-solo
@@ -0,0 +1,81 @@
1
+ # Credit: https://github.com/bittrance/rxruby/blob/master/lib/rx/concurrency/threaded_enumerator.rb
2
+ #
3
+ # ThreadedEnum can be used across threads unlike Ruby's default Enumerator
4
+ # that will throw FiberError if the enumerator is used from more than one
5
+ # thread.
6
+ class ThreadedEnum
7
+ ERROR = Object.new
8
+ DONE = Object.new
9
+
10
+ if RUBY_ENGINE == 'jruby'
11
+ def self.new(*args, &block)
12
+ Enumerator.new(*args, &block)
13
+ end
14
+ end
15
+
16
+ # ThreadedEnum helper class
17
+ class Yielder
18
+ def initialize(queue, gate, condition)
19
+ @queue = queue
20
+ @gate = gate
21
+ @condition = condition
22
+ end
23
+
24
+ def <<(e)
25
+ @queue << e
26
+ @gate.synchronize do
27
+ @condition.wait @gate while @queue.size > 0
28
+ end
29
+ end
30
+ end
31
+
32
+ # The enumerator can be created with either an enumerable or a block that
33
+ # receives a yielder object, but not both. Note that the block or enumerable
34
+ # will be iterated immediately once making it possible to prepare the iterator
35
+ # e.g. when reading from a file or a socket.
36
+ def initialize(source_or_size_hint = nil, &block)
37
+ raise TypeError, 'Size hinting not supported' if source_or_size_hint && block_given?
38
+ @condition = ConditionVariable.new
39
+ @gate = Mutex.new
40
+ @queue = Queue.new
41
+ @done = false
42
+ setup_yielder(source_or_size_hint, &block)
43
+ end
44
+
45
+ # Receive the next item from the enumerator or any exception thrown from the
46
+ # enumerator.
47
+ def next
48
+ raise StopIteration if @done
49
+ @gate.synchronize do
50
+ @condition.signal
51
+ end
52
+ payload, type = @queue.pop
53
+ case type
54
+ when DONE
55
+ @done = true
56
+ raise StopIteration
57
+ when ERROR
58
+ @done = true
59
+ raise payload
60
+ end
61
+ payload
62
+ end
63
+
64
+ private
65
+
66
+ def setup_yielder(source, &block)
67
+ yielder = Yielder.new(@queue, @gate, @condition)
68
+ Thread.new do
69
+ begin
70
+ if source
71
+ source.each { |e| yielder << e }
72
+ else
73
+ block.call yielder
74
+ end
75
+ rescue => e
76
+ yielder << [e, ERROR]
77
+ end
78
+ yielder << [nil, DONE]
79
+ end
80
+ end
81
+ end
@@ -1,3 +1,3 @@
1
1
  module DreamOps
2
- VERSION = "0.6.0"
2
+ VERSION = "0.8.0"
3
3
  end
data/lib/dream-ops.rb CHANGED
@@ -10,7 +10,8 @@ end
10
10
 
11
11
  require "berkshelf"
12
12
  require "thor"
13
- require "aws-sdk"
13
+ require "aws-sdk-core"
14
+ require "aws-sdk-configservice"
14
15
  require "inifile"
15
16
 
16
17
  module DreamOps
@@ -68,7 +69,7 @@ module DreamOps
68
69
  #
69
70
  # @return [~String]
70
71
  def ssh_key
71
- @ssh_key ||= nil
72
+ @ssh_key ||= ''
72
73
  end
73
74
 
74
75
  # Specify path to use for the SSH key
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dream-ops
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Allen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-17 00:00:00.000000000 Z
11
+ date: 2022-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -53,19 +53,61 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.2'
55
55
  - !ruby/object:Gem::Dependency
56
- name: aws-sdk
56
+ name: aws-sdk-core
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: aws-sdk-configservice
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: aws-sdk-opsworks
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: aws-sdk-s3
57
99
  requirement: !ruby/object:Gem::Requirement
58
100
  requirements:
59
101
  - - "~>"
60
102
  - !ruby/object:Gem::Version
61
- version: '2'
103
+ version: '1'
62
104
  type: :runtime
63
105
  prerelease: false
64
106
  version_requirements: !ruby/object:Gem::Requirement
65
107
  requirements:
66
108
  - - "~>"
67
109
  - !ruby/object:Gem::Version
68
- version: '2'
110
+ version: '1'
69
111
  - !ruby/object:Gem::Dependency
70
112
  name: inifile
71
113
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +142,14 @@ dependencies:
100
142
  requirements:
101
143
  - - "~>"
102
144
  - !ruby/object:Gem::Version
103
- version: '0.20'
145
+ version: '1.0'
104
146
  type: :runtime
105
147
  prerelease: false
106
148
  version_requirements: !ruby/object:Gem::Requirement
107
149
  requirements:
108
150
  - - "~>"
109
151
  - !ruby/object:Gem::Version
110
- version: '0.20'
152
+ version: '1.0'
111
153
  - !ruby/object:Gem::Dependency
112
154
  name: chef
113
155
  requirement: !ruby/object:Gem::Requirement
@@ -157,6 +199,7 @@ files:
157
199
  - lib/dream-ops/logger.rb
158
200
  - lib/dream-ops/mixin/logging.rb
159
201
  - lib/dream-ops/shell.rb
202
+ - lib/dream-ops/utils/threaded_enum.rb
160
203
  - lib/dream-ops/utils/zip.rb
161
204
  - lib/dream-ops/version.rb
162
205
  homepage: https://github.com/chris-allen/dream-ops
@@ -165,7 +208,7 @@ licenses:
165
208
  metadata:
166
209
  source_code_uri: https://github.com/chris-allen/dream-ops
167
210
  changelog_uri: https://github.com/chris-allen/dream-ops/blob/master/CHANGELOG.md
168
- post_install_message:
211
+ post_install_message:
169
212
  rdoc_options: []
170
213
  require_paths:
171
214
  - lib
@@ -180,9 +223,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
223
  - !ruby/object:Gem::Version
181
224
  version: 2.0.0
182
225
  requirements: []
183
- rubyforge_project:
184
- rubygems_version: 2.6.14
185
- signing_key:
226
+ rubygems_version: 3.3.13
227
+ signing_key:
186
228
  specification_version: 4
187
229
  summary: CLI for automating the deployment of application cookbooks
188
230
  test_files: []