dream-ops 0.7.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: 8b007fcf3a075614dc42f84cc722ccf4f4de27e5
4
- data.tar.gz: 04a440399ff9dbb2cac9b9b99d9c6815c37becb2
2
+ SHA256:
3
+ metadata.gz: e07301e3995e5b0cf1c52c79c24f23c13836f4d1f36e45b9882cc75df486636d
4
+ data.tar.gz: 825c82fcd97bf7d02582666cd997949836e3576140531a4a95b65e06bd924461
5
5
  SHA512:
6
- metadata.gz: 93bb6a02da4398fcb4546f51b0f084374356a0622fba41fd0b5409f2452d656424ea066d10762bc4534d4313ec05d2a2e418986e999f064b654a6193326a8077
7
- data.tar.gz: 9d21948bda4ed935798c203d15c3a9f8e2b6457a87dbb6aba250dd56c40dc4b46910d1b18a816d95d2943250e93299ef6916f7749e80f9db84b80ca6cc132181
6
+ metadata.gz: 9ddbdcf26a49a2ccd1f15dd1709c00ef1a54aa0c40842fcab8a76887e20e8dad8760e867cb116aa4ae8ab65a01f309c01057fb6ce57954d9065c462312911e69
7
+ data.tar.gz: 10a80d96c20276bdfe6729cfb024f153d2e6589234fb2feb1eee74c306a36cd4846f77034193bbdff32a05e7207bff24f5f0956c04d6df6ba5826f173628d642
data/CHANGELOG.md CHANGED
@@ -6,6 +6,16 @@ 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
+
9
19
  ## [0.7.0]
10
20
 
11
21
  ### Changed
@@ -73,7 +83,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
73
83
  - Gem version badge to README
74
84
  - Usage documentation
75
85
 
76
- [Unreleased]: https://github.com/chris-allen/dream-ops/compare/v0.7.0...HEAD
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
77
88
  [0.7.0]: https://github.com/chris-allen/dream-ops/compare/v0.6.1...v0.7.0
78
89
  [0.6.1]: https://github.com/chris-allen/dream-ops/compare/v0.6.0...v0.6.1
79
90
  [0.6.0]: https://github.com/chris-allen/dream-ops/compare/v0.5.0...v0.6.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.com/chris-allen/dream-ops.svg?branch=master)](https://travis-ci.com/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
- --- Chef Workstation 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 Chef Workstation [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
@@ -41,6 +41,6 @@ Gem::Specification.new do |spec|
41
41
  spec.add_dependency "aws-sdk-s3", "~> 1"
42
42
  spec.add_dependency "inifile", "~> 3.0"
43
43
  spec.add_dependency "berkshelf", "~> 7.0"
44
- spec.add_dependency "thor", "~> 0.20"
44
+ spec.add_dependency "thor", "~> 1.0"
45
45
  spec.add_dependency "chef", "~> 13.6"
46
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
@@ -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 --chef-license accept -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 Chef Workstation is not installed
182
- if !system("ssh #{@ssh_opts} #{target[:host]} which chef #{@q_all}")
183
- __bail_with_fatal_error(ChefWorkstationNotInstalledError.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 ChefWorkstationNotInstalledError < 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
- "Chef Workstation 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 ChefWorkstationFailedError < 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 ChefWorkstation 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 "--- Chef Workstation 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,31 +40,37 @@ module DreamOps
40
40
  end
41
41
 
42
42
  def init_target(target, dryrun)
43
- # Install ChefWorkstation 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 Chef Workstation [target=\"#{target[:host]}\"]"
46
+ DreamOps.ui.warn "...WOULD Install chef-solo via CINC [target=\"#{target[:host]}\"]"
47
47
  else
48
- DreamOps.ui.warn "...Installing Chef Workstation [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
- deb_file = "chef-workstation_20.12.187-1_amd64.deb"
55
- chefworkstation_url = "https://packages.chef.io/files/stable/chef-workstation/20.12.187/ubuntu/#{ubuntu_ver}/#{deb_file}"
56
- if system("ssh #{@ssh_opts} #{target[:host]} \"wget #{chefworkstation_url} -P /tmp\" #{@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
57
  `ssh #{@ssh_opts} #{target[:host]} "sudo dpkg -i /tmp/#{deb_file}" #{@q_all}`
58
58
  `ssh #{@ssh_opts} #{target[:host]} "sudo rm /tmp/#{deb_file}" #{@q_all}`
59
- `ssh #{@ssh_opts} #{target[:host]} "chef env --chef-license accept" #{@q_all}`
60
59
  else
61
- __bail_with_fatal_error(ChefWorkstationFailedError.new(target, chefworkstation_url))
60
+ __bail_with_fatal_error(ChefSoloFailedError.new(target, cinc_url))
62
61
  end
63
62
  end
64
63
  end
65
64
 
66
65
  if !dryrun
66
+ `ssh #{@ssh_opts} #{target[:host]} sudo mkdir -p /var/chef/cookbooks`
67
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
68
74
  end
69
75
 
70
76
  # Create empty json file for chef-solo
@@ -1,3 +1,3 @@
1
1
  module DreamOps
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
data/lib/dream-ops.rb CHANGED
@@ -69,7 +69,7 @@ module DreamOps
69
69
  #
70
70
  # @return [~String]
71
71
  def ssh_key
72
- @ssh_key ||= nil
72
+ @ssh_key ||= ''
73
73
  end
74
74
 
75
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.7.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-12-15 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
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '0.20'
145
+ version: '1.0'
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '0.20'
152
+ version: '1.0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: chef
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -208,7 +208,7 @@ licenses:
208
208
  metadata:
209
209
  source_code_uri: https://github.com/chris-allen/dream-ops
210
210
  changelog_uri: https://github.com/chris-allen/dream-ops/blob/master/CHANGELOG.md
211
- post_install_message:
211
+ post_install_message:
212
212
  rdoc_options: []
213
213
  require_paths:
214
214
  - lib
@@ -223,9 +223,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  - !ruby/object:Gem::Version
224
224
  version: 2.0.0
225
225
  requirements: []
226
- rubyforge_project:
227
- rubygems_version: 2.6.14
228
- signing_key:
226
+ rubygems_version: 3.3.13
227
+ signing_key:
229
228
  specification_version: 4
230
229
  summary: CLI for automating the deployment of application cookbooks
231
230
  test_files: []