chef-apply 0.6.3 → 0.9.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: c3c0e574b583d84f08985d61344c65598b0c7610f1d865f384efc8892cfdc101
4
- data.tar.gz: 78ebe1fcea394135f0d634d4fffe5117c61f82d0ea019962cb1179eb67254c22
3
+ metadata.gz: 63379d32f224c7837c6b5bdef6ae3113f91b772e2438ff13ab19a9e8dee6c0b2
4
+ data.tar.gz: a78cfaf8135f28c6ba2c0ed2d81c302a3a2cf35064a9354fe982680b1f72c4b3
5
5
  SHA512:
6
- metadata.gz: de1291f967fb645e50efc5383688fdaef256dd0829241e35b2b357caac2325853d630684f5a69184a61eb5986701a78a5036bd932f36195741e9d944573c41d0
7
- data.tar.gz: df183fca89151abb786bc49bc9aaac0d980430baba4235b9098452e4c9a0d7e4f6c20d82995689405c9b35b5f155f7589eff9eb4c5cbbc8c381f922dec0e5e3d
6
+ metadata.gz: 4985434b6d8c25d897f6c98e2abff60b79cb18510b86d61e445991fccec43dc6688be44d7ffe5bc68716f0132c8fd7c483a8490c964fb87e3db1c4a467b1bda2
7
+ data.tar.gz: 3c22ed6535c0f193b40f3202fae6bcf8a0f7021ac61f95989ba56c4330a1d56ea2ed4f8a11caa0df5eb0e3e8edf0690b804808d2e1216ed0c2ec615e9d9fb2ff
data/Gemfile CHANGED
@@ -19,7 +19,7 @@ source "https://rubygems.org"
19
19
  gemspec
20
20
 
21
21
  group :development do
22
- gem "chefstyle", "1.7.4"
22
+ gem "chefstyle", "2.2.0"
23
23
  gem "rake", ">= 10.1.0"
24
24
  gem "rspec", "~> 3.0"
25
25
  gem "simplecov"
data/chef-apply.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.description = "Ad-hoc management of individual nodes and devices."
30
30
  spec.homepage = "https://github.com/chef/chef-apply"
31
31
  spec.license = "Apache-2.0"
32
- spec.required_ruby_version = ">= 2.6"
32
+ spec.required_ruby_version = ">= 2.7"
33
33
 
34
34
  spec.files = %w{Rakefile LICENSE warning.txt} +
35
35
  Dir.glob("Gemfile*") + # Includes Gemfile and locks
data/i18n/en.yml CHANGED
@@ -17,18 +17,11 @@
17
17
 
18
18
  cli:
19
19
  telemetry_enabled: |
20
- Telemetry has been enabled by default for this beta release
21
- of chef-run. The anonymous data we gather is used to
22
- determine how we can impove your chef-run experience.
20
+ Telemetry is enabled by default in chef-run. The anonymous data we gather
21
+ is used to determine how we can impove your chef-run experience.
23
22
 
24
- To disable it, add the following entry to
25
- %1:
26
-
27
- [telemetry]
28
- enabled=false
29
-
30
- For more information about what we data gather and additional opt-out
31
- options, visit https://docs.chef.io/workstation/privacy/
23
+ For more information about what we data gather and opt-out options,
24
+ visit https://docs.chef.io/workstation/privacy/
32
25
 
33
26
  description: |
34
27
  Chef Run is a tool to execute ad-hoc tasks using Chef Infra.
@@ -41,17 +41,17 @@ module ChefApply
41
41
  def run(&block)
42
42
  @notification_handler = block
43
43
  Telemeter.timed_action_capture(self) do
44
- begin
45
- perform_action
46
- rescue StandardError => e
47
- # Give the caller a chance to clean up - if an exception is
48
- # raised it'll otherwise get routed through the executing thread,
49
- # providing no means of feedback for the caller's current task.
50
- notify(:error, e)
51
- @error = e
52
- end
44
+
45
+ perform_action
46
+ rescue StandardError => e
47
+ # Give the caller a chance to clean up - if an exception is
48
+ # raised it'll otherwise get routed through the executing thread,
49
+ # providing no means of feedback for the caller's current task.
50
+ notify(:error, e)
51
+ @error = e
52
+
53
53
  end
