chef-cli 2.0.0 → 3.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -11
  3. data/chef-cli.gemspec +5 -5
  4. data/lib/chef-cli/cli.rb +12 -6
  5. data/lib/chef-cli/command/clean_policy_cookbooks.rb +1 -1
  6. data/lib/chef-cli/command/clean_policy_revisions.rb +1 -1
  7. data/lib/chef-cli/command/delete_policy.rb +1 -1
  8. data/lib/chef-cli/command/delete_policy_group.rb +1 -1
  9. data/lib/chef-cli/command/describe_cookbook.rb +1 -1
  10. data/lib/chef-cli/command/export.rb +1 -1
  11. data/lib/chef-cli/command/generator_commands/cookbook.rb +1 -1
  12. data/lib/chef-cli/command/generator_commands/policyfile.rb +2 -2
  13. data/lib/chef-cli/command/install.rb +2 -2
  14. data/lib/chef-cli/command/push.rb +1 -1
  15. data/lib/chef-cli/command/push_archive.rb +1 -1
  16. data/lib/chef-cli/command/show_policy.rb +1 -1
  17. data/lib/chef-cli/command/undelete.rb +1 -1
  18. data/lib/chef-cli/command/update.rb +1 -1
  19. data/lib/chef-cli/dist.rb +8 -0
  20. data/lib/chef-cli/generator.rb +1 -1
  21. data/lib/chef-cli/helpers.rb +2 -2
  22. data/lib/chef-cli/policyfile/cookbook_location_specification.rb +2 -1
  23. data/lib/chef-cli/policyfile/lock_fetcher_mixin.rb +2 -2
  24. data/lib/chef-cli/policyfile/uploader.rb +2 -2
  25. data/lib/chef-cli/policyfile_services/export_repo.rb +5 -0
  26. data/lib/chef-cli/policyfile_services/install.rb +2 -0
  27. data/lib/chef-cli/policyfile_services/rm_policy.rb +1 -1
  28. data/lib/chef-cli/policyfile_services/update_attributes.rb +2 -0
  29. data/lib/chef-cli/skeletons/code_generator/files/default/build_cookbook/README.md +3 -3
  30. data/lib/chef-cli/skeletons/code_generator/files/default/build_cookbook/kitchen.yml +2 -2
  31. data/lib/chef-cli/skeletons/code_generator/files/default/chefignore +4 -8
  32. data/lib/chef-cli/skeletons/code_generator/files/default/cookbook_readmes/README-policy.md +1 -1
  33. data/lib/chef-cli/skeletons/code_generator/files/default/cookbook_readmes/README.md +2 -2
  34. data/lib/chef-cli/skeletons/code_generator/files/default/repo/README.md +1 -1
  35. data/lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/README.md +2 -2
  36. data/lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +1 -1
  37. data/lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +1 -1
  38. data/lib/chef-cli/skeletons/code_generator/files/default/repo/data_bags/README.md +4 -4
  39. data/lib/chef-cli/skeletons/code_generator/files/default/repo/environments/README.md +2 -2
  40. data/lib/chef-cli/skeletons/code_generator/files/default/repo/roles/README.md +2 -2
  41. data/lib/chef-cli/skeletons/code_generator/metadata.rb +1 -1
  42. data/lib/chef-cli/skeletons/code_generator/recipes/build_cookbook.rb +2 -2
  43. data/lib/chef-cli/skeletons/code_generator/recipes/cookbook.rb +1 -1
  44. data/lib/chef-cli/skeletons/code_generator/recipes/repo.rb +1 -1
  45. data/lib/chef-cli/skeletons/code_generator/templates/default/CHANGELOG.md.erb +1 -2
  46. data/lib/chef-cli/skeletons/code_generator/templates/default/Policyfile.rb.erb +1 -1
  47. data/lib/chef-cli/skeletons/code_generator/templates/default/build_cookbook/metadata.rb.erb +1 -1
  48. data/lib/chef-cli/skeletons/code_generator/templates/default/helpers.rb.erb +2 -2
  49. data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen.yml.erb +4 -4
  50. data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen_dokken.yml.erb +4 -4
  51. data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +4 -4
  52. data/lib/chef-cli/skeletons/code_generator/templates/default/metadata.rb.erb +1 -1
  53. data/lib/chef-cli/skeletons/code_generator/templates/default/recipe_spec.rb.erb +4 -4
  54. data/lib/chef-cli/skeletons/code_generator/templates/default/resource.rb.erb +1 -1
  55. data/lib/chef-cli/version.rb +1 -1
  56. data/lib/kitchen/provisioner/chef_zero_capture.rb +90 -0
  57. data/spec/unit/command/generator_commands/build_cookbook_spec.rb +1 -1
  58. data/spec/unit/command/generator_commands/cookbook_spec.rb +12 -12
  59. data/spec/unit/command/generator_commands/policyfile_spec.rb +1 -1
  60. data/spec/unit/command/generator_commands/repo_spec.rb +5 -5
  61. data/spec/unit/kitchen/provisioner/chef_zero_capture_spec.rb +84 -0
  62. data/spec/unit/policyfile/cookbook_location_specification_spec.rb +5 -0
  63. data/spec/unit/policyfile/uploader_spec.rb +2 -2
  64. data/spec/unit/policyfile_lock_build_spec.rb +1 -1
  65. data/spec/unit/policyfile_services/clean_policies_spec.rb +2 -0
  66. data/spec/unit/policyfile_services/update_attributes_spec.rb +1 -1
  67. data/spec/unit/service_exception_inspectors/http_spec.rb +1 -1
  68. metadata +20 -11
