The following items are new for Chef Infra Client 12.7 and/or are changes from previous versions. The short version: - **Chef::REST =\> require 'chef/rest'** Internal API calls are moved from `Chef::REST` to `Chef::ServerAPI`. Any code that uses `Chef::REST` must use `require 'chef/rest'`. - **New chocolatey_package resource** Use the **chocolatey_package** resource to manage packages using Chocolatey for the Microsoft Windows platform. - **New osx_profile resource** Use the **osx_profile** resource to manage configuration profiles (`.mobileconfig` files) on the macOS platform. - **New apt_update resource** Use the **apt_update** resource to manage Apt repository updates on Debian and Ubuntu platforms. - **Improved support for UTF-8** Chef Infra Client 12.7 release fixes a UTF-8 handling bug present in chef-client versions 12.4, 12.5, and 12.6. - **New options for the chef-client** Chef Infra Client has a new option: `--delete-entire-chef-repo`. - **Multi-package support for Chocolatey and Zypper** A resource may specify multiple packages and/or versions for platforms that use Zypper or Chocolatey package managers (in addition to the existing support for specifying multiple packages for Yum and Apt packages). ## Chef::REST =\> require 'chef/rest' Internal API calls are moved from `Chef::REST` to `Chef::ServerAPI`. As a result of this move, `Chef::REST` is no longer globally required. Any code that uses `Chef::REST` must be required as follows: ```ruby require 'chef/rest' ``` For code that is run using knife or chef command line interfaces, consider using `Chef::ServerAPI` instead. ## chocolatey_package Use the **chocolatey_package** resource to manage packages using Chocolatey on the Microsoft Windows platform. ### Syntax A **chocolatey_package** resource block manages packages using Chocolatey for the Microsoft Windows platform. The simplest use of the **chocolatey_package** resource is: ```ruby chocolatey_package 'package_name' ``` which will install the named package using all of the default options and the default action (`:install`). The full syntax for all of the properties that are available to the **chocolatey_package** resource is: ```ruby chocolatey_package 'name' do notifies # see description options String package_name String, Array # defaults to 'name' if not specified source String subscribes # see description timeout String, Integer version String, Array action Symbol # defaults to :install if not specified end ``` where - `chocolatey_package` tells Chef Infra Client to manage a package - `'name'` is the name of the package - `action` identifies which steps Chef Infra Client will take to bring the node into the desired state - `options`, `package_name`, `source`, `timeout`, and `version` are properties of this resource, with the Ruby type shown. See "Properties" section below for more information about all of the properties that may be used with this resource. ### Actions This resource has the following actions: `:install` : Default. Install a package. If a version is specified, install the specified version of the package. `:nothing` : This resource block does not act unless notified by another resource to take action. Once notified, this resource block either runs immediately or is queued up to run at the end of the Chef Infra Client run. `:purge` : Purge a package. This action typically removes the configuration files as well as the package. `:reconfig` : Reconfigure a package. This action requires a response file. `:remove` : Remove a package. `:uninstall` : Uninstall a package. `:upgrade` : Install a package and/or ensure that a package is the latest version. ### Properties This resource has the following properties: `ignore_failure` : **Ruby Type:** true, false | **Default Value:** `false` Continue running a recipe if a resource fails for any reason. `notifies` : **Ruby Type:** Symbol, 'Chef::Resource\[String\]' A resource may notify another resource to take action when its state changes. Specify a `'resource[name]'`, the `:action` that resource should take, and then the `:timer` for that action. A resource may notify more than one resource; use a `notifies` statement for each resource to be notified. A timer specifies the point during the Chef Infra Client run at which a notification is run. The following timers are available: `:before` : Specifies that the action on a notified resource should be run before processing the resource block in which the notification is located. `:delayed` : Default. Specifies that a notification should be queued up, and then executed at the end of the Chef Infra Client run. `:immediate`, `:immediately` : Specifies that a notification should be run immediately, per resource notified. The syntax for `notifies` is: ```ruby notifies :action, 'resource[name]', :timer ``` `options` : **Ruby Type:** String One (or more) additional options that are passed to the command. `package_name` : **Ruby Type:** String, Array The name of the package. Default value: the `name` of the resource block. See "Syntax" section above for more information. `retries` : **Ruby Type:** Integer | **Default Value:** `0` The number of attempts to catch exceptions and retry the resource. `retry_delay` : **Ruby Type:** Integer | **Default Value:** `2` The retry delay (in seconds). `source` : **Ruby Type:** String Optional. The path to a package in the local file system. `subscribes` : **Ruby Type:** Symbol, 'Chef::Resource\[String\]' A resource may listen to another resource, and then take action if the state of the resource being listened to changes. Specify a `'resource[name]'`, the `:action` to be taken, and then the `:timer` for that action. Note that `subscribes` does not apply the specified action to the resource that it listens to - for example: ```ruby file '/etc/nginx/ssl/example.crt' do mode '0600' owner 'root' end service 'nginx' do subscribes :reload, 'file[/etc/nginx/ssl/example.crt]', :immediately end ``` In this case the `subscribes` property reloads the `nginx` service whenever its certificate file, located under `/etc/nginx/ssl/example.crt`, is updated. `subscribes` does not make any changes to the certificate file itself, it merely listens for a change to the file, and executes the `:reload` action for its resource (in this example `nginx`) when a change is detected. A timer specifies the point during the Chef Infra Client run at which a notification is run. The following timers are available: `:before` : Specifies that the action on a notified resource should be run before processing the resource block in which the notification is located. `:delayed` : Default. Specifies that a notification should be queued up, and then executed at the end of the Chef Infra Client run. `:immediate`, `:immediately` : Specifies that a notification should be run immediately, per resource notified. The syntax for `subscribes` is: ```ruby subscribes :action, 'resource[name]', :timer ``` `timeout` : **Ruby Type:** String, Integer The amount of time (in seconds) to wait before timing out. `version` : **Ruby Type:** String, Array The version of a package to be installed or upgraded. ### Examples **Install a package** ```ruby chocolatey_package 'name of package' do action :install end ``` **Install a package with options** This example uses Chocolatey's `--checksum` option: ```ruby chocolatey_package 'name of package' do options '--checksum 1234567890' action :install end ``` ## osx_profile Use the **osx_profile** resource to manage configuration profiles (`.mobileconfig` files) on the macOS platform. The **osx_profile** resource installs profiles by using the `uuidgen` library to generate a unique `ProfileUUID`, and then using the `profiles` command to install the profile on the system. ### Syntax A **osx_profile** resource block manages configuration profiles on the macOS platform: ```ruby osx_profile 'Install screensaver profile' do profile 'com.company.screensaver.mobileconfig' end ``` The full syntax for all of the properties that are available to the **osx_profile** resource is: ```ruby osx_profile 'name' do path # set automatically profile String, Hash profile_name String # defaults to 'name' if not specified identifier String action Symbol # defaults to :install if not specified end ``` where - `osx_profile` is the resource - `name` is the name of the resource block - `action` identifies the steps Chef Infra Client will take to bring the node into the desired state - `profile`, `profile_name`, and `identifier` are properties of this resource, with the Ruby type shown. See "Properties" section below for more information about all of the properties that may be used with this resource. ### Actions The osx_profile resource has the following actions: `:install` : Default. Install the specified configuration profile. `:nothing` : This resource block does not act unless notified by another resource to take action. Once notified, this resource block either runs immediately or is queued up to run at the end of the Chef Infra Client run. `:remove` : Remove the specified configuration profile. ### Properties The osx_profile resource has the following properties: `identifier` : **Ruby Type:** String Use to specify the identifier for the profile, such as `com.company.screensaver`. `path` : **Ruby Type:** String The path to write the profile to disk before loading it. `profile` : **Ruby Type:** String, Hash Use to specify a profile. This may be the name of a profile contained in a cookbook or a Hash that contains the contents of the profile. `profile_name` : **Ruby Type:** String | **Default Value:** `The resource block's name` Use to specify the name of the profile, if different from the name of the resource block. ### Examples **One liner to install profile from cookbook file** The `profiles` command will be used to install the specified configuration profile. ```ruby osx_profile 'com.company.screensaver.mobileconfig' ``` **Install profile from cookbook file** The `profiles` command will be used to install the specified configuration profile. It can be in sub-directory within a cookbook. ```ruby osx_profile 'Install screensaver profile' do profile 'screensaver/com.company.screensaver.mobileconfig' end ``` **Install profile from a hash** The `profiles` command will be used to install the configuration profile, which is provided as a hash. ```ruby profile_hash = { 'PayloadIdentifier' => 'com.company.screensaver', 'PayloadRemovalDisallowed' => false, 'PayloadScope' => 'System', 'PayloadType' => 'Configuration', 'PayloadUUID' => '1781fbec-3325-565f-9022-8aa28135c3cc', 'PayloadOrganization' => 'Chef', 'PayloadVersion' => 1, 'PayloadDisplayName' => 'Screensaver Settings', 'PayloadContent'=> [ { 'PayloadType' => 'com.apple.ManagedClient.preferences', 'PayloadVersion' => 1, 'PayloadIdentifier' => 'com.company.screensaver', 'PayloadUUID' => '73fc30e0-1e57-0131-c32d-000c2944c108', 'PayloadEnabled' => true, 'PayloadDisplayName' => 'com.apple.screensaver', 'PayloadContent' => { 'com.apple.screensaver' => { 'Forced' => [ { 'mcx_preference_settings' => { 'idleTime' => 0, } } ] } } } ] } osx_profile 'Install screensaver profile' do profile profile_hash end ``` **Remove profile using identifier in resource name** The `profiles` command will be used to remove the configuration profile specified by the provided `identifier` property. ```ruby osx_profile 'com.company.screensaver' do action :remove end ``` **Remove profile by identifier and user friendly resource name** The `profiles` command will be used to remove the configuration profile specified by the provided `identifier` property. ```ruby osx_profile 'Remove screensaver profile' do identifier 'com.company.screensaver' action :remove end ``` ## apt_update Use the **apt_update** resource to manage APT repository updates on Debian and Ubuntu platforms. ### Syntax An **apt_update** resource block defines the update frequency for APT repositories: ```ruby apt_update 'name' do frequency Integer action Symbol # defaults to :periodic if not specified end ``` where - `apt_update` is the resource - `name` is the name of the resource block - `action` identifies the steps Chef Infra Client will take to bring the node into the desired state - `frequency` is a property of this resource, with the Ruby type shown. See "Properties" section below for more information about all of the properties that may be used with this resource. ### Actions The apt_update resource has the following actions: `:nothing` : This resource block does not act unless notified by another resource to take action. Once notified, this resource block either runs immediately or is queued up to run at the end of the Chef Infra Client run. `:periodic` : Update the Apt repository at the interval specified by the `frequency` property. `:update` : Update the Apt repository at the start of Chef Infra Client run. ### Properties The apt_update resource has the following properties: `frequency` : **Ruby Type:** Integer | **Default Value:** `86400` Determines how frequently (in seconds) APT repository updates are made. Use this property when the `:periodic` action is specified. ### Examples **Update the Apt repository at a specified interval** ```ruby apt_update 'all platforms' do frequency 86400 action :periodic end ``` **Update the Apt repository at the start of a chef-client run** ```ruby apt_update 'update' ``` ## New chef-client options Chef Infra Client has the following new options: `--delete-entire-chef-repo` : Delete the entire chef-repo. This option may only be used when running Chef Infra Client in local mode (`--local-mode`) mode. This options requires `--recipe-url` to be specified.