54
- # Raise outside the block to ensure that the telemetry cpature completes
54
+ # Raise outside the block to ensure that the telemetry capture completes
55
55
  raise @error unless @error.nil?
56
56
  end
57
57
 
@@ -197,7 +197,7 @@ module ChefApply::Action
197
197
  "exit $LASTEXITCODE"
198
198
  else
199
199
  # cd is shell a builtin, so we'll invoke bash. This also means all commands are executed
200
- # with sudo (as long as we are hardcoding our sudo use)
200
+ # with sudo (as long as we are hard coding our sudo use)
201
201
  "bash -c 'cd #{working_dir}; /opt/chef/bin/chef-client -z --config #{File.join(working_dir, config_file)} --recipe-url #{File.join(working_dir, policy)}'"
202
202
  end
203
203
  end
@@ -69,7 +69,7 @@ module ChefApply
69
69
 
70
70
  def from_resource(resource_type, resource_name, properties)
71
71
  # Generate a cookbook containing a single default recipe with the specified
72
- # resource in it. Incloud the resource type in the cookbook name so hopefully
72
+ # resource in it. Include the resource type in the cookbook name so hopefully
73
73
  # this gives us better reporting info in the future.
74
74
  @descriptor = "#{resource_type}[#{resource_name}]"
75
75
  @from = "resource"
@@ -36,6 +36,10 @@ module ChefApply
36
36
  13 => Gem::Version.new("13.10.4"),
37
37
  14 => Gem::Version.new("14.1.1"),
38
38
  },
39
+ solaris: {
40
+ 13 => Gem::Version.new("13.10.4"),
41
+ 14 => Gem::Version.new("14.1.1"),
42
+ },
39
43
  }.freeze
40
44
 
41
45
  def self.check!(target, check_only)
@@ -14,7 +14,6 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
  #
17
-
18
17
  require_relative "base"
19
18
  require_relative "install_chef/minimum_chef_version"
20
19
  require "fileutils" unless defined?(FileUtils)
@@ -98,6 +97,10 @@ module ChefApply
98
97
  opts[:platform] = "el"
99
98
  when "suse"
100
99
  opts[:platform] = "sles"
100
+ when "solaris"
101
+ opts[:platform] = "solaris2"
102
+ when "aix"
103
+ opts[:platform] = "aix"
101
104
  when "amazon"
102
105
  opts[:platform] = "el"
103
106
  if platform.release.to_i > 2010 # legacy Amazon version 1
@@ -50,7 +50,7 @@ module ChefApply
50
50
 
51
51
  # Special note:
52
52
  # config_path is pre-processed in startup.rb, and is shown here only
53
- # for purpoess of rendering help text.
53
+ # for the purpose of rendering help text.
54
54
  klass.option :config_path,
55
55
  short: "-c PATH",
56
56
  long: "--config PATH",
@@ -138,7 +138,7 @@ module ChefApply
138
138
  end
139
139
 
140
140
  # I really don't like that mixlib-cli refers to the parsed command line flags in
141
- # a hash accesed via the `config` method. Thats just such an overloaded word.
141
+ # a hash accessed via the `config` method. Thats just such an overloaded word.
142
142
  def parsed_options
143
143
  config
144
144
  end
@@ -69,11 +69,11 @@ module ChefApply
69
69
  # they will be captured in the same telemetry session.
70
70
 
71
71
  Chef::Telemeter.timed_run_capture([:redacted]) do
72
- begin
73
- perform_run(enforce_license: enforce_license)
74
- rescue Exception => e
75
- @rc = handle_run_error(e)
76
- end
72
+
73
+ perform_run(enforce_license: enforce_license)
74
+ rescue Exception => e
75
+ @rc = handle_run_error(e)
76
+
77
77
  end
78
78
  rescue => e # can occur if exception thrown in error handling
79
79
  @rc = handle_run_error(e)
@@ -211,7 +211,7 @@ module ChefApply
211
211
  end
212
212
  end
213
213
 
214
- # Runs a GenerateCookbook action based on recipe/resource infoprovided
214
+ # Runs a GenerateCookbook action based on recipe/resource info provided
215
215
  # and renders UI updates as the action reports back