@@ -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,10 +22,11 @@ Thumbs.db
26
22
  *.tmproj
27
23
  *~
28
24
  \#*
29
- mkmf.log
30
25
  REVISION
31
26
  TAGS*
32
27
  tmtags
28
+ .vscode
29
+ .editorconfig
33
30
 
34
31
  ## COMPILED ##
35
32
  ##############
@@ -42,6 +39,7 @@ tmtags
42
39
  *.so
43
40
  */rdoc/
44
41
  a.out
42
+ mkmf.log
45
43
 
46
44
  # Testing #
47
45
  ###########
@@ -61,8 +59,6 @@ kitchen.yml*
61
59
  Procfile
62
60
  Rakefile
63
61
  spec/*
64
- spec/*
65
- spec/fixtures/*
66
62
  test/*
67
63
 
68
64
  # SCM #
@@ -97,7 +93,7 @@ Gemfile.lock
97
93
  Policyfile.rb
98
94
  Policyfile.lock.json
99
95
 
100
- # Cookbooks #
96
+ # Documentation #
101
97
  #############
102
98
  CHANGELOG*
103
99
  CONTRIBUTING*
@@ -1,4 +1,4 @@
1
- This directory typically contains Chef cookbooks. This repository was
1
+ This directory typically contains Chef Infra cookbooks. This repository was
2
2
  generated with the '--policy-only' option, which means you have chosen
3
3
  to use a workflow where each cookbook is treated as an independent
4
4
  software project. As a result, any cookbooks present in this directory
@@ -1,4 +1,4 @@
1
- This directory contains the cookbooks used to configure systems in your infrastructure with Chef - an example basic cookbook called `example` has been automatically created for you.
1
+ This directory contains the cookbooks used to configure systems in your infrastructure with Chef Infra - an example basic cookbook called `example` has been automatically created for you.
2
2
 
3
3
  Knife needs to be configured to know where the cookbooks are located with the `cookbook_path` setting. If this is not set, then several cookbook operations will fail to work properly.
4
4
 
@@ -23,7 +23,7 @@ cookbook_email "cookbooks@example.com"
23
23
  cookbook_license "apachev2"
24
24
  ```
25
25
 
26
- Supported values for `cookbook_license` are "apachev2", "mit","gplv2","gplv3", or "none". These settings are used to prefill comments in the default recipe, and the corresponding values in the metadata.rb. You are free to change the the comments in those files.
26
+ Supported values for `cookbook_license` are "apachev2", "mit","gplv2","gplv3", or "none". These settings are used to prefill comments in the default recipe, and the corresponding values in the metadata.rb. You are free to change the comments in those files.
27
27
 
28
28
  Create new cookbooks in this directory with Chef.
29
29
 
@@ -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.html
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
 
@@ -4,11 +4,11 @@ An example cookbook
4
4
 
5
5
  ## Requirements
6
6
 
7
- ### Platforms:
7
+ ### Platforms
8
8
 
9
9
  _No platforms defined_
10
10
 
11
- ### Cookbooks:
11
+ ### Cookbooks
12
12
 
13
13
  _No dependencies defined_
14
14
 
@@ -4,4 +4,4 @@
4
4
  # Set a default name
5
5
  default['example']['name'] = 'Sam Doe'
6
6
 
7
- # For further information, see the Chef documentation (https://docs.chef.io/attributes.html).
7
+ # For further information, see the Chef Infra documentation (https://docs.chef.io/attributes/).
@@ -5,4 +5,4 @@ log "Welcome to Chef Infra Client, #{node['example']['name']}!" do
5
5
  level :info
6
6
  end
7
7
 
8
- # For more information, see the documentation: https://docs.chef.io/recipes.html
8
+ # For more information, see the documentation: https://docs.chef.io/recipes
@@ -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.html
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.html
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.html
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.html
9
+ https://docs.chef.io/roles/
@@ -4,4 +4,4 @@ maintainer_email 'dev@chef.io'
4
4
  license 'Apache-2.0'
5
5
  description 'Generates Chef code for Chef CLI'
6
6
  version '0.1.0'
7
- chef_version '>= 14.0'
7
+ chef_version '>= 15.0'
@@ -11,13 +11,13 @@ directory dot_delivery_dir
11
11
 
12
12
  cookbook_file config_json do
13
13
  source 'delivery-config.json'
14
- not_if { File.exist?(config_json) }
14
+ not_if { ::File.exist?(config_json) }
15
15
  end
16
16
 
17
17
  # Adding the delivery local-mode config
18
18
  cookbook_file project_toml do
19
19
  source 'delivery-project.toml'
20
- not_if { File.exist?(project_toml) }
20
+ not_if { ::File.exist?(project_toml) }
21
21
  end
22
22
 
23
23
  generator_desc('Ensuring correct Workflow (Delivery) build cookbook content')
@@ -129,7 +129,7 @@ unless context.enable_workflow
129
129
  # Adding the delivery local-mode config
130
130
  cookbook_file "#{cookbook_dir}/.delivery/project.toml" do
131
131
  source 'delivery-project.toml'
132
- not_if { File.exist?("#{cookbook_dir}/.delivery/project.toml") }
132
+ not_if { ::File.exist?("#{cookbook_dir}/.delivery/project.toml") }
133
133
  end
134
134
  end
135
135
 
@@ -60,7 +60,7 @@ if context.have_git
60
60
  execute('initialize-git') do
61
61
  command('git init .')
62
62
  cwd repo_dir
63
- not_if { File.exist?("#{repo_dir}/.gitignore") }
63
+ not_if { ::File.exist?("#{repo_dir}/.gitignore") }
64
64
  end
65
65
  end
66
66
  template "#{repo_dir}/.gitignore" do
@@ -2,10 +2,9 @@
2
2
 
3
3
  This file is used to list changes made in each version of the <%= cookbook_name %> cookbook.
4
4
 
5
- # 0.1.0
5
+ ## 0.1.0
6
6
 
7
7
  Initial release.
8
8
 
9
9
  - change 0
10
10
  - change 1
11
-
@@ -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.html
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 %>'
@@ -3,7 +3,7 @@ maintainer '<%= copyright_holder %>'
3
3
  maintainer_email '<%= email %>'
4
4
  license '<%= license %>'
5
5
  version '0.1.0'
6
- chef_version '>= 14.0'
6
+ chef_version '>= 15.0'
7
7
  <% if build_cookbook_parent_is_cookbook -%>
8
8
 
9
9
  depends 'delivery-truck'
@@ -1,6 +1,6 @@
1
1
  #
2
- # Chef Documentation
3
- # https://docs.chef.io/libraries.html
2
+ # Chef Infra Documentation
3
+ # https://docs.chef.io/libraries/
4
4
  #
5
5
 
6
6
  #
@@ -17,16 +17,16 @@ 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.html
20
+ ## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
21
21
  # product_name: chef
22
- # product_version: 15
22
+ # product_version: 16
23
23
 
24
24
  verifier:
25
25
  name: inspec
26
26
 
27
27
  platforms:
28
- - name: ubuntu-18.04
29
- - name: centos-7
28
+ - name: ubuntu-20.04
29
+ - name: centos-8
30
30
 
31
31
  suites:
32
32
  - name: default
@@ -14,16 +14,16 @@ 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-18.04
17
+ - name: ubuntu-20.04
18
18
  driver:
19
- image: dokken/ubuntu-18.04
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
23
23
 
24
- - name: centos-7
24
+ - name: centos-8
25
25
  driver:
26
- image: dokken/centos-7
26
+ image: dokken/centos-8
27
27
  pid_one_command: /usr/lib/systemd/systemd
28
28
 
29
29
  suites:
@@ -13,16 +13,16 @@ 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.html
16
+ ## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
17
17
  # product_name: chef
18
- # product_version: 15
18
+ # product_version: 16
19
19
 
20
20
  verifier:
21
21
  name: inspec
22
22
 
23
23
  platforms:
24
- - name: ubuntu-18.04
25
- - name: centos-7
24
+ - name: ubuntu-20.04
25
+ - name: centos-8
26
26
 
27
27
  suites:
28
28
  - name: default
@@ -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 '>= 14.0'
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 18.04' do
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', '18.04'
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 7' do
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', '7'
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.html
1
+ # To learn more about Custom Resources, see https://docs.chef.io/custom_resources/
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module ChefCLI
19
- VERSION = "2.0.0".freeze
19
+ VERSION = "3.0.9".freeze
20
20
  end
@@ -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
@@ -198,7 +198,7 @@ describe ChefCLI::Command::GeneratorCommands::BuildCookbook do
198
198
  maintainer_email 'you@example.com'
199
199
  license 'all_rights'
200
200
  version '0.1.0'
201
- chef_version '>= 14.0'
201
+ chef_version '>= 15.0'
202
202
 
203
203
  depends 'delivery-truck'
204
204
  METADATA