summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.expeditor/config.yml8
-rw-r--r--.travis.yml38
-rw-r--r--CHANGELOG.md109
-rw-r--r--Dockerfile2
-rw-r--r--Gemfile.lock26
-rw-r--r--RELEASE_NOTES.md203
-rw-r--r--VERSION2
-rw-r--r--chef-config/chef-config.gemspec2
-rw-r--r--chef-config/lib/chef-config/mixin/credentials.rb91
-rw-r--r--chef-config/lib/chef-config/path_helper.rb2
-rw-r--r--chef-config/lib/chef-config/version.rb2
-rw-r--r--lib/chef/application.rb2
-rw-r--r--lib/chef/dsl/platform_introspection.rb5
-rw-r--r--lib/chef/guard_interpreter/resource_guard_interpreter.rb2
-rw-r--r--lib/chef/http/http_request.rb4
-rw-r--r--lib/chef/knife.rb8
-rw-r--r--lib/chef/knife/config_get_profile.rb37
-rw-r--r--lib/chef/knife/config_list_profiles.rb121
-rw-r--r--lib/chef/knife/config_use_profile.rb50
-rw-r--r--lib/chef/knife/core/hashed_command_loader.rb2
-rw-r--r--lib/chef/knife/core/subcommand_loader.rb3
-rw-r--r--lib/chef/platform/query_helpers.rb6
-rw-r--r--lib/chef/provider/user/dscl.rb2
-rw-r--r--lib/chef/provider/windows_task.rb2
-rw-r--r--lib/chef/resource/chocolatey_config.rb2
-rw-r--r--lib/chef/resource/chocolatey_source.rb15
-rw-r--r--lib/chef/resource/dsc_script.rb12
-rw-r--r--lib/chef/resource/homebrew_tap.rb2
-rw-r--r--lib/chef/resource/hostname.rb12
-rw-r--r--lib/chef/resource/ifconfig.rb4
-rw-r--r--lib/chef/resource/kernel_module.rb4
-rw-r--r--lib/chef/resource/ohai_hint.rb6
-rw-r--r--lib/chef/resource/openssl_dhparam.rb2
-rw-r--r--lib/chef/resource/openssl_rsa_private_key.rb2
-rw-r--r--lib/chef/resource/powershell_package.rb3
-rw-r--r--lib/chef/resource/powershell_package_source.rb8
-rw-r--r--lib/chef/resource/rhsm_errata.rb2
-rw-r--r--lib/chef/resource/rhsm_errata_level.rb2
-rw-r--r--lib/chef/resource/rhsm_register.rb8
-rw-r--r--lib/chef/resource/rhsm_repo.rb4
-rw-r--r--lib/chef/resource/rhsm_subscription.rb4
-rw-r--r--lib/chef/resource/script.rb2
-rw-r--r--lib/chef/resource/service.rb2
-rw-r--r--lib/chef/resource/ssh_known_hosts_entry.rb2
-rw-r--r--lib/chef/resource/sudo.rb8
-rw-r--r--lib/chef/resource/sysctl.rb14
-rw-r--r--lib/chef/resource/windows_feature_dism.rb6
-rw-r--r--lib/chef/resource/windows_feature_powershell.rb14
-rw-r--r--lib/chef/resource/windows_service.rb2
-rw-r--r--lib/chef/version.rb2
-rw-r--r--lib/chef/win32/api/security.rb1
-rw-r--r--lib/chef/win32/security.rb13
-rw-r--r--spec/functional/resource/bash_spec.rb2
-rw-r--r--spec/functional/win32/security_spec.rb21
-rw-r--r--spec/integration/knife/config_get_profile_spec.rb112
-rw-r--r--spec/integration/knife/config_list_profiles_spec.rb188
-rw-r--r--spec/integration/knife/config_use_profile_spec.rb100
-rw-r--r--spec/unit/knife/core/hashed_command_loader_spec.rb2
-rw-r--r--spec/unit/provider/execute_spec.rb2
-rw-r--r--spec/unit/provider/service/windows_spec.rb1
-rw-r--r--spec/unit/provider/user/aix_spec.rb1
-rw-r--r--spec/unit/provider/user/dscl_spec.rb1
-rw-r--r--spec/unit/provider/user/solaris_spec.rb1
-rw-r--r--spec/unit/resource/dsc_script_spec.rb20
64 files changed, 1086 insertions, 252 deletions
diff --git a/.expeditor/config.yml b/.expeditor/config.yml
index 30f46c99f4..14e146ab72 100644
--- a/.expeditor/config.yml
+++ b/.expeditor/config.yml
@@ -1,4 +1,4 @@
-# Documentation available at http://expeditor-docs.es.chef.io/
+# Documentation available at https://expeditor.chef.io
# The name of the product keys for this product (from mixlib-install)
product_key:
@@ -42,32 +42,26 @@ github:
version_constraint: 14.*
- chef-13:
version_constraint: 13.*
- - chef-12:
- version_constraint: 12.*
# These actions are taken, in order they are specified, anytime a Pull Request is merged.
merge_actions:
- built_in:bump_version:
ignore_labels:
- - "Version: Skip Bump"
- "Expeditor: Skip Version Bump"
- "Expeditor: Skip All"
- bash:.expeditor/update_version.sh:
only_if: built_in:bump_version
- built_in:update_changelog:
ignore_labels:
- - "Meta: Exclude From Changelog"
- "Expeditor: Exclude From Changelog"
- "Expeditor: Skip All"
- built_in:trigger_habitat_package_build:
ignore_labels:
- - "Omnibus: Skip Build"
- "Expeditor: Skip Build"
- "Expeditor: Skip All"
only_if: built_in:bump_version
- built_in:trigger_omnibus_release_build:
ignore_labels:
- - "Omnibus: Skip Build"
- "Expeditor: Skip Build"
- "Expeditor: Skip All"
only_if: built_in:bump_version
diff --git a/.travis.yml b/.travis.yml
index 3f9bede22d..fa25b9c38b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -26,7 +26,6 @@ branches:
only:
- master
- chef-13
- - chef-12
env:
global:
@@ -115,26 +114,23 @@ matrix:
# script: bundle exec tasks/bin/run_external_test $TEST_GEM master rake spec
# rvm: 2.5.1
### START TEST KITCHEN ONLY ###
- #
- # Amazon Linux 2 disabled pending fixes in omnitruck/mixlib-install
- #
- # - rvm: 2.4.4
- # services: docker
- # sudo: required
- # gemfile: kitchen-tests/Gemfile
- # before_install:
- # - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2)
- # - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2)
- # before_script:
- # - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
- # - cd kitchen-tests
- # script:
- # - bundle exec kitchen test end-to-end-amazonlinux-2
- # after_failure:
- # - cat .kitchen/logs/kitchen.log
- # env:
- # - AMAZON=2
- # - KITCHEN_YAML=kitchen.travis.yml
+ - rvm: 2.4.4
+ services: docker
+ sudo: required
+ gemfile: kitchen-tests/Gemfile
+ before_install:
+ - gem update --system $(grep rubygems omnibus_overrides.rb | cut -d'"' -f2)
+ - gem install bundler -v $(grep :bundler omnibus_overrides.rb | cut -d'"' -f2)
+ before_script:
+ - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
+ - cd kitchen-tests
+ script:
+ - bundle exec kitchen test end-to-end-amazonlinux-2
+ after_failure:
+ - cat .kitchen/logs/kitchen.log
+ env:
+ - AMAZON=2
+ - KITCHEN_YAML=kitchen.travis.yml
- rvm: 2.4.4
services: docker
sudo: required
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bac85f2c22..8ca565aa51 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,59 +1,75 @@
<!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ -->
-<!-- latest_release 14.3.31 -->
-## [v14.3.31](https://github.com/chef/chef/tree/v14.3.31) (2018-07-06)
+<!-- latest_release 14.3.40 -->
+## [v14.3.40](https://github.com/chef/chef/tree/v14.3.40) (2018-07-13)
#### Merged Pull Requests
-- Don&#39;t require rubygems in our binaries [#7428](https://github.com/chef/chef/pull/7428) ([tas50](https://github.com/tas50))
+- Add knife config get/use-profile commands [#7455](https://github.com/chef/chef/pull/7455) ([coderanger](https://github.com/coderanger))
<!-- latest_release -->
-<!-- release_rollup since=14.2.0 -->
-### Changes since 14.2.0 release
+<!-- release_rollup since=14.3.37 -->
+### Changes since 14.3.37 release
#### Merged Pull Requests
-- Don&#39;t require rubygems in our binaries [#7428](https://github.com/chef/chef/pull/7428) ([tas50](https://github.com/tas50)) <!-- 14.3.31 -->
-- fix some chefstyle offenses [#7427](https://github.com/chef/chef/pull/7427) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 14.3.30 -->
-- knife config and a bunch of UX improvements [#7390](https://github.com/chef/chef/pull/7390) ([coderanger](https://github.com/coderanger)) <!-- 14.3.29 -->
-- chefstyle: fix Style/MutableConstant [#7417](https://github.com/chef/chef/pull/7417) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 14.3.28 -->
-- More chefstyle updates [#7415](https://github.com/chef/chef/pull/7415) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 14.3.27 -->
-- Chefstyle fixes [#7414](https://github.com/chef/chef/pull/7414) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 14.3.25 -->
-- Pull in new InSpec and win32-service [#7405](https://github.com/chef/chef/pull/7405) ([tas50](https://github.com/tas50)) <!-- 14.3.24 -->
-- Rename the kitchen base test suite to end-to-end [#7385](https://github.com/chef/chef/pull/7385) ([tas50](https://github.com/tas50)) <!-- 14.3.23 -->
-- Switch powershell_exec mixin to use FFI instead of COM [#7380](https://github.com/chef/chef/pull/7380) ([stuartpreston](https://github.com/stuartpreston)) <!-- 14.3.23 -->
-- Add missing require knife [#7400](https://github.com/chef/chef/pull/7400) ([tas50](https://github.com/tas50)) <!-- 14.3.22 -->
-- Remove sudo/gcc-c++ package installs from kitchen tests [#7398](https://github.com/chef/chef/pull/7398) ([tas50](https://github.com/tas50)) <!-- 14.3.21 -->
-- Remove the existing acceptance testing framework [#7399](https://github.com/chef/chef/pull/7399) ([tas50](https://github.com/tas50)) <!-- 14.3.21 -->
-- Add chocolatey_config and chocolatey_source resources [#7388](https://github.com/chef/chef/pull/7388) ([tas50](https://github.com/tas50)) <!-- 14.3.21 -->
-- Add missing knife license headers [#7397](https://github.com/chef/chef/pull/7397) ([tas50](https://github.com/tas50)) <!-- 14.3.20 -->
-- deprecate old shell_out APIs [#7382](https://github.com/chef/chef/pull/7382) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 14.3.20 -->
-- Rework the credentials file system to support any config keys. [#7387](https://github.com/chef/chef/pull/7387) ([coderanger](https://github.com/coderanger)) <!-- 14.3.19 -->
-- Unification of shell_out APIs [#7372](https://github.com/chef/chef/pull/7372) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 14.3.18 -->
-- Remove the unused audit test cookbook [#7378](https://github.com/chef/chef/pull/7378) ([tas50](https://github.com/tas50)) <!-- 14.3.17 -->
-- Silence deprecation warnings [#7375](https://github.com/chef/chef/pull/7375) ([coderanger](https://github.com/coderanger)) <!-- 14.3.17 -->
-- Remove awesome customers testing and update kitchen configs [#7377](https://github.com/chef/chef/pull/7377) ([tas50](https://github.com/tas50)) <!-- 14.3.16 -->
-- windows_task: Fix for task is not idempotent when task name includes parent folder [#7293](https://github.com/chef/chef/pull/7293) ([Vasu1105](https://github.com/Vasu1105)) <!-- 14.3.16 -->
-- windows_task: Don&#39;t allow bad username/password to be provided to a task which will fail later [#7288](https://github.com/chef/chef/pull/7288) ([Vasu1105](https://github.com/Vasu1105)) <!-- 14.3.15 -->
-- Pull in win32-taskscheduler 1.0.2 [#7371](https://github.com/chef/chef/pull/7371) ([tas50](https://github.com/tas50)) <!-- 14.3.14 -->
-- removing mwrock from client maintainers [#7369](https://github.com/chef/chef/pull/7369) ([mwrock](https://github.com/mwrock)) <!-- 14.3.13 -->
-- Add more property descriptions to resources [#7358](https://github.com/chef/chef/pull/7358) ([tas50](https://github.com/tas50)) <!-- 14.3.12 -->
-- windows_feature_dism: Fix errors when specifying the source [#7370](https://github.com/chef/chef/pull/7370) ([tas50](https://github.com/tas50)) <!-- 14.3.11 -->
-- package: Make sure to use the package_name name properties [#7365](https://github.com/chef/chef/pull/7365) ([tas50](https://github.com/tas50)) <!-- 14.3.10 -->
-- Add missing chef/resource requires in resource [#7364](https://github.com/chef/chef/pull/7364) ([tas50](https://github.com/tas50)) <!-- 14.3.9 -->
-- Update to the latest inspec and liblzma [#7355](https://github.com/chef/chef/pull/7355) ([tas50](https://github.com/tas50)) <!-- 14.3.8 -->
-- Mount: Fix errors on Windows when using the mount_point property [#7284](https://github.com/chef/chef/pull/7284) ([dheerajd-msys](https://github.com/dheerajd-msys)) <!-- 14.3.7 -->
-- Add kernel_module resource from the kernel_module cookbook [#7165](https://github.com/chef/chef/pull/7165) ([tas50](https://github.com/tas50)) <!-- 14.3.6 -->
-- Add ssh_known_hosts_entry resource from ssh_known_hosts cookbook [#7161](https://github.com/chef/chef/pull/7161) ([tas50](https://github.com/tas50)) <!-- 14.3.5 -->
-- Update help link in Add/Remove Programs on Windows [#7345](https://github.com/chef/chef/pull/7345) ([stuartpreston](https://github.com/stuartpreston)) <!-- 14.3.4 -->
-- Implement rfc107: NodeMap locking for resource and provider handlers [#7224](https://github.com/chef/chef/pull/7224) ([coderanger](https://github.com/coderanger)) <!-- 14.3.4 -->
-- Add whyrun message when installing a local file on Windows [#7351](https://github.com/chef/chef/pull/7351) ([josh-barker](https://github.com/josh-barker)) <!-- 14.3.3 -->
-- Make shell_out_compact automatically pull timeouts off the resource + remove uses of shell_out_compact_timeout [#7330](https://github.com/chef/chef/pull/7330) ([lamont-granquist](https://github.com/lamont-granquist)) <!-- 14.3.2 -->
-- Deprecated the Chef::Provider::Package::Freebsd::Pkg provider [#7350](https://github.com/chef/chef/pull/7350) ([tas50](https://github.com/tas50)) <!-- 14.3.1 -->
-- Bump the version to 14.3.0 [#7346](https://github.com/chef/chef/pull/7346) ([tas50](https://github.com/tas50)) <!-- 14.3.0 -->
-- Support windows_feature_powershell on Windows 2008 R2 [#7349](https://github.com/chef/chef/pull/7349) ([tas50](https://github.com/tas50)) <!-- 14.2.3 -->
-- Add skip_publisher_check property to powershell_package [#7259](https://github.com/chef/chef/pull/7259) ([Happycoil](https://github.com/Happycoil)) <!-- 14.2.1 -->
-- Expand development docs with branch/backport + more [#7343](https://github.com/chef/chef/pull/7343) ([tas50](https://github.com/tas50)) <!-- 14.2.2 -->
+- Add knife config get/use-profile commands [#7455](https://github.com/chef/chef/pull/7455) ([coderanger](https://github.com/coderanger)) <!-- 14.3.40 -->
+- Remove require mixlib/shellouts where not necessary [#7457](https://github.com/chef/chef/pull/7457) ([tas50](https://github.com/tas50)) <!-- 14.3.39 -->
+- Add proper yard deprecated tags on methods [#7452](https://github.com/chef/chef/pull/7452) ([tas50](https://github.com/tas50)) <!-- 14.3.38 -->
+- [MSYS-843] - Add remove_account_right function to win32/security [#7445](https://github.com/chef/chef/pull/7445) ([Nimesh-Msys](https://github.com/Nimesh-Msys)) <!-- 14.3.38 -->
<!-- release_rollup -->
<!-- latest_stable_release -->
+## [v14.3.37](https://github.com/chef/chef/tree/v14.3.37) (2018-07-11)
+
+#### Merged Pull Requests
+- Expand development docs with branch/backport + more [#7343](https://github.com/chef/chef/pull/7343) ([tas50](https://github.com/tas50))
+- Add skip_publisher_check property to powershell_package [#7259](https://github.com/chef/chef/pull/7259) ([Happycoil](https://github.com/Happycoil))
+- Support windows_feature_powershell on Windows 2008 R2 [#7349](https://github.com/chef/chef/pull/7349) ([tas50](https://github.com/tas50))
+- Bump the version to 14.3.0 [#7346](https://github.com/chef/chef/pull/7346) ([tas50](https://github.com/tas50))
+- Deprecated the Chef::Provider::Package::Freebsd::Pkg provider [#7350](https://github.com/chef/chef/pull/7350) ([tas50](https://github.com/tas50))
+- Make shell_out_compact automatically pull timeouts off the resource + remove uses of shell_out_compact_timeout [#7330](https://github.com/chef/chef/pull/7330) ([lamont-granquist](https://github.com/lamont-granquist))
+- Add whyrun message when installing a local file on Windows [#7351](https://github.com/chef/chef/pull/7351) ([josh-barker](https://github.com/josh-barker))
+- Implement rfc107: NodeMap locking for resource and provider handlers [#7224](https://github.com/chef/chef/pull/7224) ([coderanger](https://github.com/coderanger))
+- Update help link in Add/Remove Programs on Windows [#7345](https://github.com/chef/chef/pull/7345) ([stuartpreston](https://github.com/stuartpreston))
+- Add ssh_known_hosts_entry resource from ssh_known_hosts cookbook [#7161](https://github.com/chef/chef/pull/7161) ([tas50](https://github.com/tas50))
+- Add kernel_module resource from the kernel_module cookbook [#7165](https://github.com/chef/chef/pull/7165) ([tas50](https://github.com/tas50))
+- Mount: Fix errors on Windows when using the mount_point property [#7284](https://github.com/chef/chef/pull/7284) ([dheerajd-msys](https://github.com/dheerajd-msys))
+- Update to the latest inspec and liblzma [#7355](https://github.com/chef/chef/pull/7355) ([tas50](https://github.com/tas50))
+- Add missing chef/resource requires in resource [#7364](https://github.com/chef/chef/pull/7364) ([tas50](https://github.com/tas50))
+- package: Make sure to use the package_name name properties [#7365](https://github.com/chef/chef/pull/7365) ([tas50](https://github.com/tas50))
+- windows_feature_dism: Fix errors when specifying the source [#7370](https://github.com/chef/chef/pull/7370) ([tas50](https://github.com/tas50))
+- Add more property descriptions to resources [#7358](https://github.com/chef/chef/pull/7358) ([tas50](https://github.com/tas50))
+- removing mwrock from client maintainers [#7369](https://github.com/chef/chef/pull/7369) ([mwrock](https://github.com/mwrock))
+- Pull in win32-taskscheduler 1.0.2 [#7371](https://github.com/chef/chef/pull/7371) ([tas50](https://github.com/tas50))
+- windows_task: Don&#39;t allow bad username/password to be provided to a task which will fail later [#7288](https://github.com/chef/chef/pull/7288) ([Vasu1105](https://github.com/Vasu1105))
+- windows_task: Fix for task is not idempotent when task name includes parent folder [#7293](https://github.com/chef/chef/pull/7293) ([Vasu1105](https://github.com/Vasu1105))
+- Remove awesome customers testing and update kitchen configs [#7377](https://github.com/chef/chef/pull/7377) ([tas50](https://github.com/tas50))
+- Silence deprecation warnings [#7375](https://github.com/chef/chef/pull/7375) ([coderanger](https://github.com/coderanger))
+- Remove the unused audit test cookbook [#7378](https://github.com/chef/chef/pull/7378) ([tas50](https://github.com/tas50))
+- Unification of shell_out APIs [#7372](https://github.com/chef/chef/pull/7372) ([lamont-granquist](https://github.com/lamont-granquist))
+- Rework the credentials file system to support any config keys. [#7387](https://github.com/chef/chef/pull/7387) ([coderanger](https://github.com/coderanger))
+- deprecate old shell_out APIs [#7382](https://github.com/chef/chef/pull/7382) ([lamont-granquist](https://github.com/lamont-granquist))
+- Add missing knife license headers [#7397](https://github.com/chef/chef/pull/7397) ([tas50](https://github.com/tas50))
+- Add chocolatey_config and chocolatey_source resources [#7388](https://github.com/chef/chef/pull/7388) ([tas50](https://github.com/tas50))
+- Remove the existing acceptance testing framework [#7399](https://github.com/chef/chef/pull/7399) ([tas50](https://github.com/tas50))
+- Remove sudo/gcc-c++ package installs from kitchen tests [#7398](https://github.com/chef/chef/pull/7398) ([tas50](https://github.com/tas50))
+- Add missing require knife [#7400](https://github.com/chef/chef/pull/7400) ([tas50](https://github.com/tas50))
+- Switch powershell_exec mixin to use FFI instead of COM [#7380](https://github.com/chef/chef/pull/7380) ([stuartpreston](https://github.com/stuartpreston))
+- Rename the kitchen base test suite to end-to-end [#7385](https://github.com/chef/chef/pull/7385) ([tas50](https://github.com/tas50))
+- Pull in new InSpec and win32-service [#7405](https://github.com/chef/chef/pull/7405) ([tas50](https://github.com/tas50))
+- Chefstyle fixes [#7414](https://github.com/chef/chef/pull/7414) ([lamont-granquist](https://github.com/lamont-granquist))
+- More chefstyle updates [#7415](https://github.com/chef/chef/pull/7415) ([lamont-granquist](https://github.com/lamont-granquist))
+- chefstyle: fix Style/MutableConstant [#7417](https://github.com/chef/chef/pull/7417) ([lamont-granquist](https://github.com/lamont-granquist))
+- knife config and a bunch of UX improvements [#7390](https://github.com/chef/chef/pull/7390) ([coderanger](https://github.com/coderanger))
+- fix some chefstyle offenses [#7427](https://github.com/chef/chef/pull/7427) ([lamont-granquist](https://github.com/lamont-granquist))
+- Don&#39;t require rubygems in our binaries [#7428](https://github.com/chef/chef/pull/7428) ([tas50](https://github.com/tas50))
+- bump chefstyle + inspec-core [#7431](https://github.com/chef/chef/pull/7431) ([lamont-granquist](https://github.com/lamont-granquist))
+- Fix dupe stdout_logger [#7401](https://github.com/chef/chef/pull/7401) ([nsdavidson](https://github.com/nsdavidson))
+- Prevent failures using windows_feature due to the platform helper [#7433](https://github.com/chef/chef/pull/7433) ([tas50](https://github.com/tas50))
+- Bump Ohai to 14.3.0 [#7437](https://github.com/chef/chef/pull/7437) ([tas50](https://github.com/tas50))
+- Enable Amazon Linux 2.0 tests again [#7442](https://github.com/chef/chef/pull/7442) ([tas50](https://github.com/tas50))
+- Add missing descriptions and add periods after resource the descriptions [#7444](https://github.com/chef/chef/pull/7444) ([tas50](https://github.com/tas50))
+- Attributes -&gt; Properties in a few more resources [#7448](https://github.com/chef/chef/pull/7448) ([tas50](https://github.com/tas50))
+<!-- latest_stable_release -->
+
## [v14.2.0](https://github.com/chef/chef/tree/v14.2.0) (2018-06-07)
#### Merged Pull Requests
@@ -83,7 +99,6 @@
- Quote git remote_url property (PR 6249 + chefstyle fix) [#7014](https://github.com/chef/chef/pull/7014) ([tas50](https://github.com/tas50))
- Use inspec-core, new ffi gem, and bump deps [#7332](https://github.com/chef/chef/pull/7332) ([lamont-granquist](https://github.com/lamont-granquist))
- bump ohai to 14.2.0 [#7333](https://github.com/chef/chef/pull/7333) ([lamont-granquist](https://github.com/lamont-granquist))
-<!-- latest_stable_release -->
## [v14.1.12](https://github.com/chef/chef/tree/v14.1.12) (2018-05-16)
diff --git a/Dockerfile b/Dockerfile
index 0ca62b4d12..60dadabedf 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,7 +2,7 @@ FROM busybox
MAINTAINER Chef Software, Inc. <docker@chef.io>
ARG CHANNEL=stable
-ARG VERSION=14.2.0
+ARG VERSION=14.3.37
RUN wget "http://packages.chef.io/files/${CHANNEL}/chef/${VERSION}/el/6/chef-${VERSION}-1.el6.x86_64.rpm" -O /tmp/chef-client.rpm && \
rpm2cpio /tmp/chef-client.rpm | cpio -idmv && \
diff --git a/Gemfile.lock b/Gemfile.lock
index 57ecbc1af8..ae78ccb62c 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/chef/chefstyle.git
- revision: fac2105b132fddc5f671411b2b5f1cba7a2307c3
+ revision: c16b9ceab413259bda43a2d683f1f918c1be3db5
branch: master
specs:
chefstyle (0.10.0)
@@ -9,10 +9,10 @@ GIT
PATH
remote: .
specs:
- chef (14.3.31)
+ chef (14.3.40)
addressable
bundler (>= 1.10)
- chef-config (= 14.3.31)
+ chef-config (= 14.3.40)
chef-zero (>= 13.0)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
@@ -40,10 +40,10 @@ PATH
specinfra (~> 2.10)
syslog-logger (~> 1.6)
uuidtools (~> 2.1.5)
- chef (14.3.31-universal-mingw32)
+ chef (14.3.40-universal-mingw32)
addressable
bundler (>= 1.10)
- chef-config (= 14.3.31)
+ chef-config (= 14.3.40)
chef-zero (>= 13.0)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
@@ -86,10 +86,10 @@ PATH
PATH
remote: chef-config
specs:
- chef-config (14.3.31)
+ chef-config (14.3.40)
addressable
fuzzyurl
- mixlib-config (>= 2.2.11, < 3.0)
+ mixlib-config (>= 2.2.12, < 3.0)
mixlib-shellout (~> 2.0)
tomlrb (~> 1.2)
@@ -149,7 +149,7 @@ GEM
highline (1.7.10)
htmlentities (4.3.4)
iniparse (1.4.4)
- inspec-core (2.2.27)
+ inspec-core (2.2.34)
addressable (~> 2.4)
faraday (>= 0.9.0)
hashie (~> 3.4)
@@ -179,7 +179,7 @@ GEM
mixlib-log
mixlib-authentication (2.1.1)
mixlib-cli (1.7.0)
- mixlib-config (2.2.12)
+ mixlib-config (2.2.13)
tomlrb
mixlib-log (2.0.4)
mixlib-shellout (2.3.2)
@@ -204,7 +204,7 @@ GEM
netrc (0.11.0)
octokit (4.9.0)
sawyer (~> 0.8.0, >= 0.5.3)
- ohai (14.2.0)
+ ohai (14.3.0)
chef-config (>= 12.8, < 15)
ffi (~> 1.9)
ffi-yajl (~> 2.2)
@@ -289,9 +289,9 @@ GEM
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
slop (3.6.0)
- specinfra (2.73.4)
+ specinfra (2.75.0)
net-scp
- net-ssh (>= 2.7, < 5.0)
+ net-ssh (>= 2.7)
net-telnet
sfl
sslshake (1.2.0)
@@ -300,7 +300,7 @@ GEM
systemu (2.6.5)
thor (0.20.0)
tomlrb (1.2.7)
- train-core (1.4.19)
+ train-core (1.4.21)
json (>= 1.8, < 3.0)
mixlib-shellout (~> 2.0)
travis (1.8.8)
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 6b601bd569..68a31e9882 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -1,9 +1,135 @@
This file holds "in progress" release notes for the current release under development and is intended for consumption by the Chef Documentation team. Please see <https://docs.chef.io/release_notes.html> for the official Chef release notes.
+## Knife configuration profile management commands
+
+Several new commands have been added under `knife config` to help manage multiple
+profiles in your `credentials` file.
+
+`knife config get-profile` will display the active profile.
+
+`knife config use-profile PROFILE` will set the workstation-level default
+profile. That default can still be overridden by the `--profile` command line
+option or the `$CHEF_PROFILE` environment variable.
+
+`knife config list-profiles` will display all your available profiles along with
+summary information on each.
+
+```bash
+$ knife config get-profile
+staging
+$ knife config use-profile prod
+Set default profile to prod
+$ knife config list-profiles
+ Profile Client Key Server
+-----------------------------------------------------------------------------
+ staging myuser ~/.chef/user.pem https://example.com/organizations/staging
+*prod myuser ~/.chef/user.pem https://example.com/organizations/prod
+```
+
+# Chef Client Release Notes 14.3:
+
+## New Preview Resources Concept
+
+This release of Chef introduces the concept of Preview Resources. Preview resources behave the same as a standard resource built into Chef, except Chef will load a resource with the same name from a cookbook instead of the built-in preview resource.
+
+What does this mean for you? It means we can introduce new resources in Chef without breaking existing behavior in your infrastructure. For instance if you have a cookbook with a resource named `manage_everything` and a future version of Chef introduced a preview resource named `manage_everything` you will continue to receive the resource from your cookbook. That way outside of a major release your won't experience a potentially breaking behavior change from the newly included resource.
+
+Then when we perform our yearly major release we'll remove the preview designation from all resources, and the built in resources will take precedence over resources with the same names in cookbooks.
+
+## New Resources
+
+### chocolatey_config
+
+Use the chocolatey_config resource to add or remove Chocolatey configuration keys."
+
+#### Actions
+
+- `set` - Sets a Chocolatey config value.
+- `unset` - Unsets a Chocolatey config value.
+
+#### Properties
+
+- `config_key` - The name of the config. We'll use the resource's name if this isn't provided.
+- `value` - The value to set.
+
+### chocolatey_source
+
+Use the chocolatey_source resource to add or remove Chocolatey sources.
+
+#### Actions
+
+- `add` - Adds a Chocolatey source.
+- `remove` - Removes a Chocolatey source.
+
+#### Properties
+
+- `source_name` - The name of the source to add. We'll use the resource's name if this isn't provided.
+- `source` - The source URL.
+- `bypass_proxy` - Whether or not to bypass the system's proxy settings to access the source.
+- `priority` - The priority level of the source.
+
+### powershell_package_source
+
+Use the `powershell_package_source` resource to register a powershell package repository.
+
+### Actions
+
+- `register` - Registers and updates the powershell package source.
+- `unregister` - Unregisters the powershell package source.
+
+#### Properties
+
+- `source_name` - The name of the package source.
+- `url` - The url to the package source.
+- `trusted` - Whether or not to trust packages from this source.
+- `provider_name` - The package management provider for the source. It supports the following providers: 'Programs', 'msi', 'NuGet', 'msu', 'PowerShellGet', 'psl' and 'chocolatey'.
+- `publish_location` - The url where modules will be published to for this source. Only valid if the provider is 'PowerShellGet'.
+- `script_source_location` - The url where scripts are located for this source. Only valid if the provider is 'PowerShellGet'.
+- `script_publish_location` - The location where scripts will be published to for this source. Only valid if the provider is 'PowerShellGet'.
+
+### kernel_module
+
+Use the kernel_module resource to manage kernel modules on Linux systems. This resource can load, unload, blacklist, install, and uninstall modules.
+
+#### Actions
+
+- `install` - Load kernel module, and ensure it loads on reboot.
+- `uninstall` - Unload a kernel module and remove module config, so it doesn't load on reboot.
+- `blacklist` - Blacklist a kernel module.
+- `load` - Load a kernel module.
+- `unload` - Unload kernel module
+
+#### Properties
+
+- `modname` - The name of the kernel module.
+- `load_dir` - The directory to load modules from.
+- `unload_dir` - The modprobe.d directory.
+
+### ssh_known_hosts_entry
+
+Use the ssh_known_hosts_entry resource to add an entry for the specified host in /etc/ssh/ssh_known_hosts or a user's known hosts file if specified.
+
+#### Actions
+
+- `create` - Create an entry in the ssh_known_hosts file.
+- `flush` - Immediately flush the entries to the config file. Without this the actual writing of the file is delayed in the Chef run so all entries can be accumulated before writing the file out.
+
+#### Properties
+
+- `host` - The host to add to the known hosts file.
+- `key` - An optional key for the host. If not provided this will be automatically determined.
+- `key_type` - The type of key to store.
+- `port` - The server port that the ssh-keyscan command will use to gather the public key.
+- `timeout` - The timeout in seconds for ssh-keyscan.
+- `mode` - The file mode for the ssh_known_hosts file.
+- `owner`- The file owner for the ssh_known_hosts file.
+- `group` - The file group for the ssh_known_hosts file.
+- `hash_entries` - Hash the hostname and addresses in the ssh_known_hosts file for privacy.
+- `file_location` - The location of the ssh known hosts file. Change this to set a known host file for a particular user.
+
## New `knife config get` command
-The `knife config get` command has been added to help with debugging configuration
-issues with `knife` and other tools that use the `knife.rb` file.
+The `knife config get` command has been added to help with debugging configuration issues with `knife` and other tools that use the `knife.rb` file.
With no arguments, it will display all options you've set:
@@ -19,12 +145,11 @@ node_name: ...
validation_key:
```
-You can also pass specific keys to only display those `knife config get node_name client_key`,
-or use `--all` to display everything (including options that are using the default value).
+You can also pass specific keys to only display those `knife config get node_name client_key`, or use `--all` to display everything (including options that are using the default value).
## Simplification of `shell_out` APIs
-The following methods are deprecated:
+The following helper methods have been deprecated in favor of the single shell_out helper:
- `shell_out_with_systems_locale`
- `shell_out_with_timeout`
@@ -35,40 +160,21 @@ The following methods are deprecated:
- `shell_out_compact!`
- `shell_out_compact_timeout!`
-The functionality of `shell_out_with_systems_locale` has been implemented using the `default_env: false`
-option that removes the PATH and locale mangling that has been the default behavior of `shell_out`.
+The functionality of `shell_out_with_systems_locale` has been implemented using the `default_env: false` option that removes the PATH and locale mangling that has been the default behavior of `shell_out`.
-The functionality of `shell_out_compact` has been folded into `shell_out`. The `shell_out` API when called
-with varargs has its arguments flatted, compacted and coerced to strings. This style of calling is encouraged
-over using strings and building up commands using `join(" ")` since it avoids shell interpolation and edge
-conditions in the construction of spaces between arguments. The varargs form is still not supported on
-Windows.
+The functionality of `shell_out_compact` has been folded into `shell_out`. The `shell_out` API when called with varargs has its arguments flatted, compacted and coerced to strings. This style of calling is encouraged over using strings and building up commands using `join(" ")` since it avoids shell interpolation and edge conditions in the construction of spaces between arguments. The varargs form is still not supported on Windows.
-The functionality of `shell_out*timeout` has also been folded into `shell_out`. Users writing Custom Resources
-should be explicit for Chef-14: `shell_out!("whatever", timeout: new_resource.timeout)` which will become
-automatic in Chef-15.
+The functionality of `shell_out*timeout` has also been folded into `shell_out`. Users writing Custom Resources should be explicit for Chef-14: `shell_out!("whatever", timeout: new_resource.timeout)` which will become automatic in Chef-15.
## Silencing deprecation warnings
-While deprecation warnings have been great for the Chef community to ensure
-cookbooks are kept up-to-date and to prepare for major version upgrades, sometimes
-you just can't fix a deprecation right now. This is often compounded by the
-recommendation to enable `treat_deprecation_warnings_as_errors` mode in your
-Test Kitchen integration tests, which doesn't understand the difference between
-deprecations from community cookbooks and those from your own code.
+While deprecation warnings have been great for the Chef community to ensure cookbooks are kept up-to-date and to prepare for major version upgrades, sometimes you just can't fix a deprecation right now. This is often compounded by the recommendation to enable `treat_deprecation_warnings_as_errors` mode in your Test Kitchen integration tests, which doesn't understand the difference between deprecations from community cookbooks and those from your own code.
-Two new options are provided for silencing deprecation warnings: `silence_deprecation_warnings`
-and inline `chef:silence_deprecation` comments.
+Two new options are provided for silencing deprecation warnings: `silence_deprecation_warnings` and inline `chef:silence_deprecation` comments.
-The `silence_deprecation_warnings` configuration value can be set in your
-`client.rb` or `solo.rb` config file, either to `true` to silence all deprecation
-warnings or to an array of deprecations to silence. You can specify which to
-silence either by the deprecation key name (e.g. `"internal_api"`), the numeric
-deprecation ID (e.g. `25` or `"CHEF-25"`), or by specifying the filename and
-line number where the deprecation is being raised from (e.g. `"default.rb:67"`).
+The `silence_deprecation_warnings` configuration value can be set in your `client.rb` or `solo.rb` config file, either to `true` to silence all deprecation warnings or to an array of deprecations to silence. You can specify which to silence either by the deprecation key name (e.g. `"internal_api"`), the numeric deprecation ID (e.g. `25` or `"CHEF-25"`), or by specifying the filename and line number where the deprecation is being raised from (e.g. `"default.rb:67"`).
-An example of setting the `silence_deprecation_warnings` option in your `client.rb`
-or `solo.rb`:
+An example of setting the `silence_deprecation_warnings` option in your `client.rb` or `solo.rb`:
```ruby
silence_deprecation_warnings %w{deploy_resource chef-23 recipes/install.rb:22}
@@ -87,15 +193,34 @@ provisioner:
- recipes/install.rb:22
```
-You can also silence deprecations using a comment on the line that is raising
-the warning:
+You can also silence deprecations using a comment on the line that is raising the warning:
```ruby
erl_call 'something' do # chef:silence_deprecation
```
-We advise caution in the use of this feature, as excessive or prolonged silencing
-can lead to difficulty upgrading when the next major release of Chef comes out.
+We advise caution in the use of this feature, as excessive or prolonged silencing can lead to difficulty upgrading when the next major release of Chef comes out.
+
+## Misc Windows improvements
+
+- A new `skip_publisher_check` property has been added to the `powershell_package` resource
+- `windows_feature_powershell` now supports Windows 2008 R2
+- The `mount` resource now supports the `mount_point` property on Windows
+- `windows_feature_dism` no longer errors when specifying the source
+- Resolved idempotency issues in the `windows_task` resource and prevented setting up a task with bad credentials
+- `windows_service` no longer throws Ruby deprecation warnings
+
+## Newly Introduced Deprecations
+
+### CHEF-26: Deprecation of old shell_out APIs
+
+As noted above, this release of Chef unifies our shell_out helpers into just shell_out and shell_out!. Previous helpers are now deprecated and will be removed in Chef 15.
+
+See [CHEF-26 Deprecation Page](https://docs.chef.io/deprecations_shell_out.html) for details.
+
+### Legacy FreeBSD pkg provider
+
+Chef 15 will remove support for the legacy FreeBSD pkg format. We will continue to support the pkgng format introduced in FreeBSD 10.
# Chef Client Release Notes 14.2:
@@ -122,7 +247,7 @@ The execute resource has also been updated with a new property `default_env` tha
## Small Size on Disk
-Chef now bundles the inspec-core and train-core gems, which omit many cloud dependencies not needed within the Chef client. This change reduces the install size of a typical system by ~22% and the number of files within that installation by ~20% compared to Chef 14.1. Enjoy the extra disk space.
+Chef now bundles the inspec-core and train-core gems, which omit many cloud dependencies not needed within the Chef client. This change reduces the install size of a typical system by ~22% and the number of files within that installation by ~20% compared to Chef 14.1\. Enjoy the extra disk space.
## Virtualization detection on AWS
@@ -175,6 +300,12 @@ The `ignore_failure` property takes a new argument, `:quiet`, to suppress the er
- The sysctl resource correctly handles missing keys when used with `ignore_error`
- --recipe-url apparently never worked on Windows. Now it does.
+## Security Updates
+
+### ffi Gem
+
+- CVE-2018-1000201: DLL loading issue which can be hijacked on Windows OS
+
# Ohai Release Notes 14.1:
## Configurable DMI Whitelist
diff --git a/VERSION b/VERSION
index 04fcab4b4c..0bea6c9520 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-14.3.31 \ No newline at end of file
+14.3.40 \ No newline at end of file
diff --git a/chef-config/chef-config.gemspec b/chef-config/chef-config.gemspec
index f372f944c6..a1afe21b18 100644
--- a/chef-config/chef-config.gemspec
+++ b/chef-config/chef-config.gemspec
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]
spec.add_dependency "mixlib-shellout", "~> 2.0"
- spec.add_dependency "mixlib-config", ">= 2.2.11", "< 3.0"
+ spec.add_dependency "mixlib-config", ">= 2.2.12", "< 3.0"
spec.add_dependency "fuzzyurl"
spec.add_dependency "addressable"
spec.add_dependency "tomlrb", "~> 1.2"
diff --git a/chef-config/lib/chef-config/mixin/credentials.rb b/chef-config/lib/chef-config/mixin/credentials.rb
index 5a73a49add..0a7ca356c8 100644
--- a/chef-config/lib/chef-config/mixin/credentials.rb
+++ b/chef-config/lib/chef-config/mixin/credentials.rb
@@ -20,37 +20,78 @@ require "chef-config/path_helper"
module ChefConfig
module Mixin
+ # Helper methods for working with credentials files.
+ #
+ # @since 13.7
+ # @api internal
module Credentials
-
- def load_credentials(profile = nil)
- credentials_file = PathHelper.home(".chef", "credentials").freeze
+ # Compute the active credentials profile name.
+ #
+ # The lookup order is argument (from --profile), environment variable
+ # ($CHEF_PROFILE), context file (~/.chef/context), and then "default" as
+ # a fallback.
+ #
+ # @since 14.4
+ # @param profile [String, nil] Optional override for the active profile,
+ # normally set via a command-line option.
+ # @return [String]
+ def credentials_profile(profile = nil)
context_file = PathHelper.home(".chef", "context").freeze
+ if !profile.nil?
+ profile
+ elsif ENV.include?("CHEF_PROFILE")
+ ENV["CHEF_PROFILE"]
+ elsif File.file?(context_file)
+ File.read(context_file).strip
+ else
+ "default"
+ end
+ end
- return unless File.file?(credentials_file)
-
- context = File.read(context_file).strip if File.file?(context_file)
-
- environment = ENV.fetch("CHEF_PROFILE", nil)
+ # Compute the path to the credentials file.
+ #
+ # @since 14.4
+ # @return [String]
+ def credentials_file_path
+ PathHelper.home(".chef", "credentials").freeze
+ end
- profile = if !profile.nil?
- profile
- elsif !environment.nil?
- environment
- elsif !context.nil?
- context
- else
- "default"
- end
+ # Load and parse the credentials file.
+ #
+ # Returns `nil` if the credentials file is unavailable.
+ #
+ # @since 14.4
+ # @return [String, nil]
+ def parse_credentials_file
+ credentials_file = credentials_file_path
+ return nil unless File.file?(credentials_file)
+ begin
+ Tomlrb.load_file(credentials_file)
+ rescue => e
+ # TOML's error messages are mostly rubbish, so we'll just give a generic one
+ message = "Unable to parse Credentials file: #{credentials_file}\n"
+ message << e.message
+ raise ChefConfig::ConfigurationError, message
+ end
+ end
- config = Tomlrb.load_file(credentials_file)
+ # Load and process the active credentials.
+ #
+ # @see WorkstationConfigLoader#apply_credentials
+ # @param profile [String, nil] Optional override for the active profile,
+ # normally set via a command-line option.
+ # @return [void]
+ def load_credentials(profile = nil)
+ profile = credentials_profile(profile)
+ config = parse_credentials_file
+ return if config.nil? # No credentials, nothing to do here.
+ if config[profile].nil?
+ # Unknown profile name. For "default" just silently ignore, otherwise
+ # raise an error.
+ return if profile == "default"
+ raise ChefConfig::ConfigurationError, "Profile #{profile} doesn't exist. Please add it to #{credentials_file}."
+ end
apply_credentials(config[profile], profile)
- rescue ChefConfig::ConfigurationError
- raise
- rescue => e
- # TOML's error messages are mostly rubbish, so we'll just give a generic one
- message = "Unable to parse Credentials file: #{credentials_file}\n"
- message << e.message
- raise ChefConfig::ConfigurationError, message
end
end
end
diff --git a/chef-config/lib/chef-config/path_helper.rb b/chef-config/lib/chef-config/path_helper.rb
index fbb413578a..053c7a3c32 100644
--- a/chef-config/lib/chef-config/path_helper.rb
+++ b/chef-config/lib/chef-config/path_helper.rb
@@ -152,7 +152,7 @@ module ChefConfig
canonical_path(path1) == canonical_path(path2)
end
- # Note: this method is deprecated. Please use escape_glob_dirs
+ # @deprecated this method is deprecated. Please use escape_glob_dirs
# Paths which may contain glob-reserved characters need
# to be escaped before globbing can be done.
# http://stackoverflow.com/questions/14127343
diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb
index 80402f9323..a76b554bab 100644
--- a/chef-config/lib/chef-config/version.rb
+++ b/chef-config/lib/chef-config/version.rb
@@ -21,7 +21,7 @@
module ChefConfig
CHEFCONFIG_ROOT = File.expand_path("../..", __FILE__)
- VERSION = "14.3.31".freeze
+ VERSION = "14.3.40".freeze
end
#
diff --git a/lib/chef/application.rb b/lib/chef/application.rb
index 811c713464..81637eabb8 100644
--- a/lib/chef/application.rb
+++ b/lib/chef/application.rb
@@ -205,7 +205,7 @@ class Chef
# Based on config and whether or not STDOUT is a tty, should we setup a
# secondary logger for stdout?
def want_additional_logger?
- !( chef_config[:log_location].is_a?(IO) && chef_config[:log_location].tty? ) && !chef_config[:daemonize]
+ Chef::Config.is_default?(:log_location) && Chef::Config[:log_location].tty? && !Chef::Config[:daemonize]
end
def configure_stdout_logger
diff --git a/lib/chef/dsl/platform_introspection.rb b/lib/chef/dsl/platform_introspection.rb
index ac36dbd1dd..e7f0c60f0d 100644
--- a/lib/chef/dsl/platform_introspection.rb
+++ b/lib/chef/dsl/platform_introspection.rb
@@ -259,6 +259,11 @@ class Chef
node[:virtualization][:systems][:docker] && node[:virtualization][:systems][:docker] == "guest")
end
+ # a simple helper to determine if we're on a windows release pre-2012 / 8
+ # @return [Boolean] Is the system older than Windows 8 / 2012
+ def older_than_win_2012_or_8?(node = run_context.nil? ? nil : run_context.node)
+ node["platform_version"].to_f < 6.2
+ end
end
end
end
diff --git a/lib/chef/guard_interpreter/resource_guard_interpreter.rb b/lib/chef/guard_interpreter/resource_guard_interpreter.rb
index b1d497181b..79134d3dfb 100644
--- a/lib/chef/guard_interpreter/resource_guard_interpreter.rb
+++ b/lib/chef/guard_interpreter/resource_guard_interpreter.rb
@@ -36,7 +36,7 @@ class Chef
# Only execute and script resources and use guard attributes.
# The command to be executed on them are passed via different attributes.
# Script resources use code attribute and execute resources use
- # command attribute. Moreover script resources are also execute
+ # command property. Moreover script resources are also execute
# resources. Here we make sure @command is assigned to the right
# attribute by checking the type of the resources.
# We need to make sure we check for Script first because any resource
diff --git a/lib/chef/http/http_request.rb b/lib/chef/http/http_request.rb
index 8fec34f8b3..9ee519c8ac 100644
--- a/lib/chef/http/http_request.rb
+++ b/lib/chef/http/http_request.rb
@@ -100,7 +100,7 @@ class Chef
@url.path.empty? ? SLASH : @url.path
end
- # DEPRECATED. Call request on an HTTP client object instead.
+ # @deprecated Call request on an HTTP client object instead.
def call
hide_net_http_bug do
http_client.request(http_request) do |response|
@@ -114,7 +114,7 @@ class Chef
Chef::Config
end
- # DEPRECATED. Call request on an HTTP client object instead.
+ # @deprecated Call request on an HTTP client object instead.
def http_client
@http_client ||= BasicClient.new(url).http_client
end
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb
index e28ca81f71..6e525bdf3d 100644
--- a/lib/chef/knife.rb
+++ b/lib/chef/knife.rb
@@ -304,8 +304,12 @@ class Chef
# knife node run_list add requires that we have extra logic to handle
# the case that command name words could be joined by an underscore :/
- command_name_words = command_name_words.join("_")
- @name_args.reject! { |name_arg| command_name_words == name_arg }
+ command_name_joined = command_name_words.join("_")
+ @name_args.reject! { |name_arg| command_name_joined == name_arg }
+
+ # Similar handling for hyphens.
+ command_name_joined = command_name_words.join("-")
+ @name_args.reject! { |name_arg| command_name_joined == name_arg }
if config[:help]
msg opt_parser
diff --git a/lib/chef/knife/config_get_profile.rb b/lib/chef/knife/config_get_profile.rb
new file mode 100644
index 0000000000..309b7f81e8
--- /dev/null
+++ b/lib/chef/knife/config_get_profile.rb
@@ -0,0 +1,37 @@
+#
+# Copyright:: Copyright (c) 2018, Noah Kantrowitz
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require "chef/knife"
+
+class Chef
+ class Knife
+ class ConfigGetProfile < Knife
+ banner "knife config get-profile"
+
+ # Disable normal config loading since this shouldn't fail if the profile
+ # doesn't exist of the config is otherwise corrupted.
+ def configure_chef
+ apply_computed_config
+ end
+
+ def run
+ ui.msg(self.class.config_loader.credentials_profile(config[:profile]))
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/knife/config_list_profiles.rb b/lib/chef/knife/config_list_profiles.rb
new file mode 100644
index 0000000000..16b0c5df27
--- /dev/null
+++ b/lib/chef/knife/config_list_profiles.rb
@@ -0,0 +1,121 @@
+#
+# Copyright:: Copyright (c) 2018, Noah Kantrowitz
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require "chef/knife"
+require "chef/workstation_config_loader"
+
+class Chef
+ class Knife
+ class ConfigListProfiles < Knife
+ banner "knife config list-profiles"
+
+ option :ignore_knife_rb,
+ short: "-i",
+ long: "--ignore-knife-rb",
+ description: "Ignore the current knife.rb configuration",
+ default: false
+
+ def run
+ credentials_data = self.class.config_loader.parse_credentials_file
+ if credentials_data.nil? || credentials_data.empty?
+ # Should this just show the ambient knife.rb config as "default" instead?
+ ui.fatal("No profiles found, #{self.class.config_loader.credentials_file_path} does not exist or is empty")
+ exit 1
+ end
+
+ current_profile = self.class.config_loader.credentials_profile(config[:profile])
+ profiles = credentials_data.keys.map do |profile|
+ if config[:ignore_knife_rb]
+ # Don't do any fancy loading nonsense, just the raw data.
+ profile_data = credentials_data[profile]
+ {
+ profile: profile,
+ active: profile == current_profile,
+ client_name: profile_data["client_name"] || profile_data["node_name"],
+ client_key: profile_data["client_key"],
+ server_url: profile_data["chef_server_url"],
+ }
+ else
+ # Fancy loading nonsense so we get what the actual config would be.
+ # Note that this modifies the global config, after this, all bets are
+ # off as to whats in the config.
+ Chef::Config.reset
+ wcl = Chef::WorkstationConfigLoader.new(nil, Chef::Log, profile: profile)
+ wcl.load
+ {
+ profile: profile,
+ active: profile == current_profile,
+ client_name: Chef::Config[:node_name],
+ client_key: Chef::Config[:client_key],
+ server_url: Chef::Config[:chef_server_url],
+ }
+ end
+ end
+
+ # Try to reset the config.
+ unless config[:ignore_knife_rb]
+ Chef::Config.reset
+ Chef::WorkstationConfigLoader.new(config[:config_file], Chef::Log, profile: config[:profile]).load
+ apply_computed_config
+ end
+
+ if ui.interchange?
+ # Machine-readable output.
+ ui.output(profiles)
+ else
+ # Table output.
+ ui.output(render_table(profiles))
+ end
+ end
+
+ private
+
+ def render_table(profiles, padding: 2)
+ # Replace the home dir in the client key path with ~.
+ profiles.each do |profile|
+ profile[:client_key] = profile[:client_key].to_s.gsub(/^#{Regexp.escape(Dir.home)}/, "~") if profile[:client_key]
+ end
+ # Render the data to a 2D array that will be used for the table.
+ table_data = [["", "Profile", "Client", "Key", "Server"]] + profiles.map do |profile|
+ [profile[:active] ? "*" : ""] + profile.values_at(:profile, :client_name, :client_key, :server_url).map(&:to_s)
+ end
+ # Compute column widths.
+ column_widths = Array.new(table_data.first.length) do |i|
+ table_data.map { |row| row[i].length + padding }.max
+ end
+ # Special case, the first col gets no padding (because indicator) and last
+ # get no padding because last.
+ column_widths[0] -= padding
+ column_widths[-1] -= padding
+ # Build the format string for each row.
+ format_string = column_widths.map { |w| "%-#{w}.#{w}s" }.join("")
+ format_string << "\n"
+ # Print the header row and a separator.
+ table = ui.color(format_string % table_data.first, :green)
+ table << "-" * column_widths.sum
+ table << "\n"
+ # Print the rest of the table.
+ table_data.drop(1).each do |row|
+ table << format_string % row
+ end
+ # Trim the last newline because ui.output adds one.
+ table.chomp!
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/knife/config_use_profile.rb b/lib/chef/knife/config_use_profile.rb
new file mode 100644
index 0000000000..515c4a5336
--- /dev/null
+++ b/lib/chef/knife/config_use_profile.rb
@@ -0,0 +1,50 @@
+#
+# Copyright:: Copyright (c) 2018, Noah Kantrowitz
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require "fileutils"
+
+require "chef/knife"
+
+class Chef
+ class Knife
+ class ConfigUseProfile < Knife
+ banner "knife config use-profile PROFILE"
+
+ # Disable normal config loading since this shouldn't fail if the profile
+ # doesn't exist of the config is otherwise corrupted.
+ def configure_chef
+ apply_computed_config
+ end
+
+ def run
+ context_file = ChefConfig::PathHelper.home(".chef", "context").freeze
+ profile = @name_args[0]&.strip
+ if profile && !profile.empty?
+ # Ensure the .chef/ folder exists.
+ FileUtils.mkdir_p(File.dirname(context_file))
+ IO.write(context_file, "#{profile}\n")
+ ui.msg("Set default profile to #{profile}")
+ else
+ show_usage
+ ui.fatal("You must specify a profile")
+ exit 1
+ end
+ end
+
+ end
+ end
+end
diff --git a/lib/chef/knife/core/hashed_command_loader.rb b/lib/chef/knife/core/hashed_command_loader.rb
index cbe4d558c1..dff4ae50ab 100644
--- a/lib/chef/knife/core/hashed_command_loader.rb
+++ b/lib/chef/knife/core/hashed_command_loader.rb
@@ -60,7 +60,7 @@ class Chef
if errors.empty?
commands
else
- Chef::Log.error "There are files specified in the manifest that are missing. Please rehash to update the subcommands cache. If you see this error after rehashing delete the cache at #{Chef::Knife::SubcommandLoader.plugin_manifest_path}"
+ Chef::Log.error "There are plugin files specified in the knife cache that cannot be found. Please run knife rehash to update the subcommands cache. If you see this error after rehashing delete the cache at #{Chef::Knife::SubcommandLoader.plugin_manifest_path}"
Chef::Log.error "Missing files:\n\t#{errors.values.flatten.join("\n\t")}"
{}
end
diff --git a/lib/chef/knife/core/subcommand_loader.rb b/lib/chef/knife/core/subcommand_loader.rb
index 026967d6ec..fb3723de50 100644
--- a/lib/chef/knife/core/subcommand_loader.rb
+++ b/lib/chef/knife/core/subcommand_loader.rb
@@ -139,9 +139,10 @@ class Chef
# hash composed of the given words joined by the separator.
#
def find_longest_key(hash, words, sep = "_")
+ words = words.dup
match = nil
until match || words.empty?
- candidate = words.join(sep)
+ candidate = words.join(sep).tr("-", "_")
if hash.key?(candidate)
match = candidate
else
diff --git a/lib/chef/platform/query_helpers.rb b/lib/chef/platform/query_helpers.rb
index 448885dfbc..b49010efc0 100644
--- a/lib/chef/platform/query_helpers.rb
+++ b/lib/chef/platform/query_helpers.rb
@@ -20,12 +20,6 @@ class Chef
class Platform
class << self
- # a simple helper to determine if we're on a windows release pre-2012 / 8
- # @return [Boolean] Is the system older than Windows 8 / 2012
- def older_than_win_2012_or_8?
- node["platform_version"].to_f < 6.2
- end
-
def windows?
ChefConfig.windows?
end
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb
index 9584e20656..a459525bac 100644
--- a/lib/chef/provider/user/dscl.rb
+++ b/lib/chef/provider/user/dscl.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "mixlib/shellout"
+require "chef/mixin/shell_out"
require "chef/provider/user"
require "openssl"
require "plist"
diff --git a/lib/chef/provider/windows_task.rb b/lib/chef/provider/windows_task.rb
index f10e4adb70..4fb4817020 100644
--- a/lib/chef/provider/windows_task.rb
+++ b/lib/chef/provider/windows_task.rb
@@ -563,7 +563,7 @@ class Chef
new_resource.password.nil? ? TaskScheduler::TASK_LOGON_SERVICE_ACCOUNT : TaskScheduler::TASK_LOGON_PASSWORD
end
- # This method checks if task and command attributes exist since those two are mandatory attributes to create a schedules task.
+ # This method checks if task and command properties exist since those two are mandatory properties to create a schedules task.
def basic_validation
validate = []
validate << "Command" if new_resource.command.nil? || new_resource.command.empty?
diff --git a/lib/chef/resource/chocolatey_config.rb b/lib/chef/resource/chocolatey_config.rb
index bfa95ddd05..e9452e8f3c 100644
--- a/lib/chef/resource/chocolatey_config.rb
+++ b/lib/chef/resource/chocolatey_config.rb
@@ -24,7 +24,7 @@ class Chef
introduced "14.3"
property :config_key, String, name_property: true,
- description: "The name of the config. We'll use the resource's name if this isn't provided."
+ description: "The name of the config. The resource's name will be used if this isn't provided."
property :value, String,
description: "The value to set."
diff --git a/lib/chef/resource/chocolatey_source.rb b/lib/chef/resource/chocolatey_source.rb
index 2a2948e986..5319f82ab4 100644
--- a/lib/chef/resource/chocolatey_source.rb
+++ b/lib/chef/resource/chocolatey_source.rb
@@ -23,10 +23,17 @@ class Chef
description "Use the chocolatey_source resource to add or remove Chocolatey sources."
introduced "14.3"
- property :source_name, String, name_property: true
- property :source, String
- property :bypass_proxy, [TrueClass, FalseClass], default: false
- property :priority, Integer, default: 0
+ property :source_name, String, name_property: true,
+ description: "The name of the source to add. The resource's name will be used if this isn't provided."
+
+ property :source, String,
+ description: "The source URL."
+
+ property :bypass_proxy, [TrueClass, FalseClass], default: false,
+ description: "Whether or not to bypass the system's proxy settings to access the source."
+
+ property :priority, Integer, default: 0,
+ description: "The priority level of the source."
load_current_value do
element = fetch_source_element(source_name)
diff --git a/lib/chef/resource/dsc_script.rb b/lib/chef/resource/dsc_script.rb
index 7d1e11b659..86be3ddd70 100644
--- a/lib/chef/resource/dsc_script.rb
+++ b/lib/chef/resource/dsc_script.rb
@@ -46,10 +46,10 @@ class Chef
def code(arg = nil)
if arg && command
- raise ArgumentError, "Only one of 'code' and 'command' attributes may be specified"
+ raise ArgumentError, "Only one of 'code' and 'command' properties may be specified"
end
if arg && configuration_name
- raise ArgumentError, "The 'code' and 'command' attributes may not be used together"
+ raise ArgumentError, "The 'code' and 'command' properties may not be used together"
end
set_or_return(
:code,
@@ -60,7 +60,7 @@ class Chef
def configuration_name(arg = nil)
if arg && code
- raise ArgumentError, "Attribute `configuration_name` may not be set if `code` is set"
+ raise ArgumentError, "Property `configuration_name` may not be set if `code` is set"
end
set_or_return(
:configuration_name,
@@ -71,7 +71,7 @@ class Chef
def command(arg = nil)
if arg && code
- raise ArgumentError, "The 'code' and 'command' attributes may not be used together"
+ raise ArgumentError, "The 'code' and 'command' properties may not be used together"
end
set_or_return(
:command,
@@ -82,7 +82,7 @@ class Chef
def configuration_data(arg = nil)
if arg && configuration_data_script
- raise ArgumentError, "The 'configuration_data' and 'configuration_data_script' attributes may not be used together"
+ raise ArgumentError, "The 'configuration_data' and 'configuration_data_script' properties may not be used together"
end
set_or_return(
:configuration_data,
@@ -93,7 +93,7 @@ class Chef
def configuration_data_script(arg = nil)
if arg && configuration_data
- raise ArgumentError, "The 'configuration_data' and 'configuration_data_script' attributes may not be used together"
+ raise ArgumentError, "The 'configuration_data' and 'configuration_data_script' properties may not be used together"
end
set_or_return(
:configuration_data_script,
diff --git a/lib/chef/resource/homebrew_tap.rb b/lib/chef/resource/homebrew_tap.rb
index 2028ce80c8..ab56f6a4c9 100644
--- a/lib/chef/resource/homebrew_tap.rb
+++ b/lib/chef/resource/homebrew_tap.rb
@@ -49,7 +49,7 @@ class Chef
default: "/usr/local/bin/brew"
property :owner, String,
- description: "The owner of the homebrew installation",
+ description: "The owner of the homebrew installation.",
default: lazy { find_homebrew_username }
action :tap do
diff --git a/lib/chef/resource/hostname.rb b/lib/chef/resource/hostname.rb
index f213ae47ad..82240bd6fb 100644
--- a/lib/chef/resource/hostname.rb
+++ b/lib/chef/resource/hostname.rb
@@ -27,23 +27,23 @@ class Chef
introduced "14.0"
property :hostname, String,
- description: "The hostname if different than the resource's name",
+ description: "The hostname if different than the resource's name.",
name_property: true
property :compile_time, [ TrueClass, FalseClass ],
- description: "Should the resource run at compile time or not.",
+ description: "Whether the resource runs at compile time or not.",
default: true
property :ipaddress, String,
- description: "The ip address to use when configuring the hosts file",
+ description: "The ip address to use when configuring the hosts file.",
default: lazy { node["ipaddress"] }
property :aliases, [ Array, nil ],
- description: "An array of hostname aliases to use when configuring the hosts file",
+ description: "An array of hostname aliases to use when configuring the hosts file.",
default: nil
property :windows_reboot, [ TrueClass, FalseClass ],
- description: "Should Windows nodes be rebooted upon changing the name so it can take effect",
+ description: "Whether Windows nodes will be rebooted upon changing the name so changes can take effect.",
default: true
action_class do
@@ -80,7 +80,7 @@ class Chef
end
action :set do
- description "Sets the node's hostname"
+ description "Sets the node's hostname."
if node["platform_family"] != "windows"
ohai "reload hostname" do
diff --git a/lib/chef/resource/ifconfig.rb b/lib/chef/resource/ifconfig.rb
index 84ee249ec4..d43b8c2d58 100644
--- a/lib/chef/resource/ifconfig.rb
+++ b/lib/chef/resource/ifconfig.rb
@@ -79,11 +79,11 @@ class Chef
property :ethtool_opts, String,
introduced: "13.4",
- description: "Options to be passed to ethtool(8). For example: -A eth0 autoneg off rx off tx off"
+ description: "Options to be passed to ethtool(8). For example: -A eth0 autoneg off rx off tx off."
property :bonding_opts, String,
introduced: "13.4",
- description: "Bonding options to pass via BONDING_OPTS on RHEL and CentOS. For example: mode=active-backup miimon=100"
+ description: "Bonding options to pass via BONDING_OPTS on RHEL and CentOS. For example: mode=active-backup miimon=100."
property :master, String,
introduced: "13.4",
diff --git a/lib/chef/resource/kernel_module.rb b/lib/chef/resource/kernel_module.rb
index bea56dedc2..54f213cd11 100644
--- a/lib/chef/resource/kernel_module.rb
+++ b/lib/chef/resource/kernel_module.rb
@@ -30,7 +30,7 @@ class Chef
default: "/etc/modprobe.d"
action :install do
- description "Load kernel module, and ensure it loads on reboot"
+ description "Load kernel module, and ensure it loads on reboot."
# load the module first before installing
new_resource.run_action(:load)
@@ -98,7 +98,7 @@ class Chef
end
action :unload do
- description "Unload kernel module"
+ description "Unload kernel module."
if module_loaded?
converge_by("unload kernel module #{new_resource.modname}") do
diff --git a/lib/chef/resource/ohai_hint.rb b/lib/chef/resource/ohai_hint.rb
index f485222ec6..66146ff16a 100644
--- a/lib/chef/resource/ohai_hint.rb
+++ b/lib/chef/resource/ohai_hint.rb
@@ -34,11 +34,11 @@ class Chef
description: "Values to include in the hint file."
property :compile_time, [TrueClass, FalseClass],
- description: "Should the resource execute during the compile time phase",
+ description: "Whether the resource will execute during the compile time phase or not.",
default: true, desired_state: false
action :create do
- description "Create an Ohai hint file"
+ description "Create an Ohai hint file."
declare_resource(:directory, ::Ohai::Config.ohai.hints_path.first) do
action :create
@@ -52,7 +52,7 @@ class Chef
end
action :delete do
- description "Delete an Ohai hint file"
+ description "Delete an Ohai hint file."
declare_resource(:file, ohai_hint_file_path(new_resource.hint_name)) do
action :delete
diff --git a/lib/chef/resource/openssl_dhparam.rb b/lib/chef/resource/openssl_dhparam.rb
index ec98237a1b..b7bc8438f2 100644
--- a/lib/chef/resource/openssl_dhparam.rb
+++ b/lib/chef/resource/openssl_dhparam.rb
@@ -59,7 +59,7 @@ class Chef
default: "0640"
action :create do
- description "Create the dhparam file"
+ description "Create the dhparam file."
unless dhparam_pem_valid?(new_resource.path)
converge_by("Create a dhparam file #{new_resource.path}") do
diff --git a/lib/chef/resource/openssl_rsa_private_key.rb b/lib/chef/resource/openssl_rsa_private_key.rb
index be4c85bcbb..1bc8f73f47 100644
--- a/lib/chef/resource/openssl_rsa_private_key.rb
+++ b/lib/chef/resource/openssl_rsa_private_key.rb
@@ -68,6 +68,8 @@ class Chef
default: false, desired_state: false
action :create do
+ description "Create the RSA private key."
+
return if new_resource.force || priv_key_file_valid?(new_resource.path, new_resource.key_pass)
converge_by("create #{new_resource.key_length} bit RSA key #{new_resource.path}") do
diff --git a/lib/chef/resource/powershell_package.rb b/lib/chef/resource/powershell_package.rb
index ae6e410f21..ba5a03ef8b 100644
--- a/lib/chef/resource/powershell_package.rb
+++ b/lib/chef/resource/powershell_package.rb
@@ -37,7 +37,8 @@ class Chef
property :package_name, [String, Array], coerce: proc { |x| [x].flatten }
property :version, [String, Array], coerce: proc { |x| [x].flatten }
property :source, [String]
- property :skip_publisher_check, [true, false], default: false, introduced: "14.3", description: "Skip validating module author"
+ property :skip_publisher_check, [true, false], default: false, introduced: "14.3",
+ description: "Skip validating module author."
end
end
end
diff --git a/lib/chef/resource/powershell_package_source.rb b/lib/chef/resource/powershell_package_source.rb
index 9fa4bc8497..1ed3b895a1 100644
--- a/lib/chef/resource/powershell_package_source.rb
+++ b/lib/chef/resource/powershell_package_source.rb
@@ -24,19 +24,19 @@ class Chef
preview_resource true
resource_name "powershell_package_source"
- description "Use the powershell_package_source resource to register a powershell package repository"
+ description "Use the powershell_package_source resource to register a powershell package repository."
introduced "14.3"
property :source_name, String,
- description: "The name of the package source",
+ description: "The name of the package source.",
name_property: true
property :url, String,
- description: "The url to the package source",
+ description: "The url to the package source.",
required: true
property :trusted, [TrueClass, FalseClass],
- description: "Whether or not to trust packages from this source",
+ description: "Whether or not to trust packages from this source.",
default: false
property :provider_name, String,
diff --git a/lib/chef/resource/rhsm_errata.rb b/lib/chef/resource/rhsm_errata.rb
index 96de1bafe7..15b6dab8bc 100644
--- a/lib/chef/resource/rhsm_errata.rb
+++ b/lib/chef/resource/rhsm_errata.rb
@@ -33,7 +33,7 @@ class Chef
name_property: true
action :install do
- description "Installs a package for a specific errata ID"
+ description "Installs a package for a specific errata ID."
execute "Install errata packages for #{new_resource.errata_id}" do
command "yum update --advisory #{new_resource.errata_id} -y"
diff --git a/lib/chef/resource/rhsm_errata_level.rb b/lib/chef/resource/rhsm_errata_level.rb
index 73c9dc0423..ee94a3e60f 100644
--- a/lib/chef/resource/rhsm_errata_level.rb
+++ b/lib/chef/resource/rhsm_errata_level.rb
@@ -35,7 +35,7 @@ class Chef
name_property: true
action :install do
- descripton "Install all packages of the specified errata level"
+ descripton "Install all packages of the specified errata level."
yum_package "yum-plugin-security" do
action :install
diff --git a/lib/chef/resource/rhsm_register.rb b/lib/chef/resource/rhsm_register.rb
index 0e478eff38..f0c86ccaac 100644
--- a/lib/chef/resource/rhsm_register.rb
+++ b/lib/chef/resource/rhsm_register.rb
@@ -36,10 +36,10 @@ class Chef
description: "The FQDN of the Satellite host to register with. If not specified, the host will be registered with Red Hat's public RHSM service."
property :organization, String,
- description: "The organization to use when registering, required when using an activation key"
+ description: "The organization to use when registering, required when using an activation key."
property :environment, String,
- description: "The environment to use when registering, required when using username and password"
+ description: "The environment to use when registering, required when using username and password."
property :username, String,
description: "The username to use when registering. Not applicable if using an activation key. If specified, password and environment are also required."
@@ -61,7 +61,7 @@ class Chef
default: false, desired_state: false
action :register do
- description "Register the node with RHSM"
+ description "Register the node with RHSM."
package "subscription-manager"
@@ -98,7 +98,7 @@ class Chef
end
action :unregister do
- description "Unregister the node from RHSM"
+ description "Unregister the node from RHSM."
execute "Unregister from RHSM" do
command "subscription-manager unregister"
diff --git a/lib/chef/resource/rhsm_repo.rb b/lib/chef/resource/rhsm_repo.rb
index 9eba096f51..54f829e79e 100644
--- a/lib/chef/resource/rhsm_repo.rb
+++ b/lib/chef/resource/rhsm_repo.rb
@@ -32,7 +32,7 @@ class Chef
name_property: true
action :enable do
- description "Enable a RHSM repository"
+ description "Enable a RHSM repository."
execute "Enable repository #{new_resource.repo_name}" do
command "subscription-manager repos --enable=#{new_resource.repo_name}"
@@ -42,7 +42,7 @@ class Chef
end
action :disable do
- description "Disable a RHSM repository"
+ description "Disable a RHSM repository."
execute "Enable repository #{new_resource.repo_name}" do
command "subscription-manager repos --disable=#{new_resource.repo_name}"
diff --git a/lib/chef/resource/rhsm_subscription.rb b/lib/chef/resource/rhsm_subscription.rb
index 9f198dc917..1f6eb9edee 100644
--- a/lib/chef/resource/rhsm_subscription.rb
+++ b/lib/chef/resource/rhsm_subscription.rb
@@ -33,7 +33,7 @@ class Chef
name_property: true
action :attach do
- description "Attach the node to a subscription pool"
+ description "Attach the node to a subscription pool."
execute "Attach subscription pool #{new_resource.pool_id}" do
command "subscription-manager attach --pool=#{new_resource.pool_id}"
@@ -43,7 +43,7 @@ class Chef
end
action :remove do
- description "Remove the node from a subscription pool"
+ description "Remove the node from a subscription pool."
execute "Remove subscription pool #{new_resource.pool_id}" do
command "subscription-manager remove --serial=#{pool_serial(new_resource.pool_id)}"
diff --git a/lib/chef/resource/script.rb b/lib/chef/resource/script.rb
index d3562ee6f5..ac3af619e5 100644
--- a/lib/chef/resource/script.rb
+++ b/lib/chef/resource/script.rb
@@ -40,7 +40,7 @@ class Chef
# FIXME: remove this and use an execute sub-resource instead of inheriting from Execute
def command(arg = nil)
unless arg.nil?
- raise Chef::Exceptions::Script, "Do not use the command attribute on a #{resource_name} resource, use the 'code' attribute instead."
+ raise Chef::Exceptions::Script, "Do not use the command property on a #{resource_name} resource, use the 'code' property instead."
end
super
end
diff --git a/lib/chef/resource/service.rb b/lib/chef/resource/service.rb
index fe13c433cb..c5197d5f06 100644
--- a/lib/chef/resource/service.rb
+++ b/lib/chef/resource/service.rb
@@ -123,7 +123,7 @@ class Chef
# distributions this is '/etc/init.d/SERVICE_NAME' by default. In
# non-standard configurations setting this value will save having to
# specify overrides for the start_command, stop_command and
- # restart_command attributes.
+ # restart_command properties.
def init_command(arg = nil)
set_or_return(
:init_command,
diff --git a/lib/chef/resource/ssh_known_hosts_entry.rb b/lib/chef/resource/ssh_known_hosts_entry.rb
index 07e35587b7..a1257722e0 100644
--- a/lib/chef/resource/ssh_known_hosts_entry.rb
+++ b/lib/chef/resource/ssh_known_hosts_entry.rb
@@ -25,7 +25,7 @@ class Chef
preview_resource true
resource_name :ssh_known_hosts_entry
- description "Use the ssh_known_hosts_entry resource to append an entry for the specified host in /etc/ssh/ssh_known_hosts or a user's known hosts file if specified."
+ description "Use the ssh_known_hosts_entry resource to add an entry for the specified host in /etc/ssh/ssh_known_hosts or a user's known hosts file if specified."
introduced "14.3"
property :host, String,
diff --git a/lib/chef/resource/sudo.rb b/lib/chef/resource/sudo.rb
index af26bde595..87799e5bbb 100644
--- a/lib/chef/resource/sudo.rb
+++ b/lib/chef/resource/sudo.rb
@@ -37,7 +37,7 @@ class Chef
# acording to the sudo man pages sudo will ignore files in an include dir that have a `.` or `~`
# We convert either to `__`
property :filename, String,
- description: "The name of the sudoers.d file",
+ description: "The name of the sudoers.d file.",
name_property: true,
coerce: proc { |x| x.gsub(/[\.~]/, "__") }
@@ -60,11 +60,11 @@ class Chef
default: "ALL"
property :runas, String,
- description: "User the command(s) can be run as",
+ description: "User the command(s) can be run as.",
default: "ALL"
property :nopasswd, [TrueClass, FalseClass],
- description: "Allow running sudo without specifying a password sudo",
+ description: "Allow running sudo without specifying a password sudo.",
default: false
property :noexec, [TrueClass, FalseClass],
@@ -83,7 +83,7 @@ class Chef
default: lazy { [] }
property :command_aliases, Array,
- description: "Command aliases that can be used as allowed commands later in the config",
+ description: "Command aliases that can be used as allowed commands later in the config.",
default: lazy { [] }
property :setenv, [TrueClass, FalseClass],
diff --git a/lib/chef/resource/sysctl.rb b/lib/chef/resource/sysctl.rb
index 496eb05cb8..e03b7a362c 100644
--- a/lib/chef/resource/sysctl.rb
+++ b/lib/chef/resource/sysctl.rb
@@ -50,8 +50,8 @@ class Chef
default: "/etc/sysctl.d"
def after_created
- raise "The systctl resource requires Linux as it needs sysctl and the systctl.d directory functionality." unless node["os"] == "linux"
- raise "The systctl resource does not support SLES releases less than 12 as it requires a systctl.d directory" if platform_family?("suse") && node["platform_version"].to_i < 12
+ raise "The sysctl resource requires Linux as it needs sysctl and the sysctl.d directory functionality." unless node["os"] == "linux"
+ raise "The sysctl resource does not support SLES releases less than 12 as it requires a sysctl.d directory" if platform_family?("suse") && node["platform_version"].to_i < 12
end
def coerce_value(v)
@@ -63,15 +63,17 @@ class Chef
end
end
- # shellout to systctl to get the current value
+ # shellout to sysctl to get the current value
# ignore missing keys by using '-e'
- # convert tabs to spaces since systctl tab deliminates multivalue parameters
+ # convert tabs to spaces since sysctl tab deliminates multivalue parameters
# strip the newline off the end of the output as well
load_current_value do
value shell_out!("sysctl -n -e #{key}").stdout.tr("\t", " ").strip
end
action :apply do
+ description "Apply a sysctl value."
+
converge_if_changed do
# set it temporarily
set_sysctl_param(new_resource.key, new_resource.value)
@@ -91,9 +93,11 @@ class Chef
end
action :remove do
+ description "Remove a sysctl value."
+
# only converge the resource if the file actually exists to delete
if ::File.exist?("#{new_resource.conf_dir}/99-chef-#{new_resource.key}.conf")
- converge_by "removing systctl config at #{new_resource.conf_dir}/99-chef-#{new_resource.key}.conf" do
+ converge_by "removing sysctl config at #{new_resource.conf_dir}/99-chef-#{new_resource.key}.conf" do
file "#{new_resource.conf_dir}/99-chef-#{new_resource.key}.conf" do
action :delete
end
diff --git a/lib/chef/resource/windows_feature_dism.rb b/lib/chef/resource/windows_feature_dism.rb
index fd076ffad3..c5bdc6fdfa 100644
--- a/lib/chef/resource/windows_feature_dism.rb
+++ b/lib/chef/resource/windows_feature_dism.rb
@@ -50,7 +50,7 @@ class Chef
x = x.split(/\s*,\s*/) if x.is_a?(String) # split multiple forms of a comma separated list
# feature installs on windows < 2012 are case sensitive so only downcase when on 2012+
- Chef::Platform.older_than_win_2012_or_8? ? x : x.map(&:downcase)
+ older_than_win_2012_or_8? ? x : x.map(&:downcase)
end
action :install do
@@ -201,7 +201,7 @@ class Chef
# dism on windows 2012+ isn't case sensitive so it's best to compare
# lowercase lists so the user input doesn't need to be case sensitive
# @todo when we're ready to remove windows 2008R2 the gating here can go away
- feature_details.downcase! unless Chef::Platform.older_than_win_2012_or_8?
+ feature_details.downcase! unless older_than_win_2012_or_8?
node.override["dism_features_cache"][feature_type] << feature_details
end
@@ -219,7 +219,7 @@ class Chef
# Fail unless we're on windows 8+ / 2012+ where deleting a feature is supported
# @return [void]
def raise_if_delete_unsupported
- raise Chef::Exceptions::UnsupportedAction, "#{self} :delete action not supported on Windows releases before Windows 8/2012. Cannot continue!" if Chef::Platform.older_than_win_2012_or_8?
+ raise Chef::Exceptions::UnsupportedAction, "#{self} :delete action not supported on Windows releases before Windows 8/2012. Cannot continue!" if older_than_win_2012_or_8?
end
end
end
diff --git a/lib/chef/resource/windows_feature_powershell.rb b/lib/chef/resource/windows_feature_powershell.rb
index c06e380675..6141ff40ba 100644
--- a/lib/chef/resource/windows_feature_powershell.rb
+++ b/lib/chef/resource/windows_feature_powershell.rb
@@ -61,7 +61,7 @@ class Chef
x = x.split(/\s*,\s*/) if x.is_a?(String) # split multiple forms of a comma separated list
# feature installs on windows < 8/2012 are case sensitive so only downcase when on 2012+
- Chef::Platform.older_than_win_2012_or_8? ? x : x.map(&:downcase)
+ older_than_win_2012_or_8? ? x : x.map(&:downcase)
end
include Chef::Mixin::PowershellOut
@@ -78,7 +78,7 @@ class Chef
converge_by("install Windows feature#{'s' if features_to_install.count > 1} #{features_to_install.join(',')}") do
install_command = "#{install_feature_cmdlet} #{features_to_install.join(',')}"
install_command << " -IncludeAllSubFeature" if new_resource.all
- if Chef::Platform.older_than_win_2012_or_8? && (new_resource.source || new_resource.management_tools)
+ if older_than_win_2012_or_8? && (new_resource.source || new_resource.management_tools)
Chef::Log.warn("The 'source' and 'management_tools' properties are only available on Windows 8/2012 or greater. Skipping these properties!")
else
install_command << " -Source \"#{new_resource.source}\"" if new_resource.source
@@ -156,13 +156,13 @@ class Chef
# The appropriate cmdlet to install a windows feature based on windows release
# @return [String]
def install_feature_cmdlet
- Chef::Platform.older_than_win_2012_or_8? ? "Add-WindowsFeature" : "Install-WindowsFeature"
+ older_than_win_2012_or_8? ? "Add-WindowsFeature" : "Install-WindowsFeature"
end
# The appropriate cmdlet to remove a windows feature based on windows release
# @return [String]
def remove_feature_cmdlet
- Chef::Platform.older_than_win_2012_or_8? ? "Remove-WindowsFeature" : "Uninstall-WindowsFeature"
+ older_than_win_2012_or_8? ? "Remove-WindowsFeature" : "Uninstall-WindowsFeature"
end
# @return [Array] features the user has requested to install which need installation
@@ -230,7 +230,7 @@ class Chef
def parsed_feature_list
# Grab raw feature information from dism command line
# Windows < 2012 doesn't present a state value so we have to check if the feature is installed or not
- raw_list_of_features = if Chef::Platform.older_than_win_2012_or_8? # make the older format look like the new format, warts and all
+ raw_list_of_features = if older_than_win_2012_or_8? # make the older format look like the new format, warts and all
powershell_out!('Get-WindowsFeature | Select-Object -Property Name, @{Name=\"InstallState\"; Expression = {If ($_.Installed) { 1 } Else { 0 }}} | ConvertTo-Json -Compress', timeout: new_resource.timeout).stdout
else
powershell_out!("Get-WindowsFeature | Select-Object -Property Name,InstallState | ConvertTo-Json -Compress", timeout: new_resource.timeout).stdout
@@ -243,7 +243,7 @@ class Chef
# @return [void]
def add_to_feature_mash(feature_type, feature_details)
# add the lowercase feature name to the mash unless we're on < 2012 where they're case sensitive
- node.override["powershell_features_cache"][feature_type] << (Chef::Platform.older_than_win_2012_or_8? ? feature_details : feature_details.downcase)
+ node.override["powershell_features_cache"][feature_type] << (older_than_win_2012_or_8? ? feature_details : feature_details.downcase)
end
# Fail if any of the packages are in a removed state
@@ -259,7 +259,7 @@ class Chef
# Fail unless we're on windows 8+ / 2012+ where deleting a feature is supported
def raise_if_delete_unsupported
- raise Chef::Exceptions::UnsupportedAction, "#{self} :delete action not supported on Windows releases before Windows 8/2012. Cannot continue!" if Chef::Platform.older_than_win_2012_or_8?
+ raise Chef::Exceptions::UnsupportedAction, "#{self} :delete action not supported on Windows releases before Windows 8/2012. Cannot continue!" if older_than_win_2012_or_8?
end
end
end
diff --git a/lib/chef/resource/windows_service.rb b/lib/chef/resource/windows_service.rb
index a9ce1f454f..7e265c57c3 100644
--- a/lib/chef/resource/windows_service.rb
+++ b/lib/chef/resource/windows_service.rb
@@ -31,7 +31,7 @@ class Chef
}.freeze
# Until #1773 is resolved, you need to manually specify the windows_service resource
- # to use action :configure_startup and attribute startup_type
+ # to use action :configure_startup and properties startup_type
provides(:windows_service) { true }
provides :service, os: "windows"
diff --git a/lib/chef/version.rb b/lib/chef/version.rb
index c69b787880..f27b4fbe43 100644
--- a/lib/chef/version.rb
+++ b/lib/chef/version.rb
@@ -23,7 +23,7 @@ require "chef/version_string"
class Chef
CHEF_ROOT = File.expand_path("../..", __FILE__)
- VERSION = Chef::VersionString.new("14.3.31")
+ VERSION = Chef::VersionString.new("14.3.40")
end
#
diff --git a/lib/chef/win32/api/security.rb b/lib/chef/win32/api/security.rb
index 6620f321aa..277e85a26b 100644
--- a/lib/chef/win32/api/security.rb
+++ b/lib/chef/win32/api/security.rb
@@ -446,6 +446,7 @@ class Chef
safe_attach_function :LookupPrivilegeDisplayNameW, [ :LPCWSTR, :LPCWSTR, :LPWSTR, :LPDWORD, :LPDWORD ], :BOOL
safe_attach_function :LookupPrivilegeValueW, [ :LPCWSTR, :LPCWSTR, :PLUID ], :BOOL
safe_attach_function :LsaAddAccountRights, [ :pointer, :pointer, :pointer, :ULONG ], :NTSTATUS
+ safe_attach_function :LsaRemoveAccountRights, [ :pointer, :pointer, :BOOL, :pointer, :ULONG ], :NTSTATUS
safe_attach_function :LsaClose, [ :LSA_HANDLE ], :NTSTATUS
safe_attach_function :LsaEnumerateAccountRights, [ :LSA_HANDLE, :PSID, :PLSA_UNICODE_STRING, :PULONG ], :NTSTATUS
safe_attach_function :LsaFreeMemory, [ :PVOID ], :NTSTATUS
diff --git a/lib/chef/win32/security.rb b/lib/chef/win32/security.rb
index 58f47e885b..879aba7f2b 100644
--- a/lib/chef/win32/security.rb
+++ b/lib/chef/win32/security.rb
@@ -117,6 +117,19 @@ class Chef
end
end
+ def self.remove_account_right(name, privilege)
+ privilege_pointer = FFI::MemoryPointer.new LSA_UNICODE_STRING, 1
+ privilege_lsa_string = LSA_UNICODE_STRING.new(privilege_pointer)
+ privilege_lsa_string[:Buffer] = FFI::MemoryPointer.from_string(privilege.to_wstring)
+ privilege_lsa_string[:Length] = privilege.length * 2
+ privilege_lsa_string[:MaximumLength] = (privilege.length + 1) * 2
+
+ with_lsa_policy(name) do |policy_handle, sid|
+ result = LsaRemoveAccountRights(policy_handle.read_pointer, sid, false, privilege_pointer, 1)
+ test_and_raise_lsa_nt_status(result)
+ end
+ end
+
def self.adjust_token_privileges(token, privileges)
token = token.handle if token.respond_to?(:handle)
old_privileges_size = FFI::Buffer.new(:long).write_long(privileges.size_with_privileges)
diff --git a/spec/functional/resource/bash_spec.rb b/spec/functional/resource/bash_spec.rb
index 4a5fee64bc..969ed8f605 100644
--- a/spec/functional/resource/bash_spec.rb
+++ b/spec/functional/resource/bash_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Resource::Bash, :unix_only do
resource
end
- describe "when setting the command attribute" do
+ describe "when setting the command property" do
let (:command) { "wizard racket" }
it "should raise an exception when trying to set the command" do
diff --git a/spec/functional/win32/security_spec.rb b/spec/functional/win32/security_spec.rb
index f88cde0204..5ef1f250ea 100644
--- a/spec/functional/win32/security_spec.rb
+++ b/spec/functional/win32/security_spec.rb
@@ -176,6 +176,27 @@ describe "Chef::Win32::Security", :windows_only do
end
end
+ describe ".remove_account_right" do
+ let(:username) { ENV["USERNAME"] }
+
+ context "when given a valid username" do
+ it "removes the account right constants" do
+ Chef::ReservedNames::Win32::Security.add_account_right(username, "SeBatchLogonRight")
+ expect(Chef::ReservedNames::Win32::Security.get_account_right(username)).to include("SeBatchLogonRight")
+ Chef::ReservedNames::Win32::Security.remove_account_right(username, "SeBatchLogonRight")
+ expect(Chef::ReservedNames::Win32::Security.get_account_right(username)).not_to include("SeBatchLogonRight")
+ end
+ end
+
+ context "when given an invalid username" do
+ let(:username) { "noooooooooope" }
+
+ it "raises an exception" do
+ expect { Chef::ReservedNames::Win32::Security.remove_account_right(username, "SeBatchLogonRight") }.to raise_error(Chef::Exceptions::Win32APIError)
+ end
+ end
+ end
+
describe ".test_and_raise_lsa_nt_status" do
# NTSTATUS code: 0xC0000001 / STATUS_UNSUCCESSFUL
# Windows Error: ERROR_GEN_FAILURE / 31 / 0x1F / A device attached to the system is not functioning.
diff --git a/spec/integration/knife/config_get_profile_spec.rb b/spec/integration/knife/config_get_profile_spec.rb
new file mode 100644
index 0000000000..e97b24b869
--- /dev/null
+++ b/spec/integration/knife/config_get_profile_spec.rb
@@ -0,0 +1,112 @@
+#
+# Copyright 2018, Noah Kantrowitz
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require "support/shared/integration/integration_helper"
+require "support/shared/context/config"
+
+describe "knife config get-profile", :workstation do
+ include IntegrationSupport
+ include KnifeSupport
+
+ include_context "default config options"
+ include_context "with a chef repo"
+
+ let(:cmd_args) { [] }
+
+ subject do
+ cmd = knife("config", "get-profile", *cmd_args, instance_filter: lambda { |instance|
+ # Fake the failsafe check because this command doesn't actually process knife.rb.
+ $__KNIFE_INTEGRATION_FAILSAFE_CHECK << " ole"
+ })
+ cmd.stdout
+ end
+
+ around do |ex|
+ # Store and reset the value of some env vars.
+ old_chef_home = ENV["CHEF_HOME"]
+ old_knife_home = ENV["KNIFE_HOME"]
+ old_home = ENV["HOME"]
+ old_wd = Dir.pwd
+ ChefConfig::PathHelper.per_tool_home_environment = "KNIFE_HOME"
+ # Clear these out because they are cached permanently.
+ ChefConfig::PathHelper.class_exec { remove_class_variable(:@@home_dir) }
+ Chef::Knife::ConfigGetProfile.reset_config_loader!
+ begin
+ ex.run
+ ensure
+ ENV["CHEF_HOME"] = old_chef_home
+ ENV["KNIFE_HOME"] = old_knife_home
+ ENV["HOME"] = old_home
+ Dir.chdir(old_wd)
+ ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
+ ChefConfig::PathHelper.per_tool_home_environment = nil
+ end
+ end
+
+ before do
+ # Always run from the temp folder. This can't be in the `around` block above
+ # because it has to run after the before set in the "with a chef repo" shared context.
+ directory("repo")
+ Dir.chdir(path_to("repo"))
+ ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
+ ENV["HOME"] = path_to(".")
+ end
+
+ context "with no configuration" do
+ it { is_expected.to eq "default\n" }
+ end
+
+ context "with --profile" do
+ let(:cmd_args) { %w{--profile production} }
+ it { is_expected.to eq "production\n" }
+ end
+
+ context "with an environment variable" do
+ around do |ex|
+ old_chef_profile = ENV["CHEF_PROFILE"]
+ begin
+ ENV["CHEF_PROFILE"] = "staging"
+ ex.run
+ ensure
+ ENV["CHEF_PROFILE"] = old_chef_profile
+ end
+ end
+
+ it { is_expected.to eq "staging\n" }
+ end
+
+ context "with a context file" do
+ before { file(".chef/context", "development\n") }
+ it { is_expected.to eq "development\n" }
+ end
+
+ context "with a context file under $CHEF_HOME" do
+ before do
+ file("chefhome/.chef/context", "other\n")
+ ENV["CHEF_HOME"] = path_to("chefhome")
+ end
+
+ it { is_expected.to eq "other\n" }
+ end
+
+ context "with a context file under $KNIFE_HOME" do
+ before do
+ file("knifehome/.chef/context", "other\n")
+ ENV["KNIFE_HOME"] = path_to("knifehome")
+ end
+
+ it { is_expected.to eq "other\n" }
+ end
+end
diff --git a/spec/integration/knife/config_list_profiles_spec.rb b/spec/integration/knife/config_list_profiles_spec.rb
new file mode 100644
index 0000000000..32846f9999
--- /dev/null
+++ b/spec/integration/knife/config_list_profiles_spec.rb
@@ -0,0 +1,188 @@
+#
+# Copyright 2018, Noah Kantrowitz
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require "support/shared/integration/integration_helper"
+require "support/shared/context/config"
+
+describe "knife config list-profiles", :workstation do
+ include IntegrationSupport
+ include KnifeSupport
+
+ include_context "default config options"
+ include_context "with a chef repo"
+
+ let(:cmd_args) { [] }
+ let(:knife_list_profiles) do
+ knife("config", "list-profiles", *cmd_args, instance_filter: proc {
+ # Clear the stub set up in KnifeSupport.
+ allow(File).to receive(:file?).and_call_original
+ })
+ end
+ subject { knife_list_profiles.stdout }
+
+ around do |ex|
+ # Store and reset the value of some env vars.
+ old_home = ENV["HOME"]
+ old_wd = Dir.pwd
+ # Clear these out because they are cached permanently.
+ ChefConfig::PathHelper.class_exec { remove_class_variable(:@@home_dir) }
+ Chef::Knife::ConfigListProfiles.reset_config_loader!
+ begin
+ ex.run
+ ensure
+ ENV["HOME"] = old_home
+ Dir.chdir(old_wd)
+ ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
+ end
+ end
+
+ before do
+ # Always run from the temp folder. This can't be in the `around` block above
+ # because it has to run after the before set in the "with a chef repo" shared context.
+ directory("repo")
+ Dir.chdir(path_to("repo"))
+ ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
+ ENV["HOME"] = path_to(".")
+ end
+
+ # NOTE: The funky formatting with # at the end of the line of some of the
+ # output examples are because of how the format strings are built, there is
+ # substantial trailing whitespace in most cases which many editors "helpfully" remove.
+
+ context "with no credentials file" do
+ subject { knife_list_profiles.stderr }
+ it { is_expected.to eq "FATAL: No profiles found, #{path_to(".chef/credentials")} does not exist or is empty\n" }
+ end
+
+ context "with an empty credentials file" do
+ before { file(".chef/credentials", "") }
+ subject { knife_list_profiles.stderr }
+ it { is_expected.to eq "FATAL: No profiles found, #{path_to(".chef/credentials")} does not exist or is empty\n" }
+ end
+
+ context "with a simple default profile" do
+ before { file(".chef/credentials", <<~EOH) }
+ [default]
+ client_name = "testuser"
+ client_key = "testkey.pem"
+ chef_server_url = "https://example.com/organizations/testorg"
+ EOH
+ it { is_expected.to eq <<~EOH.delete("#") }
+ Profile Client Key Server #
+ ----------------------------------------------------------------------------------#
+ *default testuser ~/.chef/testkey.pem https://example.com/organizations/testorg#
+ EOH
+ end
+
+ context "with multiple profiles" do
+ before { file(".chef/credentials", <<~EOH) }
+ [default]
+ client_name = "testuser"
+ client_key = "testkey.pem"
+ chef_server_url = "https://example.com/organizations/testorg"
+
+ [prod]
+ client_name = "testuser"
+ client_key = "testkey.pem"
+ chef_server_url = "https://example.com/organizations/prod"
+
+ [qa]
+ client_name = "qauser"
+ client_key = "~/src/qauser.pem"
+ chef_server_url = "https://example.com/organizations/testorg"
+ EOH
+ it { is_expected.to eq <<~EOH.delete("#") }
+ Profile Client Key Server #
+ ----------------------------------------------------------------------------------#
+ *default testuser ~/.chef/testkey.pem https://example.com/organizations/testorg#
+ prod testuser ~/.chef/testkey.pem https://example.com/organizations/prod #
+ qa qauser ~/src/qauser.pem https://example.com/organizations/testorg#
+ EOH
+ end
+
+ context "with a non-default active profile" do
+ let(:cmd_args) { %w{--profile prod} }
+ before { file(".chef/credentials", <<~EOH) }
+ [default]
+ client_name = "testuser"
+ client_key = "testkey.pem"
+ chef_server_url = "https://example.com/organizations/testorg"
+
+ [prod]
+ client_name = "testuser"
+ client_key = "testkey.pem"
+ chef_server_url = "https://example.com/organizations/prod"
+
+ [qa]
+ client_name = "qauser"
+ client_key = "~/src/qauser.pem"
+ chef_server_url = "https://example.com/organizations/testorg"
+ EOH
+ it { is_expected.to eq <<~EOH.delete("#") }
+ Profile Client Key Server #
+ ----------------------------------------------------------------------------------#
+ default testuser ~/.chef/testkey.pem https://example.com/organizations/testorg#
+ *prod testuser ~/.chef/testkey.pem https://example.com/organizations/prod #
+ qa qauser ~/src/qauser.pem https://example.com/organizations/testorg#
+ EOH
+ end
+
+ context "with a minimal profile" do
+ before { file(".chef/credentials", <<~EOH) }
+ [default]
+ chef_server_url = "https://example.com/organizations/testorg"
+ EOH
+ it { is_expected.to match %r{^*default .*? https://example.com/organizations/testorg$} }
+ end
+
+ context "with -i" do
+ let(:cmd_args) { %w{-i} }
+ before { file(".chef/credentials", <<~EOH) }
+ [default]
+ chef_server_url = "https://example.com/organizations/testorg"
+ EOH
+ it { is_expected.to eq <<~EOH.delete("#") }
+ Profile Client Key Server #
+ ----------------------------------------------------------------#
+ *default https://example.com/organizations/testorg#
+ EOH
+ end
+
+ context "with --format=json" do
+ let(:cmd_args) { %w{--format=json node_name} }
+ before { file(".chef/credentials", <<~EOH) }
+ [default]
+ client_name = "testuser"
+ client_key = "testkey.pem"
+ chef_server_url = "https://example.com/organizations/testorg"
+
+ [prod]
+ client_name = "testuser"
+ client_key = "testkey.pem"
+ chef_server_url = "https://example.com/organizations/prod"
+
+ [qa]
+ client_name = "qauser"
+ client_key = "~/src/qauser.pem"
+ chef_server_url = "https://example.com/organizations/testorg"
+ EOH
+ it {
+ expect(JSON.parse(subject)).to eq [
+ { "profile" => "default", "active" => true, "client_name" => "testuser", "client_key" => path_to(".chef/testkey.pem"), "server_url" => "https://example.com/organizations/testorg" },
+ { "profile" => "prod", "active" => false, "client_name" => "testuser", "client_key" => path_to(".chef/testkey.pem"), "server_url" => "https://example.com/organizations/prod" },
+ { "profile" => "qa", "active" => false, "client_name" => "qauser", "client_key" => path_to("src/qauser.pem"), "server_url" => "https://example.com/organizations/testorg" },
+ ] }
+ end
+end
diff --git a/spec/integration/knife/config_use_profile_spec.rb b/spec/integration/knife/config_use_profile_spec.rb
new file mode 100644
index 0000000000..a021dbbe6f
--- /dev/null
+++ b/spec/integration/knife/config_use_profile_spec.rb
@@ -0,0 +1,100 @@
+#
+# Copyright 2018, Noah Kantrowitz
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require "support/shared/integration/integration_helper"
+require "support/shared/context/config"
+
+describe "knife config use-profile", :workstation do
+ include IntegrationSupport
+ include KnifeSupport
+
+ include_context "default config options"
+ include_context "with a chef repo"
+
+ let(:cmd_args) { [] }
+
+ let(:knife_use_profile) do
+ knife("config", "use-profile", *cmd_args, instance_filter: lambda { |instance|
+ # Fake the failsafe check because this command doesn't actually process knife.rb.
+ $__KNIFE_INTEGRATION_FAILSAFE_CHECK << " ole"
+ })
+ end
+
+ subject { knife_use_profile.stdout }
+
+ around do |ex|
+ # Store and reset the value of some env vars.
+ old_chef_home = ENV["CHEF_HOME"]
+ old_knife_home = ENV["KNIFE_HOME"]
+ old_home = ENV["HOME"]
+ old_wd = Dir.pwd
+ ChefConfig::PathHelper.per_tool_home_environment = "KNIFE_HOME"
+ # Clear these out because they are cached permanently.
+ ChefConfig::PathHelper.class_exec { remove_class_variable(:@@home_dir) }
+ Chef::Knife::ConfigUseProfile.reset_config_loader!
+ begin
+ ex.run
+ ensure
+ ENV["CHEF_HOME"] = old_chef_home
+ ENV["KNIFE_HOME"] = old_knife_home
+ ENV["HOME"] = old_home
+ Dir.chdir(old_wd)
+ ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
+ ChefConfig::PathHelper.per_tool_home_environment = nil
+ end
+ end
+
+ before do
+ # Always run from the temp folder. This can't be in the `around` block above
+ # because it has to run after the before set in the "with a chef repo" shared context.
+ directory("repo")
+ Dir.chdir(path_to("repo"))
+ ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
+ ENV["HOME"] = path_to(".")
+ end
+
+ context "with no argument" do
+ subject { knife_use_profile.stderr }
+ it { is_expected.to eq "FATAL: You must specify a profile\n" }
+ end
+
+ context "with an argument" do
+ let(:cmd_args) { %w{production} }
+ it do
+ is_expected.to eq "Set default profile to production\n"
+ expect(File.read(path_to(".chef/context"))).to eq "production\n"
+ end
+ end
+
+ context "with $CHEF_HOME" do
+ let(:cmd_args) { %w{staging} }
+ before { ENV["CHEF_HOME"] = path_to("chefhome"); file("chefhome/tmp", "") }
+ it do
+ is_expected.to eq "Set default profile to staging\n"
+ expect(File.read(path_to("chefhome/.chef/context"))).to eq "staging\n"
+ expect(File.exist?(path_to(".chef/context"))).to be_falsey
+ end
+ end
+
+ context "with $KNIFE_HOME" do
+ let(:cmd_args) { %w{development} }
+ before { ENV["KNIFE_HOME"] = path_to("knifehome"); file("knifehome/tmp", "") }
+ it do
+ is_expected.to eq "Set default profile to development\n"
+ expect(File.read(path_to("knifehome/.chef/context"))).to eq "development\n"
+ expect(File.exist?(path_to(".chef/context"))).to be_falsey
+ end
+ end
+end
diff --git a/spec/unit/knife/core/hashed_command_loader_spec.rb b/spec/unit/knife/core/hashed_command_loader_spec.rb
index 53bd81f4f7..e866f13a9c 100644
--- a/spec/unit/knife/core/hashed_command_loader_spec.rb
+++ b/spec/unit/knife/core/hashed_command_loader_spec.rb
@@ -65,7 +65,7 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
end
it "lists all commands by category when no argument is given" do
- expect(Chef::Log).to receive(:error).with(/There are files specified in the manifest that are missing/)
+ expect(Chef::Log).to receive(:error).with(/There are plugin files specified in the knife cache that cannot be found/)
expect(Chef::Log).to receive(:error).with("Missing files:\n\t/file/for/plugin/b")
expect(loader.list_commands).to eq({})
end
diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb
index 48cee78462..622d54af37 100644
--- a/spec/unit/provider/execute_spec.rb
+++ b/spec/unit/provider/execute_spec.rb
@@ -102,7 +102,7 @@ describe Chef::Provider::Execute do
expect(new_resource).to be_updated
end
- it "if you pass a command attribute, it runs the command" do
+ it "if you pass a command property, it runs the command" do
new_resource.command "/usr/argelbargle/bin/oogachacka 12345"
expect(provider).to receive(:shell_out!).with(new_resource.command, opts)
expect(provider).to receive(:converge_by).with("execute #{new_resource.command}").and_call_original
diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb
index dd59089418..1b7f91df76 100644
--- a/spec/unit/provider/service/windows_spec.rb
+++ b/spec/unit/provider/service/windows_spec.rb
@@ -18,7 +18,6 @@
#
require "spec_helper"
-require "mixlib/shellout"
describe Chef::Provider::Service::Windows, "load_current_resource", :windows_only do
include_context "Win32"
diff --git a/spec/unit/provider/user/aix_spec.rb b/spec/unit/provider/user/aix_spec.rb
index aa62edd878..f8b5b8a324 100644
--- a/spec/unit/provider/user/aix_spec.rb
+++ b/spec/unit/provider/user/aix_spec.rb
@@ -15,7 +15,6 @@
# limitations under the License.
#
-require "mixlib/shellout"
require "spec_helper"
describe Chef::Provider::User::Aix do
diff --git a/spec/unit/provider/user/dscl_spec.rb b/spec/unit/provider/user/dscl_spec.rb
index 928cf020e8..c93a1eb4a8 100644
--- a/spec/unit/provider/user/dscl_spec.rb
+++ b/spec/unit/provider/user/dscl_spec.rb
@@ -18,7 +18,6 @@
require "spec_helper"
require "ostruct"
-require "mixlib/shellout"
describe Chef::Provider::User::Dscl do
before do
diff --git a/spec/unit/provider/user/solaris_spec.rb b/spec/unit/provider/user/solaris_spec.rb
index b39e065f48..11c8656a5c 100644
--- a/spec/unit/provider/user/solaris_spec.rb
+++ b/spec/unit/provider/user/solaris_spec.rb
@@ -20,7 +20,6 @@
# limitations under the License.
#
-require "mixlib/shellout"
require "spec_helper"
describe Chef::Provider::User::Solaris do
diff --git a/spec/unit/resource/dsc_script_spec.rb b/spec/unit/resource/dsc_script_spec.rb
index d5ebcaca5c..26a1c7cca0 100644
--- a/spec/unit/resource/dsc_script_spec.rb
+++ b/spec/unit/resource/dsc_script_spec.rb
@@ -45,27 +45,27 @@ describe Chef::Resource::DscScript do
expect { resource.action :run }.not_to raise_error
end
- it "allows the code attribute to be set" do
+ it "allows the code property to be set" do
resource.code(configuration_code)
expect(resource.code).to eq(configuration_code)
end
- it "allows the command attribute to be set" do
+ it "allows the command property to be set" do
resource.command(configuration_path)
expect(resource.command).to eq(configuration_path)
end
- it "allows the configuration_name attribute to be set" do
+ it "allows the configuration_name property to be set" do
resource.configuration_name(configuration_name)
expect(resource.configuration_name).to eq(configuration_name)
end
- it "allows the configuration_data attribute to be set" do
+ it "allows the configuration_data property to be set" do
resource.configuration_data(configuration_data)
expect(resource.configuration_data).to eq(configuration_data)
end
- it "allows the configuration_data_script attribute to be set" do
+ it "allows the configuration_data_script property to be set" do
resource.configuration_data_script(configuration_data_script)
expect(resource.configuration_data_script).to eq(configuration_data_script)
end
@@ -106,27 +106,27 @@ describe Chef::Resource::DscScript do
end
end
- it "raises an ArgumentError exception if an attempt is made to set the code attribute when the command attribute is already set" do
+ it "raises an ArgumentError exception if an attempt is made to set the code property when the command property is already set" do
resource.command(configuration_path)
expect { resource.code(configuration_code) }.to raise_error(ArgumentError)
end
- it "raises an ArgumentError exception if an attempt is made to set the command attribute when the code attribute is already set" do
+ it "raises an ArgumentError exception if an attempt is made to set the command property when the code property is already set" do
resource.code(configuration_code)
expect { resource.command(configuration_path) }.to raise_error(ArgumentError)
end
- it "raises an ArgumentError exception if an attempt is made to set the configuration_name attribute when the code attribute is already set" do
+ it "raises an ArgumentError exception if an attempt is made to set the configuration_name property when the code property is already set" do
resource.code(configuration_code)
expect { resource.configuration_name(configuration_name) }.to raise_error(ArgumentError)
end
- it "raises an ArgumentError exception if an attempt is made to set the configuration_data attribute when the configuration_data_script attribute is already set" do
+ it "raises an ArgumentError exception if an attempt is made to set the configuration_data property when the configuration_data_script property is already set" do
resource.configuration_data_script(configuration_data_script)
expect { resource.configuration_data(configuration_data) }.to raise_error(ArgumentError)
end
- it "raises an ArgumentError exception if an attempt is made to set the configuration_data_script attribute when the configuration_data attribute is already set" do
+ it "raises an ArgumentError exception if an attempt is made to set the configuration_data_script property when the configuration_data property is already set" do
resource.configuration_data(configuration_data)
expect { resource.configuration_data_script(configuration_data_script) }.to raise_error(ArgumentError)
end