216
216
  def generate_temp_cookbook(arguments, reporter)
217
217
  opts = if arguments.length == 1
@@ -44,25 +44,25 @@ module ChefApply
44
44
  file = open(temp_path, "wb")
45
45
  ChefApply::Log.debug "Downloading: #{temp_path}"
46
46
  Net::HTTP.start(url.host) do |http|
47
- begin
48
- http.request_get(url.path) do |resp|
49
- resp.read_body do |segment|
50
- file.write(segment)
51
- end
52
- end
53
- rescue e
54
- @error = true
55
- raise
56
- ensure
57
- file.close
58
- # If any failures occurred, don't risk keeping
59
- # an incomplete download that we'll see as 'cached'
60
- if @error
61
- FileUtils.rm_f(temp_path)
62
- else
63
- FileUtils.mv(temp_path, local_path)
47
+
48
+ http.request_get(url.path) do |resp|
49
+ resp.read_body do |segment|
50
+ file.write(segment)
64
51
  end
65
52
  end
53
+ rescue e
54
+ @error = true
55
+ raise
56
+ ensure
57
+ file.close
58
+ # If any failures occurred, don't risk keeping
59
+ # an incomplete download that we'll see as 'cached'
60
+ if @error
61
+ FileUtils.rm_f(temp_path)
62
+ else
63
+ FileUtils.mv(temp_path, local_path)
64
+ end
65
+
66
66
  end
67
67
  end
68
68
  end
@@ -43,7 +43,7 @@ module ChefApply
43
43
 
44
44
  # Call this every time, so that if we add or change ~/.chef-workstation
45
45
  # directory structure, we can be sure that it exists. Even with a
46
- # custom configuration, the .chef-workstation directory and subdirs
46
+ # custom configuration, the .chef-workstation directory and sub-dirs
47
47
  # are required.
48
48
  setup_workstation_user_directories
49
49
 
@@ -65,7 +65,7 @@ module ChefApply
65
65
  start_chef_apply(enforce_license: enforce_license)
66
66
 
67
67
  # NOTE: Because these exceptions occur outside of the
68
- # CLI handling, they won't be tracked in telemtry.
68
+ # CLI handling, they won't be tracked in telemetry.
69
69
  # We can revisit this once the pending error handling rework
70
70
  # is underway.
71
71
  rescue ConfigPathInvalid => e
@@ -149,7 +149,7 @@ module ChefApply
149
149
  end
150
150
 
151
151
  def setup_error_handling
152
- # In Ruby 2.5+ threads print out to stdout when they raise an exception. This is an agressive
152
+ # In Ruby 2.5+ threads print out to stdout when they raise an exception. This is an aggressive
153
153
  # attempt to ensure debugging information is not lost, but in our case it is not necessary
154
154
  # because we handle all the errors ourself. So we disable this to keep output clean.
155
155
  # See https://ruby-doc.org/core-2.5.0/Thread.html#method-c-report_on_exception
@@ -168,7 +168,7 @@ module ChefApply
168
168
  # Look for a user-supplied config path by manually parsing the option.
169
169
  # Note that we can't use Mixlib::CLI for this.
170
170
  # To ensure that ChefApply::CLI initializes with correct
171
- # option defaults, we need to have configuraton loaded before initializing it.
171
+ # option defaults, we need to have configuration loaded before initializing it.
172
172
  def custom_config_path
173
173
  argv.each_with_index do |arg, index|
174
174
  if arg == "--config-path" || arg == "-c"
