Use the osx_profile resource to manage configuration profiles (.mobileconfig
files) on the Mac OS X 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.
A osx_profile resource block manages configuration profiles on the Mac OS X platform:
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:
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 resourcename
is the name of the resource block:action
identifies the steps the chef-client will take to bring the node into the desired stateprofile
, 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.This resource has the following actions:
:install
:nothing
Default. .. tag resources_common_actions_nothing
Define this resource block to do nothing until notified by another resource to take action. When this resource is notified, this resource block is either run immediately or it is queued up to be run at the end of the chef-client run.
:remove
This resource has the following properties:
identifier
Ruby Type: String
Use to specify the identifier for the profile, such as com.company.screensaver
.
ignore_failure
Ruby Types: TrueClass, FalseClass
Continue running a recipe if a resource fails for any reason. Default value: false
.
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 notifiy more than one resource; use a notifies
statement for each resource to be notified.
A timer specifies the point during the chef-client run at which a notification is run. The following timers are available:
:before
:delayed
:immediate
, :immediately
The syntax for notifies
is:
notifies :action, 'resource[name]', :timer
profile
Ruby Types: 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
Use to specify the name of the profile, if different from the name of the resource block.
provider
Ruby Type: Chef Class
Optional. Explicitly specifies a provider.
retries
Ruby Type: Integer
The number of times to catch exceptions and retry the resource. Default value: 0
.
retry_delay
Ruby Type: Integer
The retry delay (in seconds). Default value: 2
.
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.
A timer specifies the point during the chef-client run at which a notification is run. The following timers are available:
:before
:delayed
:immediate
, :immediately
The syntax for subscribes
is:
subscribes :action, 'resource[name]', :timer
The following examples demonstrate various approaches for using resources in recipes. If you want to see examples of how Chef uses resources in recipes, take a closer look at the cookbooks that Chef authors and maintains: https://github.com/chef-cookbooks.
One liner to install profile from cookbook file
The profiles
command will be used to install the specified configuration profile.
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.
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.
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.
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.
osx_profile 'Remove screensaver profile' do identifier 'com.company.screensaver' action :remove end
© Chef Software, Inc.
Licensed under the Creative Commons Attribution 3.0 Unported License.
The Chef™ Mark and Chef Logo are either registered trademarks/service marks or trademarks/servicemarks of Chef, in the United States and other countries and are used with Chef Inc's permission.
We are not affiliated with, endorsed or sponsored by Chef Inc.
https://docs-archive.chef.io/release/12-13/resource_osx_profile.html