Skip to main content

Chef Deprecation Warnings

When we wish to remove a feature or an API in Chef, we try to first mark it with a deprecation warning that contains a link to a description of the change and how to fix it. For example:

Deprecated features used!
  JSON auto inflation is not supported (CHEF-1) at (irb):7:in `irb_binding`.
  Please see /chef-client/deprecations/json_auto_inflate.html for further details and information on how to correct this problem.

Testing for Deprecations

To test your code for deprecations, you can put Test Kitchen in a mode where any deprecations cause the chef run to fail. Ensure your kitchen.yml includes:

provisioner:
  deprecations_as_errors: true

and then run Test Kitchen as usual. Test Kitchen will fail if any deprecation errors are issued.

Silencing deprecation warnings

Deprecation warnings are great for ensuring cookbooks are kept up-to-date and to prepare for major version upgrades, sometimes you just cannot fix a deprecation right away. Enabling treat_deprecation_warnings_as_errors mode in Test Kitchen integration tests often compounds the problem because it does not distinguish between deprecations from community cookbooks and those in your own code.

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 (for example, "internal_api"), the numeric deprecation ID (for example, 25 or “CHEF-25”), or by specifying the filename and line number where the deprecation is being raised from (for example, "default.rb:67").

An example of setting the silence_deprecation_warnings option in your client.rb or solo.rb:

silence_deprecation_warnings %w{deploy_resource chef-23 recipes/install.rb:22}

or in your `kitchen.yml`:

provisioner:
  name: chef_solo
    solo_rb:
      treat_deprecation_warnings_as_errors: true
      silence_deprecation_warnings:
        - deploy_resource
        - chef-23
        - recipes/install.rb:22

You can also silence deprecations using a comment on the line that is raising the warning:

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.

All Deprecations

IDDescriptionDeprecatedExpected Removal
CHEF-0Many internal APIs have been improved.variousvaries
CHEF-1Consumers of JSON are now required to be explicit in how it is turned in to a Chef object.12.713.0
CHEF-2Chef's exit codes are now defined so that it is easy to understand why Chef exited.12.1113.0
CHEF-3When using the chef_gem resource, the phase to install the gem in must be specified.12.113.0
CHEF-4Various improvements have been made to attribute syntax.variousvaries
CHEF-5Various improvements have been made to custom resource syntax.variousvaries
CHEF-6The easy_install resource will be removed.12.1013.0
CHEF-7The verify metaproperty's file substitution will be removed.12.513.0
CHEF-8The supports metaproperty will be removed.12.1413.0
CHEF-9The Chef::REST API will be removed.12.713.0
CHEF-10DNF package provider and resource do not require --allow-downgrade anymore.12.1813.0
CHEF-11An exception will be raised if a resource property conflicts with an already-existing property or method.12.1913.0
CHEF-12An exception will be raised whenever the hash property in the launchd resource is used.12.1913.0
CHEF-13Deprecated Chef::Platform methods12.1813.0
CHEF-14Deprecation of run_command12.1813.0
CHEF-18Deprecation of local mode listening.13.115.0
CHEF-19Deprecation of property_name within actions.13.214.0
CHEF-20Deprecation of the deploy resource.13.614.0
CHEF-21Deprecation of the :uninstall action in the chocolatey_package resource.13.714.0
CHEF-22Deprecation of the erl_call resource.13.714.0
CHEF-23Deprecation of legacy HWRP mixins.12.X14.0
CHEF-24Deprecation of epic_fail in favor of allow_failure13.714.0
CHEF-25Resource(s) in a cookbook collide with the same resource(s) now included in Chef Infra Client.XX.X15.0
CHEF-26Deprecation of legacy shell_out APIs.14.315.0
CHEF-27Deprecation of lc_all from locale resource15.016.0
CHEF-31Deprecation of resource_name declaration without provides15.1316.2
CHEF-33Enabling unified mode in custom resources17.0
CHEF-3694Resource Cloning will no longer work.10.1813.0
OHAI-1Ohai::Config removal.12.613.0
OHAI-2Sigar gem based plugins removal.12.1913.0
OHAI-3run_command and popen4 helper method removal.12.813.0
OHAI-4Libvirt plugin attributes changes.12.1914.0
OHAI-5Windows CPU plugin attribute changes.12.1913.0
OHAI-6DigitalOcean plugin attribute changes.12.1913.0
OHAI-7Amazon linux moved to the Amazon platform_family.13.013.0
OHAI-8Cloud plugin replaced by the Cloud_V2 plugin.13.013.0
OHAI-9Filesystem plugin replaced by the Filesystem V2 plugin.13.013.0
OHAI-10Removal of support for Ohai version 6 plugins.11.1214.0
OHAI-11Cloud_v2 attribute removal.13.114.0
OHAI-12Filesystem2 attribute removal.13.114.0
OHAI-13Removal of IpScopes plugin13.214.0
OHAI-14Removal of system_profile plugin14.615.0
Edit this page on GitHub

Thank you for your feedback!

×











Search Results