@@ -0,0 +1,55 @@
1
+ module ChefApply
2
+ class TargetHost
3
+ module Aix
4
+
5
+ def omnibus_manifest_path
6
+ # Note that we can't use File::Join, because that will render for the
7
+ # CURRENT platform - not the platform of the target.
8
+ "/opt/chef/version-manifest.json"
9
+ end
10
+
11
+ def mkdir(path)
12
+ run_command!("mkdir -p #{path}")
13
+ end
14
+
15
+ def chown(path, owner)
16
+ # owner ||= user
17
+ # run_command!("chown #{owner} '#{path}'")
18
+ nil
19
+ end
20
+
21
+ def make_temp_dir
22
+ # We will cache this so that we only run this once
23
+ @tempdir ||= begin
24
+ res = run_command!("bash -c '#{MKTEMP_COMMAND}'")
25
+ res.stdout.chomp.strip
26
+ end
27
+ end
28
+
29
+ def install_package(target_package_path)
30
+ command = "installp -aXYgd #{target_package_path} all"
31
+ run_command!(command)
32
+ end
33
+
34
+ def del_file(path)
35
+ run_command!("rm -rf #{path}")
36
+ end
37
+
38
+ def del_dir(path)
39
+ del_file(path)
40
+ end
41
+
42
+ def ws_cache_path
43
+ "/var/chef-workstation"
44
+ end
45
+
46
+ # Nothing to escape in a unix-based path
47
+ def normalize_path(path)
48
+ path
49
+ end
50
+
51
+ MKTEMP_COMMAND = "d=$(mktemp -d -p${TMPDIR:-/tmp} chef_XXXXXX); echo $d".freeze
52
+
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,55 @@
1
+ module ChefApply
2
+ class TargetHost
3
+ module Solaris
4
+
5
+ def omnibus_manifest_path
6
+ # Note that we can't use File::Join, because that will render for the
7
+ # CURRENT platform - not the platform of the target.
8
+ "/opt/chef/version-manifest.json"
9
+ end
10
+
11
+ def mkdir(path)
12
+ run_command!("mkdir -p #{path}")
13
+ end
14
+
15
+ def chown(path, owner)
16
+ owner ||= user
17
+ run_command!("chown #{owner} '#{path}'")
18
+ nil
19
+ end
20
+
21
+ def make_temp_dir
22
+ # We will cache this so that we only run this once
23
+ @tempdir ||= begin
24
+ res = run_command!("bash -c '#{MKTEMP_COMMAND}'")
25
+ res.stdout.chomp.strip
26
+ end
27
+ end
28
+
29
+ def install_package(target_package_path)
30
+ command = "pkg install -g #{target_package_path} chef"
31
+ run_command!(command)
32
+ end
33
+
34
+ def del_file(path)
35
+ run_command!("rm -rf #{path}")
36
+ end
37
+
38
+ def del_dir(path)
39
+ del_file(path)
40
+ end
41
+
42
+ def ws_cache_path
43
+ "/var/chef-workstation"
44
+ end
45
+
46
+ # Nothing to escape in a unix-based path
47
+ def normalize_path(path)
48
+ path
49
+ end
50
+
51
+ MKTEMP_COMMAND = "d=$(mktemp -d -p${TMPDIR:-/tmp} chef_XXXXXX); echo $d".freeze
52
+
53
+ end
54
+ end
55
+ end
@@ -18,7 +18,6 @@
18
18
  require_relative "log"
19
19
  require_relative "error"
20
20
  require "train"
21
-
22
21
  module ChefApply
23
22
  class TargetHost
24
23
  attr_reader :config, :reporter, :backend, :transport_type
@@ -30,7 +29,7 @@ module ChefApply
30
29
  # We're borrowing a page from train here - because setting up a
31
30
  # reliable connection for testing is a multi-step process,
32
31
  # we'll provide this method which instantiates a TargetHost connected
33
- # to a train mock backend. If the family/name provided resolves to a suported
32
+ # to a train mock backend. If the family/name provided resolves to a supported
34
33
  # OS, this instance will mix-in the supporting methods for the given platform;
35
34
  # otherwise those methods will raise NotImplementedError.
