chef-apply 0.5.16 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -7
- data/Rakefile +0 -7
- data/chef-apply.gemspec +1 -1
- data/i18n/en.yml +18 -25
- data/i18n/errors/en.yml +5 -5
- data/lib/chef_apply/action/base.rb +9 -9
- data/lib/chef_apply/action/converge_target.rb +1 -1
- data/lib/chef_apply/action/install_chef.rb +6 -0
- data/lib/chef_apply/action/install_chef/minimum_chef_version.rb +4 -0
- data/lib/chef_apply/cli.rb +5 -5
- data/lib/chef_apply/file_fetcher.rb +17 -17
- data/lib/chef_apply/target_host.rb +5 -0
- data/lib/chef_apply/target_host/macos.rb +69 -0
- data/lib/chef_apply/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f30291abd4af8458afefb7462bce10d03a063fe81b97eebd51d531cb3f143b9
|
4
|
+
data.tar.gz: 999fe608ed0c409c242079e43de8f19a9498b5310a262b632de2594175803c63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35be39538674afbaa34893e1231e34c5ddedc6b5ca13c251a2cb3e75790ed41a332d3ca04f130bc9c18cdf563f45d12aa003f290bb88f1cd555d228cabd3e987
|
7
|
+
data.tar.gz: 5438e35ec7367378afcc841bcca6e3e57f35b98cc0153ab67d9d8515321d4c65a69c5214fcbacaa8a8d89dfe13d2fcce4fb40f3acdfb6ddcfa6ff8f1de01cc9f
|
data/Gemfile
CHANGED
@@ -19,18 +19,12 @@ source "https://rubygems.org"
|
|
19
19
|
gemspec
|
20
20
|
|
21
21
|
group :development do
|
22
|
-
gem "chefstyle", "
|
22
|
+
gem "chefstyle", "2.0.7"
|
23
23
|
gem "rake", ">= 10.1.0"
|
24
24
|
gem "rspec", "~> 3.0"
|
25
25
|
gem "simplecov"
|
26
26
|
end
|
27
27
|
|
28
|
-
group :docs do
|
29
|
-
gem "yard"
|
30
|
-
gem "redcarpet"
|
31
|
-
gem "github-markup"
|
32
|
-
end
|
33
|
-
|
34
28
|
group :debug do
|
35
29
|
gem "pry"
|
36
30
|
gem "pry-byebug"
|
data/Rakefile
CHANGED
@@ -24,13 +24,6 @@ rescue LoadError
|
|
24
24
|
puts "chefstyle gem is not installed. bundle install first to make sure all dependencies are installed."
|
25
25
|
end
|
26
26
|
|
27
|
-
begin
|
28
|
-
require "yard"
|
29
|
-
YARD::Rake::YardocTask.new(:docs)
|
30
|
-
rescue LoadError
|
31
|
-
puts "yard is not available. bundle install first to make sure all dependencies are installed."
|
32
|
-
end
|
33
|
-
|
34
27
|
task :console do
|
35
28
|
require "irb"
|
36
29
|
require "irb/completion"
|
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.
|
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,21 +17,14 @@
|
|
17
17
|
|
18
18
|
cli:
|
19
19
|
telemetry_enabled: |
|
20
|
-
Telemetry
|
21
|
-
|
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
|
-
|
25
|
-
|
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
|
-
Chef Run is a tool to execute ad-hoc tasks using Chef.
|
27
|
+
Chef Run is a tool to execute ad-hoc tasks using Chef Infra.
|
35
28
|
creating_config: "Creating config file in %1."
|
36
29
|
default_config_location: "Location of config file. Default: %1"
|
37
30
|
identity_file: "SSH identity file to use when connecting. Keys loaded into ssh-agent will also be used."
|
@@ -44,9 +37,9 @@ cli:
|
|
44
37
|
Current default: %1
|
45
38
|
cookbook_repo_paths: "Comma separated list of cookbook repository paths."
|
46
39
|
install_description: |
|
47
|
-
Install Chef
|
40
|
+
Install Chef Infra Client on the target host(s) if it is not installed.
|
48
41
|
This defaults to enabled - the installation will be performed
|
49
|
-
if there is no Chef
|
42
|
+
if there is no Chef Infra Client on the target(s).
|
50
43
|
user_description: |
|
51
44
|
Username to use for authentication to the target(s). The same
|
52
45
|
username will be used for all targets.
|
@@ -102,7 +95,7 @@ cli:
|
|
102
95
|
in the form:
|
103
96
|
|
104
97
|
ssh://[USERNAME]@example.com[:PORT]
|
105
|
-
<RESOURCE> A Chef resource, such as 'user' or 'package'
|
98
|
+
<RESOURCE> A Chef Infra resource, such as 'user' or 'package'
|
106
99
|
<RESOURCE_NAME> The name, usually used to specify what 'thing' to set up with
|
107
100
|
the resource. For example, given resource 'user', 'name' would be
|
108
101
|
the name of the user you wanted to create.
|
@@ -179,16 +172,16 @@ status:
|
|
179
172
|
exporting: Generating local policyfile... exporting...
|
180
173
|
success: Generating local policyfile... exporting... done!
|
181
174
|
install_chef:
|
182
|
-
checking_for_client: Checking for Chef
|
183
|
-
verifying: Verifying Chef
|
184
|
-
downloading: Downloading Chef
|
185
|
-
uploading: Uploading Chef
|
186
|
-
installing: Installing Chef
|
187
|
-
upgrading: Upgrading Chef
|
188
|
-
already_present: Chef
|
189
|
-
install_success: Successfully installed Chef
|
190
|
-
upgrade_success: Successfully upgraded Chef
|
191
|
-
failure: "An error occurred while installing Chef
|
175
|
+
checking_for_client: Checking for Chef Infra Client.
|
176
|
+
verifying: Verifying Chef Infra Client installation.
|
177
|
+
downloading: Downloading Chef Infra Client installer into local cache.
|
178
|
+
uploading: Uploading Chef Infra Client installer to target.
|
179
|
+
installing: Installing Chef Infra Client version %1.
|
180
|
+
upgrading: Upgrading Chef Infra Client from version %1 to %2.
|
181
|
+
already_present: Chef Infra Client version %1 already installed on target.
|
182
|
+
install_success: Successfully installed Chef Infra Client version %1
|
183
|
+
upgrade_success: Successfully upgraded Chef Infra Client from version %1 to %2.
|
184
|
+
failure: "An error occurred while installing Chef Infra Client: %1"
|
192
185
|
converge:
|
193
186
|
header: !!pl
|
194
187
|
1: Applying %2 from %3 to target.
|
data/i18n/errors/en.yml
CHANGED
@@ -71,8 +71,8 @@ errors:
|
|
71
71
|
text: |
|
72
72
|
The target does not have chef-client installed.
|
73
73
|
|
74
|
-
This command is powered by the Chef
|
75
|
-
on this node, the Chef
|
74
|
+
This command is powered by the Chef Infra Client. In order to make use of it
|
75
|
+
on this node, the Chef Infra Client must be installed first.
|
76
76
|
|
77
77
|
Re-running this command without the '--no-install' flag will
|
78
78
|
automatically perform the installation.
|
@@ -91,12 +91,12 @@ errors:
|
|
91
91
|
|
92
92
|
CHEFINS003:
|
93
93
|
text: |
|
94
|
-
The target has an older version of Chef
|
94
|
+
The target has an older version of Chef Infra Client installed.
|
95
95
|
|
96
96
|
The target has version %1 installed, but this command
|
97
97
|
requires a minimum version of %2.
|
98
98
|
|
99
|
-
Please upgrade the Chef
|
99
|
+
Please upgrade the Chef Infra Client on this node to version %2 or later.
|
100
100
|
|
101
101
|
# Local errors trying to create policy to send to target
|
102
102
|
CHEFPOLICY001:
|
@@ -240,7 +240,7 @@ errors:
|
|
240
240
|
|
241
241
|
Try...
|
242
242
|
- Provide a password with "--password PASSWORD"
|
243
|
-
- Provide a key with "
|
243
|
+
- Provide a key with "--identity-file PATH/TO/FILE"
|
244
244
|
- Enable ssh-agent and add keys
|
245
245
|
- Add a host entry to your ssh configuration
|
246
246
|
|
@@ -41,15 +41,15 @@ module ChefApply
|
|
41
41
|
def run(&block)
|
42
42
|
@notification_handler = block
|
43
43
|
Telemeter.timed_action_capture(self) do
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
54
|
# Raise outside the block to ensure that the telemetry cpature completes
|
55
55
|
raise @error unless @error.nil?
|
@@ -198,7 +198,7 @@ module ChefApply::Action
|
|
198
198
|
else
|
199
199
|
# cd is shell a builtin, so we'll invoke bash. This also means all commands are executed
|
200
200
|
# with sudo (as long as we are hardcoding our sudo use)
|
201
|
-
"bash -c 'cd #{working_dir}; chef-client -z --config #{File.join(working_dir, config_file)} --recipe-url #{File.join(working_dir, policy)}'"
|
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
|
204
204
|
|
@@ -86,6 +86,12 @@ module ChefApply
|
|
86
86
|
platform_version_compatibility_mode: true,
|
87
87
|
}
|
88
88
|
case platform.name
|
89
|
+
when /mac_os_x/
|
90
|
+
if platform.release.to_i >= 17
|
91
|
+
opts[:platform_version] = "10.13"
|
92
|
+
else
|
93
|
+
raise NotImplementedError
|
94
|
+
end
|
89
95
|
when /windows/
|
90
96
|
opts[:platform] = "windows"
|
91
97
|
when "redhat", "centos"
|
data/lib/chef_apply/cli.rb
CHANGED
@@ -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
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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)
|
@@ -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
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
@@ -139,6 +139,9 @@ module ChefApply
|
|
139
139
|
when :windows
|
140
140
|
require_relative "target_host/windows"
|
141
141
|
class << self; include ChefApply::TargetHost::Windows; end
|
142
|
+
when :macos
|
143
|
+
require_relative "target_host/macos"
|
144
|
+
class << self; include ChefApply::TargetHost::MacOS; end
|
142
145
|
when :other
|
143
146
|
raise ChefApply::TargetHost::UnsupportedTargetOS.new(platform.name)
|
144
147
|
end
|
@@ -169,6 +172,8 @@ module ChefApply
|
|
169
172
|
:windows
|
170
173
|
elsif platform.linux?
|
171
174
|
:linux
|
175
|
+
elsif platform.darwin?
|
176
|
+
:macos
|
172
177
|
else
|
173
178
|
:other
|
174
179
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright (c) 2017 Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
module ChefApply
|
19
|
+
class TargetHost
|
20
|
+
module MacOS
|
21
|
+
def omnibus_manifest_path
|
22
|
+
# TODO - if habitat install on target, this won't work
|
23
|
+
# Note that we can't use File::Join, because that will render for the
|
24
|
+
# CURRENT platform - not the platform of the target.
|
25
|
+
"/opt/chef/version-manifest.json"
|
26
|
+
end
|
27
|
+
|
28
|
+
def mkdir(path)
|
29
|
+
run_command!("mkdir -p #{path}")
|
30
|
+
end
|
31
|
+
|
32
|
+
def chown(path, owner)
|
33
|
+
owner ||= user
|
34
|
+
run_command!("chown #{owner} '#{path}'")
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
|
38
|
+
def install_package(remote_path)
|
39
|
+
install_cmd = <<-EOS
|
40
|
+
hdiutil detach "/Volumes/chef_software" >/dev/null 2>&1 || true
|
41
|
+
hdiutil attach #{remote_path} -mountpoint "/Volumes/chef_software"
|
42
|
+
cd / && sudo /usr/sbin/installer -pkg `sudo find "/Volumes/chef_software" -name \\*.pkg` -target /
|
43
|
+
EOS
|
44
|
+
run_command!(install_cmd)
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
|
48
|
+
def del_file(path)
|
49
|
+
run_command!("rm -rf #{path}")
|
50
|
+
end
|
51
|
+
|
52
|
+
def del_dir(path)
|
53
|
+
del_file(path)
|
54
|
+
end
|
55
|
+
|
56
|
+
def make_temp_dir
|
57
|
+
installer_dir = "/tmp/chef-installer"
|
58
|
+
run_command!("mkdir -p #{installer_dir}")
|
59
|
+
run_command!("chmod 777 #{installer_dir}")
|
60
|
+
installer_dir
|
61
|
+
end
|
62
|
+
|
63
|
+
def ws_cache_path
|
64
|
+
"/var/chef-workstation"
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/chef_apply/version.rb
CHANGED
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.
|
4
|
+
version: 0.7.1
|
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-
|
11
|
+
date: 2021-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-cli
|
@@ -251,6 +251,7 @@ files:
|
|
251
251
|
- lib/chef_apply/status_reporter.rb
|
252
252
|
- lib/chef_apply/target_host.rb
|
253
253
|
- lib/chef_apply/target_host/linux.rb
|
254
|
+
- lib/chef_apply/target_host/macos.rb
|
254
255
|
- lib/chef_apply/target_host/windows.rb
|
255
256
|
- lib/chef_apply/target_resolver.rb
|
256
257
|
- lib/chef_apply/telemeter.rb
|
@@ -280,7 +281,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
280
281
|
requirements:
|
281
282
|
- - ">="
|
282
283
|
- !ruby/object:Gem::Version
|
283
|
-
version: '2.
|
284
|
+
version: '2.7'
|
284
285
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
285
286
|
requirements:
|
286
287
|
- - ">="
|