This repository has been archived by the owner. It is now read-only.
Development repository for dmg Chef cookbook
Clone or download
tas50 Deprecate in the readme
Signed-off-by: Tim Smith <tsmith@chef.io>
Latest commit 8742132 Apr 6, 2018

README.md

The dmg_package resource is now included in Chef 14 and this cookbook has been deprecated. We highly recommend updating to Chef 14 so you can use this resource without the need for a cookbook dependency.

dmg Cookbook

Build Status Cookbook Version

Resource to install OS X applications (.app) from dmg files.

Requirements

Platforms

  • macOS

Chef

  • Chef 12.5+

Cookbooks

  • none

Resources/Providers

dmg_package

This resource will install a DMG "Package". It will retrieve the DMG from a remote URL, mount it using OS X's hdid, copy the application (.app directory) to the specified destination (/Applications), and detach the image using hdiutil. The dmg file will be stored in the Chef::Config[:file_cache_path]. If you want to install an application that has already been downloaded (not using the source parameter), copy it to the appropriate location. You can find out what directory this is with the following command on the node to run chef:

knife exec -E 'p Chef::Config[:file_cache_path]' -c /etc/chef/client.rb

Optionally, the LWRP can install an "mpkg" or "pkg" package using installer(8).

Actions

  • :install - Installs the application.

Parameter attributes:

  • app - This is the name of the application used by default for the /Volumes directory and the .app directory copied to /Applications.
  • source - remote URL for the dmg to download if specified. Default is nil.
  • file - local dmg full file path. Default is nil.
  • owner - owner that should own the package installation.
  • destination - directory to copy the .app into. Default is /Applications.
  • checksum - sha256 checksum of the dmg to download. Default is nil.
  • type - type of package, "app", "pkg" or "mpkg". Default is "app". When using "pkg" or "mpkg", the destination must be /Applications.
  • volumes_dir - Directory under /Volumes where the dmg is mounted. Not all dmgs are mounted into a /Volumes location matching the name of the dmg. If not specified, this will use the name attribute.
  • package_id - Package id registered with pkgutil when a pkg or mpkg is installed
  • dmg_name - Specify the name of the dmg if it is not the same as app, or if the name has spaces.
  • dmg_passphrase - Specify a passphrase to use to unencrypt the dmg while mounting.
  • accept_eula - Specify whether to accept the EULA. Certain dmgs require acceptance of EULA before mounting. Can be true or false, defaults to false.
  • headers - Allows custom HTTP headers (like cookies) to be set on the remote_file resource.
  • allow_untrusted - Allows packages with untrusted certs to be installed.

Examples

Install /Applications/Tunnelblick.app from the primary download site.

dmg_package 'Tunnelblick' do
  source   'https://tunnelblick.net/release/Tunnelblick_3.7.0_build_4790.dmg'
  checksum '5053038aa8caf7dea66dcab11d6d240672216e6546eff4c2622e216c61af85e5'
  action   :install
end

Install Google Chrome. Uses the dmg_name because the application name has spaces. Installs in /Applications/Google Chrome.app.

dmg_package 'Google Chrome' do
  dmg_name 'googlechrome'
  source   'https://dl-ssl.google.com/chrome/mac/stable/GGRM/googlechrome.dmg'
  checksum '7daa2dc5c46d9bfb14f1d7ff4b33884325e5e63e694810adc58f14795165c91a'
  action   :install
end

Install Dropbox. Uses volumes_dir because the mounted directory is different than the name of the application directory. Installs in /Applications/Dropbox.app.

dmg_package 'Dropbox' do
  volumes_dir 'Dropbox Installer'
  source      'http://www.dropbox.com/download?plat=mac'
  checksum    'b4ea620ca22b0517b75753283ceb82326aca8bc3c86212fbf725de6446a96a13'
  action      :install
end

Install MacIrssi to ~/Applications from the local file downloaded to the cache path into an Applications directory in the current user's home directory. Chef should run as a non-root user for this.

directory "#{ENV['HOME']}/Applications"

dmg_package 'MacIrssi' do
  destination "#{ENV['HOME']}/Applications"
  action      :install
end

Install Virtualbox to /Applications from the .mpkg:

dmg_package 'Virtualbox' do
  source 'http://dlc.sun.com.edgesuite.net/virtualbox/4.0.8/VirtualBox-4.0.8-71778-OSX.dmg'
  type   'mpkg'
end

Install pgAdmin to /Applications and automatically accept the EULA:

dmg_package 'pgAdmin3' do
  source   'http://wwwmaster.postgresql.org/redir/198/h/pgadmin3/release/v1.12.3/osx/pgadmin3-1.12.3.dmg'
  checksum '9435f79d5b52d0febeddfad392adf82db9df159196f496c1ab139a6957242ce9'
  accept_eula true
end

Install Silverlight, with idempotence check based on pkgutil:

dmg_package 'Silerlight' do
  source     'http://silverlight.dlservice.microsoft.com/download/D/C/2/DC2D5838-9138-4D25-AA92-52F61F7C51E6/runtime/Silverlight.dmg'
  type       'pkg'
  checksum   '6d4a0ad4552d9815531463eb3f467fb8cf4bffcc'
  package_id 'com.microsoft.installSilverlightPlugin'
end

License & Authors

Author: Cookbook Engineering Team (cookbooks@chef.io)

Copyright: 2011-2017, Chef Software, Inc.

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.