36
35
  def self.mock_instance(url, family: "unknown", name: "unknown",
@@ -142,6 +141,12 @@ module ChefApply
142
141
  when :macos
143
142
  require_relative "target_host/macos"
144
143
  class << self; include ChefApply::TargetHost::MacOS; end
144
+ when :solaris
145
+ require_relative "target_host/solaris"
146
+ class << self; include ChefApply::TargetHost::Solaris; end
147
+ when :aix
148
+ require_relative "target_host/aix"
149
+ class << self; include ChefApply::TargetHost::Aix; end
145
150
  when :other
146
151
  raise ChefApply::TargetHost::UnsupportedTargetOS.new(platform.name)
147
152
  end
@@ -174,12 +179,16 @@ module ChefApply
174
179
  :linux
175
180
  elsif platform.darwin?
176
181
  :macos
182
+ elsif platform.solaris?
183
+ :solaris
184
+ elsif platform.aix?
185
+ :aix
177
186
  else
178
187
  :other
179
188
  end
180
189
  end
181
190
 
182
- # TODO 2019-01-29 not expose this, it's internal implemenation. Same with #backend.
191
+ # TODO 2019-01-29 not expose this, it's internal implementation. Same with #backend.
183
192
  def platform
184
193
  backend.platform
185
194
  end
@@ -312,7 +321,7 @@ module ChefApply
312
321
  case original_exception.message # original_exception.reason
313
322
  when /Sudo requires a password/ # :sudo_password_required
314
323
  "CHEFTRN003"
315
- when /Wrong sudo password/ #:bad_sudo_password
324
+ when /Wrong sudo password/ # :bad_sudo_password
316
325
  "CHEFTRN004"
317
326
  when /Can't find sudo command/, /No such file/, /command not found/ # :sudo_command_not_found
318
327
  # NOTE: In the /No such file/ case, reason will be nil - we still have
@@ -59,7 +59,7 @@ module ChefApply
59
59
  if target =~ /(.*)@(.*)/
60
60
  inline_credentials = $1
61
61
  host = $2
62
- # We'll use a non-greedy match to grab everthinmg up to the first ':'
62
+ # We'll use a non-greedy match to grab everything up to the first ':'
63
63
  # as username if there is no :, credentials is just the username
64
64
  if inline_credentials =~ /(.+?):(.*)/
65
65
  inline_user = $1
@@ -111,7 +111,7 @@ module ChefApply
111
111
  # POSTFIX can contain further ranges itself
112
112
  # This uses a greedy match (.*) to get include every character
113
113
  # up to the last "[" in PREFIX
114
- # $1 - prefix; $2 - x, $3 - y, $4 unproccessed/remaining text
114
+ # $1 - prefix; $2 - x, $3 - y, $4 unprocessed/remaining text
115
115
  TARGET_WITH_RANGE = /^(.*)\[([\p{Alnum}]+):([\p{Alnum}]+)\](.*)/.freeze
116
116
 
117
117
  def do_parse(targets, depth = 0)
@@ -24,7 +24,7 @@ require_relative "text/error_translation"
24
24
  module ChefApply
25
25
  module Text
26
26
  def self._error_table
27
- # Though ther may be several translations, en.yml will be the only one with
27
+ # Though there may be several translations, en.yml will be the only one with
28
28
  # error metadata.
29
29
  path = File.join(_translation_path, "errors", "en.yml")
30
30
  raw_yaml = File.read(path)
@@ -22,7 +22,6 @@ require_relative "../config"
22
22
  require_relative "../log"
23
23
  require_relative "plain_text_element"
24
24
  require_relative "plain_text_header"
25
-
26
25
  module ChefApply
27
26
  module UI
28
27
  class Terminal
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module ChefApply
19
- VERSION = "0.6.3".freeze
19
+ VERSION = "0.9.0".freeze
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-apply
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-05 00:00:00.000000000 Z
11
+ date: 2022-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-cli
@@ -250,8 +250,10 @@ files:
250
250
  - lib/chef_apply/startup.rb
251
251
  - lib/chef_apply/status_reporter.rb
252
252
  - lib/chef_apply/target_host.rb
253
+ - lib/chef_apply/target_host/aix.rb
253
254
  - lib/chef_apply/target_host/linux.rb
254
255
  - lib/chef_apply/target_host/macos.rb
256
+ - lib/chef_apply/target_host/solaris.rb
255
257
  - lib/chef_apply/target_host/windows.rb
256
258
  - lib/chef_apply/target_resolver.rb
257
259
  - lib/chef_apply/telemeter.rb
@@ -281,7 +283,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
281
283
  requirements:
282
284
  - - ">="
283
285
  - !ruby/object:Gem::Version
284
- version: '2.6'
286
+ version: '2.7'
285
287
  required_rubygems_version: !ruby/object:Gem::Requirement
286
288
  requirements:
287
289
  - - ">="