chef-cli 2.0.10 → 3.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -5
- data/chef-cli.gemspec +3 -3
- data/lib/chef-cli/cli.rb +7 -1
- data/lib/chef-cli/command/clean_policy_cookbooks.rb +1 -1
- data/lib/chef-cli/command/clean_policy_revisions.rb +1 -1
- data/lib/chef-cli/command/delete_policy.rb +1 -1
- data/lib/chef-cli/command/delete_policy_group.rb +1 -1
- data/lib/chef-cli/command/export.rb +1 -1
- data/lib/chef-cli/command/generator_commands/chef_exts/generator_desc_resource.rb +1 -0
- data/lib/chef-cli/command/generator_commands/cookbook.rb +1 -1
- data/lib/chef-cli/command/install.rb +1 -1
- data/lib/chef-cli/command/push.rb +1 -1
- data/lib/chef-cli/command/push_archive.rb +1 -1
- data/lib/chef-cli/command/show_policy.rb +1 -1
- data/lib/chef-cli/command/undelete.rb +1 -1
- data/lib/chef-cli/command/update.rb +1 -1
- data/lib/chef-cli/generator.rb +1 -1
- data/lib/chef-cli/skeletons/code_generator/files/default/build_cookbook/kitchen.yml +1 -1
- data/lib/chef-cli/skeletons/code_generator/files/default/chefignore +2 -7
- data/lib/chef-cli/skeletons/code_generator/files/default/repo/README.md +1 -1
- data/lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +1 -1
- data/lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +1 -1
- data/lib/chef-cli/skeletons/code_generator/files/default/repo/data_bags/README.md +4 -4
- data/lib/chef-cli/skeletons/code_generator/files/default/repo/environments/README.md +2 -2
- data/lib/chef-cli/skeletons/code_generator/files/default/repo/roles/README.md +2 -2
- data/lib/chef-cli/skeletons/code_generator/metadata.rb +1 -1
- data/lib/chef-cli/skeletons/code_generator/templates/default/CHANGELOG.md.erb +1 -2
- data/lib/chef-cli/skeletons/code_generator/templates/default/Policyfile.rb.erb +1 -1
- data/lib/chef-cli/skeletons/code_generator/templates/default/build_cookbook/metadata.rb.erb +1 -1
- data/lib/chef-cli/skeletons/code_generator/templates/default/helpers.rb.erb +2 -2
- data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen.yml.erb +3 -3
- data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen_dokken.yml.erb +2 -2
- data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +3 -3
- data/lib/chef-cli/skeletons/code_generator/templates/default/metadata.rb.erb +1 -1
- data/lib/chef-cli/skeletons/code_generator/templates/default/recipe_spec.rb.erb +4 -4
- data/lib/chef-cli/skeletons/code_generator/templates/default/resource.rb.erb +1 -1
- data/lib/chef-cli/version.rb +1 -1
- data/lib/kitchen/provisioner/chef_zero_capture.rb +90 -0
- data/spec/unit/command/generator_commands/build_cookbook_spec.rb +1 -1
- data/spec/unit/command/generator_commands/cookbook_spec.rb +8 -8
- data/spec/unit/command/generator_commands/policyfile_spec.rb +1 -1
- data/spec/unit/command/generator_commands/repo_spec.rb +4 -4
- data/spec/unit/kitchen/provisioner/chef_zero_capture_spec.rb +84 -0
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52fb659d9d9b8f33e6a46e06ff25c62531d7098c0917da319078ab6c280b9f86
|
4
|
+
data.tar.gz: d0148fd63485171a17313682edec5a4bf0f62e6c19d0cb906dd150cbc8599bc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93eca71e26052ee224039df9e0814dff270b0544976e95ed65b3877b14e7538f52e9c295fb8b26cd969c904f27d7fdad404fb6b5e471bc6e67db614795aa0a52
|
7
|
+
data.tar.gz: a6b3181c1531d4a91bf0c9a3670c4ee922c3849d849f7a2d61a00a04ab9911a3405dca60a26aff7f2aa08969b43a5092850fa4ca730d9bdfdf8f7ea0095294f3
|
data/Gemfile
CHANGED
@@ -9,21 +9,22 @@ group :docs do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
group :test do
|
12
|
-
# For ruby 2.4 testing we need to use ohai 14
|
13
|
-
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.5")
|
14
|
-
gem "ohai", "~> 14"
|
15
|
-
end
|
16
12
|
gem "rake"
|
17
13
|
gem "rspec", "~> 3.8"
|
18
14
|
gem "rspec-expectations", "~> 3.8"
|
19
15
|
gem "rspec-mocks", "~> 3.8"
|
20
16
|
gem "cookstyle"
|
21
17
|
gem "chefstyle"
|
18
|
+
gem "test-kitchen", "> 2.5"
|
19
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.6")
|
20
|
+
gem "chef-zero", "~> 14"
|
21
|
+
gem "chef", "~> 15"
|
22
|
+
end
|
22
23
|
end
|
23
24
|
|
24
25
|
group :development do
|
25
26
|
gem "pry"
|
26
27
|
gem "pry-byebug"
|
27
|
-
gem "pry-stack_explorer"
|
28
|
+
gem "pry-stack_explorer", "~> 0.4.0"
|
28
29
|
gem "rb-readline"
|
29
30
|
end
|
data/chef-cli.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright (c)
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |gem|
|
|
29
29
|
gem.license = "Apache-2.0"
|
30
30
|
gem.homepage = "https://www.chef.io/"
|
31
31
|
|
32
|
-
gem.required_ruby_version = ">= 2.
|
32
|
+
gem.required_ruby_version = ">= 2.5"
|
33
33
|
|
34
34
|
gem.files = %w{Rakefile LICENSE} +
|
35
35
|
Dir.glob("Gemfile*") + # Includes Gemfile and locks
|
@@ -43,7 +43,7 @@ Gem::Specification.new do |gem|
|
|
43
43
|
gem.add_dependency "mixlib-shellout", ">= 2.0", "< 4.0"
|
44
44
|
gem.add_dependency "ffi-yajl", ">= 1.0", "< 3.0"
|
45
45
|
gem.add_dependency "minitar", "~> 0.6"
|
46
|
-
gem.add_dependency "chef", ">=
|
46
|
+
gem.add_dependency "chef", ">= 15.0"
|
47
47
|
gem.add_dependency "solve", "< 5.0", "> 2.0"
|
48
48
|
gem.add_dependency "addressable", ">= 2.3.5", "< 2.8"
|
49
49
|
gem.add_dependency "cookbook-omnifetch", "~> 0.5"
|
data/lib/chef-cli/cli.rb
CHANGED
@@ -122,7 +122,13 @@ module ChefCLI
|
|
122
122
|
"Test Kitchen": "kitchen",
|
123
123
|
"Cookstyle": "cookstyle",
|
124
124
|
}.each do |name, cli|
|
125
|
-
|
125
|
+
# @todo when Ruby 2.5/2.6 support goes away this if statement can go away
|
126
|
+
if Gem::Version.new(Bundler::VERSION) >= Gem::Version.new("2")
|
127
|
+
result = Bundler.with_unbundled_env { shell_out("#{cli} --version") }
|
128
|
+
else
|
129
|
+
result = Bundler.with_clean_env { shell_out("#{cli} --version") }
|
130
|
+
end
|
131
|
+
|
126
132
|
if result.exitstatus != 0
|
127
133
|
msg("#{name} version: ERROR")
|
128
134
|
else
|
@@ -216,7 +216,7 @@ module ChefCLI
|
|
216
216
|
if !@cookbook_name_or_path
|
217
217
|
@params_valid = false
|
218
218
|
elsif /-/ =~ File.basename(@cookbook_name_or_path)
|
219
|
-
msg("Hyphens are discouraged in cookbook names as they may cause problems with custom resources. See https://docs.chef.io/ctl_chef
|
219
|
+
msg("Hyphens are discouraged in cookbook names as they may cause problems with custom resources. See https://docs.chef.io/ctl_chef/#chef-generate-cookbook for more information.")
|
220
220
|
end
|
221
221
|
|
222
222
|
if config[:berks] && config[:policy]
|
data/lib/chef-cli/generator.rb
CHANGED
@@ -150,7 +150,7 @@ module ChefCLI
|
|
150
150
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
151
151
|
EOH
|
152
152
|
else
|
153
|
-
raise ArgumentError, "Invalid generator.license setting: #{license}.
|
153
|
+
raise ArgumentError, "Invalid generator.license setting: #{license}. See available licenses at https://docs.chef.io/ctl_chef/#chef-generate-cookbook"
|
154
154
|
end
|
155
155
|
if comment
|
156
156
|
# Ensure there's no trailing whitespace
|
@@ -10,10 +10,6 @@ Icon?
|
|
10
10
|
nohup.out
|
11
11
|
Thumbs.db
|
12
12
|
|
13
|
-
# SASS #
|
14
|
-
########
|
15
|
-
.sass-cache
|
16
|
-
|
17
13
|
# EDITORS #
|
18
14
|
###########
|
19
15
|
.#*
|
@@ -26,11 +22,11 @@ Thumbs.db
|
|
26
22
|
*.tmproj
|
27
23
|
*~
|
28
24
|
\#*
|
29
|
-
mkmf.log
|
30
25
|
REVISION
|
31
26
|
TAGS*
|
32
27
|
tmtags
|
33
28
|
.vscode
|
29
|
+
.editorconfig
|
34
30
|
|
35
31
|
## COMPILED ##
|
36
32
|
##############
|
@@ -43,6 +39,7 @@ tmtags
|
|
43
39
|
*.so
|
44
40
|
*/rdoc/
|
45
41
|
a.out
|
42
|
+
mkmf.log
|
46
43
|
|
47
44
|
# Testing #
|
48
45
|
###########
|
@@ -62,8 +59,6 @@ kitchen.yml*
|
|
62
59
|
Procfile
|
63
60
|
Rakefile
|
64
61
|
spec/*
|
65
|
-
spec/*
|
66
|
-
spec/fixtures/*
|
67
62
|
test/*
|
68
63
|
|
69
64
|
# SCM #
|
@@ -13,7 +13,7 @@ This repository contains several directories, and each directory contains a READ
|
|
13
13
|
|
14
14
|
# Configuration
|
15
15
|
|
16
|
-
The config file, `.chef/config.rb` is a repository-specific configuration file for the knife command line tool. If you're using the Hosted Chef platform, you can download one for your organization from the management console. You can also generate a new config.rb by running `knife configure`. For more information about configuring Knife, see the Knife documentation at https://docs.chef.io/knife
|
16
|
+
The config file, `.chef/config.rb` is a repository-specific configuration file for the knife command line tool. If you're using the Hosted Chef platform, you can download one for your organization from the management console. You can also generate a new config.rb by running `knife configure`. For more information about configuring Knife, see the Knife documentation at https://docs.chef.io/workstation/knife/
|
17
17
|
|
18
18
|
# Next Steps
|
19
19
|
|
@@ -12,9 +12,9 @@ Then we can upload the items in the data bag's directory to the Chef Infra Serve
|
|
12
12
|
|
13
13
|
knife data bag from file example example_item.json
|
14
14
|
|
15
|
-
For more information on data bags, see the Chef docs site:
|
15
|
+
For more information on data bags, see the Chef Infra docs site:
|
16
16
|
|
17
|
-
https://docs.chef.io/data_bags
|
17
|
+
https://docs.chef.io/data_bags/
|
18
18
|
|
19
19
|
# Encrypted Data Bags
|
20
20
|
|
@@ -51,6 +51,6 @@ Use the secret_key to view the contents.
|
|
51
51
|
password: abc123
|
52
52
|
|
53
53
|
|
54
|
-
For more information on encrypted data bags, see the Chef docs site:
|
54
|
+
For more information on encrypted data bags, see the Chef Infra docs site:
|
55
55
|
|
56
|
-
https://docs.chef.io/data_bags
|
56
|
+
https://docs.chef.io/data_bags/
|
@@ -4,6 +4,6 @@ For example, in this directory, you'll find an example environment file called `
|
|
4
4
|
|
5
5
|
knife environment from file environments/example.json
|
6
6
|
|
7
|
-
For more information on environments, see the Chef docs site:
|
7
|
+
For more information on environments, see the Chef Infra docs site:
|
8
8
|
|
9
|
-
https://docs.chef.io/environments
|
9
|
+
https://docs.chef.io/environments/
|
@@ -4,6 +4,6 @@ For example, in this directory, you'll find an example role file called `example
|
|
4
4
|
|
5
5
|
knife role from file roles/example.json
|
6
6
|
|
7
|
-
For more information on roles, see the Chef docs site:
|
7
|
+
For more information on roles, see the Chef Infra docs site:
|
8
8
|
|
9
|
-
https://docs.chef.io/roles
|
9
|
+
https://docs.chef.io/roles/
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Policyfile.rb - Describe how you want Chef Infra Client to build your system.
|
2
2
|
#
|
3
3
|
# For more information on the Policyfile feature, visit
|
4
|
-
# https://docs.chef.io/policyfile
|
4
|
+
# https://docs.chef.io/policyfile/
|
5
5
|
|
6
6
|
# A name that describes what the system you're building with Chef does.
|
7
7
|
name '<%= policy_name %>'
|
@@ -17,15 +17,15 @@ provisioner:
|
|
17
17
|
always_update_cookbooks: true
|
18
18
|
|
19
19
|
## product_name and product_version specifies a specific Chef product and version to install.
|
20
|
-
## see the Chef documentation for more details: https://docs.chef.io/config_yml_kitchen
|
20
|
+
## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
|
21
21
|
# product_name: chef
|
22
|
-
# product_version:
|
22
|
+
# product_version: 16
|
23
23
|
|
24
24
|
verifier:
|
25
25
|
name: inspec
|
26
26
|
|
27
27
|
platforms:
|
28
|
-
- name: ubuntu-
|
28
|
+
- name: ubuntu-20.04
|
29
29
|
- name: centos-8
|
30
30
|
|
31
31
|
suites:
|
@@ -14,9 +14,9 @@ verifier:
|
|
14
14
|
platforms:
|
15
15
|
# @see https://github.com/chef-cookbooks/testing_examples/blob/master/kitchen.dokken.yml
|
16
16
|
# @see https://hub.docker.com/u/dokken
|
17
|
-
- name: ubuntu-
|
17
|
+
- name: ubuntu-20.04
|
18
18
|
driver:
|
19
|
-
image: dokken/ubuntu-
|
19
|
+
image: dokken/ubuntu-20.04
|
20
20
|
pid_one_command: /bin/systemd
|
21
21
|
intermediate_instructions:
|
22
22
|
- RUN /usr/bin/apt-get update
|
@@ -13,15 +13,15 @@ provisioner:
|
|
13
13
|
name: chef_zero
|
14
14
|
|
15
15
|
## product_name and product_version specifies a specific Chef product and version to install.
|
16
|
-
## see the Chef documentation for more details: https://docs.chef.io/config_yml_kitchen
|
16
|
+
## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
|
17
17
|
# product_name: chef
|
18
|
-
# product_version:
|
18
|
+
# product_version: 16
|
19
19
|
|
20
20
|
verifier:
|
21
21
|
name: inspec
|
22
22
|
|
23
23
|
platforms:
|
24
|
-
- name: ubuntu-
|
24
|
+
- name: ubuntu-20.04
|
25
25
|
- name: centos-8
|
26
26
|
|
27
27
|
suites:
|
@@ -4,7 +4,7 @@ maintainer_email '<%= email %>'
|
|
4
4
|
license '<%= @spdx_license %>'
|
5
5
|
description 'Installs/Configures <%= cookbook_name %>'
|
6
6
|
version '0.1.0'
|
7
|
-
chef_version '>=
|
7
|
+
chef_version '>= 15.0'
|
8
8
|
|
9
9
|
# The `issues_url` points to the location where issues for this cookbook are
|
10
10
|
# tracked. A `View Issues` link will be displayed on this cookbook's page when
|
@@ -7,20 +7,20 @@
|
|
7
7
|
require 'spec_helper'
|
8
8
|
|
9
9
|
describe '<%= cookbook_name %>::<%= recipe_name %>' do
|
10
|
-
context 'When all attributes are default, on Ubuntu
|
10
|
+
context 'When all attributes are default, on Ubuntu 20.04' do
|
11
11
|
# for a complete list of available platforms and versions see:
|
12
12
|
# https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md
|
13
|
-
platform 'ubuntu', '
|
13
|
+
platform 'ubuntu', '20.04'
|
14
14
|
|
15
15
|
it 'converges successfully' do
|
16
16
|
expect { chef_run }.to_not raise_error
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
context 'When all attributes are default, on CentOS
|
20
|
+
context 'When all attributes are default, on CentOS 8' do
|
21
21
|
# for a complete list of available platforms and versions see:
|
22
22
|
# https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md
|
23
|
-
platform 'centos', '
|
23
|
+
platform 'centos', '8'
|
24
24
|
|
25
25
|
it 'converges successfully' do
|
26
26
|
expect { chef_run }.to_not raise_error
|
@@ -1 +1 @@
|
|
1
|
-
# To learn more about Custom Resources, see https://docs.chef.io/custom_resources
|
1
|
+
# To learn more about Custom Resources, see https://docs.chef.io/custom_resources/
|
data/lib/chef-cli/version.rb
CHANGED
@@ -0,0 +1,90 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Marc Paradise <marc@chef.io>
|
4
|
+
#
|
5
|
+
# Copyright (C) 2020, Chef Software Inc
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require "json"
|
20
|
+
require "kitchen"
|
21
|
+
require "kitchen/provisioner/base"
|
22
|
+
require "kitchen/provisioner/chef_zero"
|
23
|
+
|
24
|
+
module Kitchen
|
25
|
+
module Provisioner
|
26
|
+
# For use in a provisioner that does not do any run list evaluation or
|
27
|
+
# policy/berks file expansion.
|
28
|
+
class ChefZeroCaptureSandbox < Chef::CommonSandbox
|
29
|
+
def populate
|
30
|
+
super
|
31
|
+
prepare(:policies)
|
32
|
+
prepare(:policy_groups)
|
33
|
+
prepare(:cookbook_artifacts)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Override #prepare_cookbooks because we don't want any cookbook resolving to occur
|
37
|
+
# via kitchen through berks, policy
|
38
|
+
def prepare_cookbooks
|
39
|
+
cp_cookbooks
|
40
|
+
filter_only_cookbook_files
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# chef-zero provisioner intended for use with `chef capture`.
|
45
|
+
#
|
46
|
+
# This provisioner does not do any cookbook dependency
|
47
|
+
# resolution and will not pull in external cookbooks. All cookbooks
|
48
|
+
# or cookbook artificats + policy data as captured from the live node and are
|
49
|
+
# expected to be available for chef-zero to provide to the client.
|
50
|
+
class ChefZeroCapture < ChefZero
|
51
|
+
# Declaring these ensure that they're available to the sandbox - it's initialized
|
52
|
+
# the provider's configoptions.
|
53
|
+
default_config :policies_path, "policies"
|
54
|
+
default_config :policy_groups_path, "policy_groups"
|
55
|
+
default_config :cookbook_artifacts_path, "cookbook_artifacts"
|
56
|
+
|
57
|
+
# This will load policyfile/berkshelf. We don't want either - the client resolves all
|
58
|
+
# dependencies from chef-zero, exactly as preppped in the captured repository.
|
59
|
+
def load_needed_dependencies!; end
|
60
|
+
|
61
|
+
def create_sandbox
|
62
|
+
# We have to invoke the the true Base create_sandbox because it does setup that
|
63
|
+
# we want. However, we do not want to invoke the create_sandbox inherited from
|
64
|
+
# ChefZero/ChefBase - those will create and populate a ChefCommonSandbox instead
|
65
|
+
# of a ChefZeroCaptureSandbox.
|
66
|
+
m = Base.instance_method(:create_sandbox).bind(self)
|
67
|
+
m.call
|
68
|
+
|
69
|
+
# These behaviors from super we _do_ want, so we need to copy them here.
|
70
|
+
prepare_validation_pem
|
71
|
+
prepare_config_rb
|
72
|
+
ChefZeroCaptureSandbox.new(config, sandbox_path, instance).populate
|
73
|
+
end
|
74
|
+
|
75
|
+
# Overriding the private ProviderChefZero#default_config_rb
|
76
|
+
# so that we can add additional configuratoin required for chef-zeor
|
77
|
+
# to be able to locate our policies/, policy groups, and cookbook artifacts
|
78
|
+
# at run-time.
|
79
|
+
def default_config_rb
|
80
|
+
cfg = super
|
81
|
+
# Need to tell chef-zero about our additional config.
|
82
|
+
root = config[:root_path].gsub("$env:TEMP", "\#{ENV['TEMP']\}")
|
83
|
+
cfg[:policies_path] = remote_path_join(root, config[:policies_path])
|
84
|
+
cfg[:policy_groups_path] = remote_path_join(root, config[:policy_groups_path])
|
85
|
+
cfg[:cookbook_artifacts_path] = remote_path_join(root, config[:cookbook_artifacts_path])
|
86
|
+
cfg
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -129,7 +129,7 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
|
|
129
129
|
|
130
130
|
it "warns if a hyphenated cookbook name is passed" do
|
131
131
|
expect(with_argv(%w{my-cookbook}).run).to eq(0)
|
132
|
-
message = "Hyphens are discouraged in cookbook names as they may cause problems with custom resources. See https://docs.chef.io/ctl_chef
|
132
|
+
message = "Hyphens are discouraged in cookbook names as they may cause problems with custom resources. See https://docs.chef.io/ctl_chef/#chef-generate-cookbook for more information."
|
133
133
|
expect(stdout_io.string).to include(message)
|
134
134
|
end
|
135
135
|
|
@@ -523,7 +523,7 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
|
|
523
523
|
# Policyfile.rb - Describe how you want Chef Infra Client to build your system.
|
524
524
|
#
|
525
525
|
# For more information on the Policyfile feature, visit
|
526
|
-
# https://docs.chef.io/policyfile
|
526
|
+
# https://docs.chef.io/policyfile/
|
527
527
|
|
528
528
|
# A name that describes what the system you're building with Chef does.
|
529
529
|
name 'new_cookbook'
|
@@ -571,15 +571,15 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
|
|
571
571
|
name: chef_zero
|
572
572
|
|
573
573
|
## product_name and product_version specifies a specific Chef product and version to install.
|
574
|
-
## see the Chef documentation for more details: https://docs.chef.io/config_yml_kitchen
|
574
|
+
## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
|
575
575
|
# product_name: chef
|
576
|
-
# product_version:
|
576
|
+
# product_version: 16
|
577
577
|
|
578
578
|
verifier:
|
579
579
|
name: inspec
|
580
580
|
|
581
581
|
platforms:
|
582
|
-
- name: ubuntu-
|
582
|
+
- name: ubuntu-20.04
|
583
583
|
- name: centos-8
|
584
584
|
|
585
585
|
suites:
|
@@ -658,15 +658,15 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
|
|
658
658
|
always_update_cookbooks: true
|
659
659
|
|
660
660
|
## product_name and product_version specifies a specific Chef product and version to install.
|
661
|
-
## see the Chef documentation for more details: https://docs.chef.io/config_yml_kitchen
|
661
|
+
## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
|
662
662
|
# product_name: chef
|
663
|
-
# product_version:
|
663
|
+
# product_version: 16
|
664
664
|
|
665
665
|
verifier:
|
666
666
|
name: inspec
|
667
667
|
|
668
668
|
platforms:
|
669
|
-
- name: ubuntu-
|
669
|
+
- name: ubuntu-20.04
|
670
670
|
- name: centos-8
|
671
671
|
|
672
672
|
suites:
|
@@ -118,7 +118,7 @@ describe ChefCLI::Command::GeneratorCommands::Policyfile do
|
|
118
118
|
# Policyfile.rb - Describe how you want Chef Infra Client to build your system.
|
119
119
|
#
|
120
120
|
# For more information on the Policyfile feature, visit
|
121
|
-
# https://docs.chef.io/policyfile
|
121
|
+
# https://docs.chef.io/policyfile/
|
122
122
|
|
123
123
|
# A name that describes what the system you're building with Chef does.
|
124
124
|
name 'my-app-frontend'
|
@@ -331,9 +331,9 @@ describe ChefCLI::Command::GeneratorCommands::Repo do
|
|
331
331
|
|
332
332
|
knife role from file roles/example.json
|
333
333
|
|
334
|
-
For more information on roles, see the Chef docs site:
|
334
|
+
For more information on roles, see the Chef Infra docs site:
|
335
335
|
|
336
|
-
https://docs.chef.io/roles
|
336
|
+
https://docs.chef.io/roles/
|
337
337
|
README
|
338
338
|
end
|
339
339
|
|
@@ -355,9 +355,9 @@ describe ChefCLI::Command::GeneratorCommands::Repo do
|
|
355
355
|
|
356
356
|
knife environment from file environments/example.json
|
357
357
|
|
358
|
-
For more information on environments, see the Chef docs site:
|
358
|
+
For more information on environments, see the Chef Infra docs site:
|
359
359
|
|
360
|
-
https://docs.chef.io/environments
|
360
|
+
https://docs.chef.io/environments/
|
361
361
|
README
|
362
362
|
end
|
363
363
|
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Marc Paradsie <marc.paradise@gmail.com>
|
4
|
+
#
|
5
|
+
# Copyright (C) 2020 Chef Software Inc
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative "../../../spec_helper"
|
20
|
+
|
21
|
+
require "kitchen"
|
22
|
+
require "kitchen/provisioner/chef_zero_capture"
|
23
|
+
|
24
|
+
describe Kitchen::Provisioner::ChefZeroCapture do
|
25
|
+
let(:logged_output) { StringIO.new }
|
26
|
+
let(:logger) { Logger.new(logged_output) }
|
27
|
+
let(:kitchen_root) { Dir.mktmpdir }
|
28
|
+
|
29
|
+
let(:config) do
|
30
|
+
{ test_base_path: "/t", base_path: "/b", kitchen_root: kitchen_root, root_path: kitchen_root }
|
31
|
+
end
|
32
|
+
let(:platform) { double("platform", os_type: nil) }
|
33
|
+
let(:suite) { double("suite", name: "fried") }
|
34
|
+
|
35
|
+
let(:instance_config) do
|
36
|
+
double("config", name: "coolbeans", logger: logger, suite: suite, platform: platform)
|
37
|
+
end
|
38
|
+
|
39
|
+
subject do
|
40
|
+
p = Kitchen::Provisioner::ChefZeroCapture.new(config)
|
41
|
+
p.finalize_config!(instance_config)
|
42
|
+
end
|
43
|
+
|
44
|
+
after do
|
45
|
+
FileUtils.remove_entry(kitchen_root)
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#create_sandbox" do
|
49
|
+
let(:sandbox_mock) do
|
50
|
+
double("sandbox", populate: nil)
|
51
|
+
end
|
52
|
+
before do
|
53
|
+
allow(Kitchen::Provisioner::ChefZeroCaptureSandbox).to receive(:new).and_return sandbox_mock
|
54
|
+
end
|
55
|
+
|
56
|
+
it "initializes files and populates a ChefZeroCaptureSandbox" do
|
57
|
+
expect(subject).to receive(:prepare_validation_pem)
|
58
|
+
expect(subject).to receive(:prepare_config_rb)
|
59
|
+
expect(sandbox_mock).to receive(:populate)
|
60
|
+
subject.create_sandbox
|
61
|
+
end
|
62
|
+
|
63
|
+
after do
|
64
|
+
begin
|
65
|
+
subject.cleanup_sandbox
|
66
|
+
rescue # rubocop:disable Lint/HandleExceptions
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#default_config_rb" do
|
72
|
+
it "contains keys that suggest 'super' was invoked for full config_rb setup" do
|
73
|
+
cfg = subject.default_config_rb
|
74
|
+
expect(cfg[:node_path]).to eq File.join(kitchen_root, "nodes")
|
75
|
+
end
|
76
|
+
|
77
|
+
it "adds the expected correct config for captured nodes" do
|
78
|
+
cfg = subject.default_config_rb
|
79
|
+
expect(cfg[:policies_path]).to eq File.join(kitchen_root, "policies")
|
80
|
+
expect(cfg[:cookbook_artifacts_path]).to eq File.join(kitchen_root, "cookbook_artifacts")
|
81
|
+
expect(cfg[:policy_groups_path]).to eq File.join(kitchen_root, "policy_groups")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.10
|
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: 2020-
|
11
|
+
date: 2020-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-cli
|
@@ -90,14 +90,14 @@ dependencies:
|
|
90
90
|
requirements:
|
91
91
|
- - ">="
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: '
|
93
|
+
version: '15.0'
|
94
94
|
type: :runtime
|
95
95
|
prerelease: false
|
96
96
|
version_requirements: !ruby/object:Gem::Requirement
|
97
97
|
requirements:
|
98
98
|
- - ">="
|
99
99
|
- !ruby/object:Gem::Version
|
100
|
-
version: '
|
100
|
+
version: '15.0'
|
101
101
|
- !ruby/object:Gem::Dependency
|
102
102
|
name: solve
|
103
103
|
requirement: !ruby/object:Gem::Requirement
|
@@ -389,6 +389,7 @@ files:
|
|
389
389
|
- lib/chef-cli/skeletons/code_generator/templates/default/template.erb
|
390
390
|
- lib/chef-cli/ui.rb
|
391
391
|
- lib/chef-cli/version.rb
|
392
|
+
- lib/kitchen/provisioner/chef_zero_capture.rb
|
392
393
|
- lib/kitchen/provisioner/policyfile_zero.rb
|
393
394
|
- spec/shared/a_file_generator.rb
|
394
395
|
- spec/shared/a_generated_file.rb
|
@@ -527,6 +528,7 @@ files:
|
|
527
528
|
- spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/metadata.rb
|
528
529
|
- spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/recipes/default.rb
|
529
530
|
- spec/unit/generator_spec.rb
|
531
|
+
- spec/unit/kitchen/provisioner/chef_zero_capture_spec.rb
|
530
532
|
- spec/unit/pager_spec.rb
|
531
533
|
- spec/unit/policyfile/artifactory_cookbook_source_spec.rb
|
532
534
|
- spec/unit/policyfile/attribute_merge_checker_spec.rb
|
@@ -592,7 +594,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
592
594
|
requirements:
|
593
595
|
- - ">="
|
594
596
|
- !ruby/object:Gem::Version
|
595
|
-
version: '2.
|
597
|
+
version: '2.5'
|
596
598
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
597
599
|
requirements:
|
598
600
|
- - ">="
|
@@ -741,6 +743,7 @@ test_files:
|
|
741
743
|
- spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/metadata.rb
|
742
744
|
- spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/recipes/default.rb
|
743
745
|
- spec/unit/generator_spec.rb
|
746
|
+
- spec/unit/kitchen/provisioner/chef_zero_capture_spec.rb
|
744
747
|
- spec/unit/pager_spec.rb
|
745
748
|
- spec/unit/policyfile/artifactory_cookbook_source_spec.rb
|
746
749
|
- spec/unit/policyfile/attribute_merge_checker_spec.rb
|