chef-apply 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/lib/chef_apply/action/base.rb +1 -1
- data/lib/chef_apply/action/converge_target.rb +1 -1
- data/lib/chef_apply/action/generate_temp_cookbook/temp_cookbook.rb +1 -1
- data/lib/chef_apply/action/install_chef.rb +2 -0
- data/lib/chef_apply/cli/options.rb +2 -2
- data/lib/chef_apply/cli.rb +1 -1
- data/lib/chef_apply/startup.rb +4 -4
- data/lib/chef_apply/target_host/aix.rb +55 -0
- data/lib/chef_apply/target_host.rb +7 -2
- data/lib/chef_apply/target_resolver.rb +2 -2
- data/lib/chef_apply/text.rb +1 -1
- data/lib/chef_apply/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63379d32f224c7837c6b5bdef6ae3113f91b772e2438ff13ab19a9e8dee6c0b2
|
4
|
+
data.tar.gz: a78cfaf8135f28c6ba2c0ed2d81c302a3a2cf35064a9354fe982680b1f72c4b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4985434b6d8c25d897f6c98e2abff60b79cb18510b86d61e445991fccec43dc6688be44d7ffe5bc68716f0132c8fd7c483a8490c964fb87e3db1c4a467b1bda2
|
7
|
+
data.tar.gz: 3c22ed6535c0f193b40f3202fae6bcf8a0f7021ac61f95989ba56c4330a1d56ea2ed4f8a11caa0df5eb0e3e8edf0690b804808d2e1216ed0c2ec615e9d9fb2ff
|
data/Gemfile
CHANGED
@@ -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
|
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.
|
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"
|
@@ -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
|
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
|
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
|
data/lib/chef_apply/cli.rb
CHANGED
@@ -211,7 +211,7 @@ module ChefApply
|
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
214
|
-
# Runs a GenerateCookbook action based on recipe/resource
|
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
|
data/lib/chef_apply/startup.rb
CHANGED
@@ -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
|
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
|
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
|
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
|
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
|
@@ -29,7 +29,7 @@ module ChefApply
|
|
29
29
|
# We're borrowing a page from train here - because setting up a
|
30
30
|
# reliable connection for testing is a multi-step process,
|
31
31
|
# we'll provide this method which instantiates a TargetHost connected
|
32
|
-
# to a train mock backend. If the family/name provided resolves to a
|
32
|
+
# to a train mock backend. If the family/name provided resolves to a supported
|
33
33
|
# OS, this instance will mix-in the supporting methods for the given platform;
|
34
34
|
# otherwise those methods will raise NotImplementedError.
|
35
35
|
def self.mock_instance(url, family: "unknown", name: "unknown",
|
@@ -144,6 +144,9 @@ module ChefApply
|
|
144
144
|
when :solaris
|
145
145
|
require_relative "target_host/solaris"
|
146
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
|
147
150
|
when :other
|
148
151
|
raise ChefApply::TargetHost::UnsupportedTargetOS.new(platform.name)
|
149
152
|
end
|
@@ -178,12 +181,14 @@ module ChefApply
|
|
178
181
|
:macos
|
179
182
|
elsif platform.solaris?
|
180
183
|
:solaris
|
184
|
+
elsif platform.aix?
|
185
|
+
:aix
|
181
186
|
else
|
182
187
|
:other
|
183
188
|
end
|
184
189
|
end
|
185
190
|
|
186
|
-
# TODO 2019-01-29 not expose this, it's internal
|
191
|
+
# TODO 2019-01-29 not expose this, it's internal implementation. Same with #backend.
|
187
192
|
def platform
|
188
193
|
backend.platform
|
189
194
|
end
|
@@ -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
|
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
|
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)
|
data/lib/chef_apply/text.rb
CHANGED
@@ -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
|
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)
|
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.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:
|
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,6 +250,7 @@ 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
|
255
256
|
- lib/chef_apply/target_host/solaris.rb
|