Puppet Mac Osx
Version 2 (Anonymous, 03/13/2010 08:01 pm)
| 1 | 1 | # Puppet on Mac OS X |
|
|---|---|---|---|
| 2 | 1 | ||
| 3 | 1 | Generally speaking, there are very few differences between Mac OS X |
|
| 4 | 1 | and other Unix operating systems. OS X's unix underpinnings are |
|
| 5 | 1 | evident in the short list of special cases we must take into |
|
| 6 | 1 | account when running Puppet on an OS X computer. Throughout the |
|
| 7 | 1 | rest of this document, I'll refer to Mac OS X as Darwin. |
|
| 8 | 1 | ||
| 9 | 1 | ## Background |
|
| 10 | 1 | ||
| 11 | 1 | Within the Mac OS X system administration community, there are |
|
| 12 | 1 | currently three major deployment strategies: |
|
| 13 | 1 | ||
| 14 | 1 | - Monolithic Disk Image (Block Level Cloning) |
|
| 15 | 1 | - Filesystem Synchronization (File Level Cloning) |
|
| 16 | 1 | - Package Installation (often ad-hoc or on-demand) |
|
| 17 | 1 | ||
| 18 | 1 | Most large sites appear to deploy monolithic "master images" which |
|
| 19 | 1 | contain all managed software. This is similar to Ghost in the |
|
| 20 | 1 | Microsoft world, and is commonly achieved by using |
|
| 21 | 1 | [Apple NetBoot-Install Service](http://www.apple.com/server/macosx/features/client-management.html), |
|
| 22 | 1 | part of Mac OS X Server, or Mike Bombich's NetRestore-Helper. The |
|
| 23 | 1 | popular NetRestore product by Bombich was recently retired, and |
|
| 24 | 1 | [Deploy Studio](http://www.deploystudio.com) has been recommended |
|
| 25 | 1 | as a capable successor, one that supports advanced large-scale |
|
| 26 | 1 | cloning using technologies like |
|
| 27 | 1 | [multicast](http://www.bombich.com/mactips/multicast.html) |
|
| 28 | 1 | [asr](http://developer.apple.com/documentation/Darwin/Reference/ManPages/man8/asr.8.html), |
|
| 29 | 1 | among others. |
|
| 30 | 1 | ||
| 31 | 1 | A common alternative to NetBoot-Install monolithic images are file |
|
| 32 | 1 | level synchronization services, such as |
|
| 33 | 1 | [Radmind](http://rsug.itd.umich.edu/software/radmind/) |
|
| 34 | 1 | ||
| 35 | 1 | Finally, some sites manage software using |
|
| 36 | 1 | [Apple's PackageMaker](http://developer.apple.com/documentation/Darwin/Reference/Manpages/man1/packagemaker.1.html) |
|
| 37 | 1 | tool, distributed as part of |
|
| 38 | 1 | [Xcode Tools](http://developer.apple.com/tools/xcode/). Often, |
|
| 39 | 1 | these packages are deployed as incremental updates to managed |
|
| 40 | 1 | computers through |
|
| 41 | 1 | [Apple Remote Desktop](http://www.apple.com/remotedesktop/), or |
|
| 42 | 1 | added to a |
|
| 43 | 1 | [slipstreamed](http://en.wikipedia.org/wiki/Slipstream_(computing)), |
|
| 44 | 1 | cloning-ready image like those created by |
|
| 45 | 1 | [InstaDMG](http://code.google.com/p/instadmg) or the |
|
| 46 | 1 | [JAMF Imaging Suite](http://www.jamfsoftware.com/products/imagingSuite.php). |
|
| 47 | 1 | ||
| 48 | 1 | Puppet plays nicely with all three of these strategies. In |
|
| 49 | 1 | particular, Puppet's dependency mapping features set it apart from |
|
| 50 | 1 | most other tools, particularly for package deployment. In addition, |
|
| 51 | 1 | unlike the common Remote Desktop package deployment method, Puppet |
|
| 52 | 1 | is able to ensure packages get installed, even if the receiving |
|
| 53 | 1 | node is off line when the package is deployed to the site. |
|
| 54 | 1 | ||
| 55 | 1 | ## Providers |
|
| 56 | 1 | ||
| 57 | 1 | ### package:pkgdmg |
|
| 58 | 1 | ||
| 59 | 1 | Mac OS X nodes have a slightly unique package provider available to |
|
| 60 | 1 | them. The **pkgdmg** provider facilitates the deployment of |
|
| 61 | 1 | software packaged with Package Maker, and wrapped in a disk image |
|
| 62 | 1 | (DMG). The package is wrapped in order to provide easier network |
|
| 63 | 1 | file copies, as a .pkg and .mpkg object are standard directories. |
|
| 64 | 1 | ||
| 65 | 1 | The pkgdmg provider also allows source packages to reside at any |
|
| 66 | 1 | location Open::URI accepts. In plain terms, this means a standard |
|
| 67 | 1 | HTTP server. |
|
| 68 | 1 | ||
| 69 | 1 | This example deploys Apple Remote Desktop and TextMate onto support |
|
| 70 | 1 | workstations: |
|
| 71 | 1 | ||
| 72 | 1 | # Convenience component for installing pkg.dmg packages. |
|
| 73 | 1 | define pkg_deploy($sourcedir = false) |
|
| 74 | 1 | { |
|
| 75 | 1 | $sourcedir_real = $sourcedir ? { |
|
| 76 | 1 | false => "http://puppet.reductivelabs.foo/osx/pkgs/apps", |
|
| 77 | 1 | default => $sourcedir |
|
| 78 | 1 | } |
|
| 79 | 1 | package { $name: |
|
| 80 | 1 | ensure => installed, |
|
| 81 | 1 | provider => pkgdmg, |
|
| 82 | 1 | source => "$sourcedir_real/$name" |
|
| 83 | 1 | } |
|
| 84 | 1 | } |
|
| 85 | 1 | ||
| 86 | 1 | ||
| 87 | 1 | class support-workstation { |
|
| 88 | 1 | case $operatingsystem { |
|
| 89 | 1 | Darwin: { |
|
| 90 | 1 | pkg_deploy { "RemoteDesktop-3.0.0-ub.pkg.dmg": |
|
| 91 | 1 | sourcedir => "http://puppet.reductivelabs.foo/osx/pkgs/apple/ard", |
|
| 92 | 1 | alias => ard-admin300 |
|
| 93 | 1 | } |
|
| 94 | 1 | pkg_deploy { "RemoteDesktopAdmin310.dmg": |
|
| 95 | 1 | sourcedir => "http://puppet.reductivelabs.foo/osx/pkgs/apple/ard", |
|
| 96 | 1 | require => Package[ard-admin300], |
|
| 97 | 1 | alias => ard-admin310 |
|
| 98 | 1 | } |
|
| 99 | 1 | pkg_deploy { "TextMate-1.5.1-01-ub.pkg.dmg": alias => textmate } |
|
| 100 | 1 | } |
|
| 101 | 1 | } |
|
| 102 | 1 | } |
|
| 103 | 1 | ||
| 104 | 1 | The pkg\_deploy component defines standard package objects on the |
|
| 105 | 1 | client, and specifies the use of pkgdmg as the provider. |
|
| 106 | 1 | ||
| 107 | 1 | Note the use of **require => Package[ard-admin300]** in the |
|
| 108 | 1 | **RemoteDesktopAdmin310.dmg** definition. This dependency coupling |
|
| 109 | 1 | feature of puppet sets it apart from other tools such as Apple |
|
| 110 | 1 | Remote Desktop and Filewave. |
|
| 111 | 1 | ||
| 112 | 1 | The overall process this provider takes is: |
|
| 113 | 1 | ||
| 114 | 1 | 1. If necessary, download the DMG to the local file system. |
|
| 115 | 1 | 2. Mount the DMG using hdiutil |
|
| 116 | 1 | 3. Install all .pkg or .mpkg objects in the root directory of the |
|
| 117 | 1 | DMG using installer |
|
| 118 | 1 | 4. Touch a control file in /var/db/, allowing future ensure => |
|
| 119 | 1 | present checks |
|
| 120 | 1 | 5. Eject the DMG using hdiutil |
|
| 121 | 1 | 6. Remove source file. |
|
| 122 | 1 | ||
| 123 | 1 | The source code is short and available at |
|
| 124 | 1 | [source:lib/puppet/provider/package/pkgdmg.rb] |
|
| 125 | 1 | ||
| 126 | 1 | NOTE: Currently, I believe the source file is always removed. This |
|
| 127 | 1 | may bite you if you're not installing from HTTP. This may be a |
|
| 128 | 1 | bug. |
|
| 129 | 1 | ||
| 130 | 1 | # Multiple Architectures |
|
| 131 | 1 | ||
| 132 | 1 | A somewhat unique issue when managing Apple hardware is dealing |
|
| 133 | 1 | with two very different hardware architectures; **powerpc** and |
|
| 134 | 1 | **i386**. Apple has done a remarkable job of pulling off the |
|
| 135 | 1 | complete transition of all their products to intel hardware, but |
|
| 136 | 1 | this poses a problem for some software which refuses to run on the |
|
| 137 | 1 | wrong hardware. |
|
| 138 | 1 | ||
| 139 | 1 | I typically handle these unique cases using case statements or |
|
| 140 | 1 | selectors: (Note: **$hardwaremodel** is automatically set by the |
|
| 141 | 1 | Facter library on each client node.) |
|
| 142 | 1 | ||
| 143 | 1 | # Apple updates. |
|
| 144 | 1 | class sw-apple { |
|
| 145 | 1 | Pkg_deploy { sourcedir => "http://www.math.ohio-state.edu/osx/pkgs/apple/updates_osx" } |
|
| 146 | 1 | case $hardwaremodel { |
|
| 147 | 1 | "i386": { |
|
| 148 | 1 | pkg_deploy { "SecUpd2006-007Intel.dmg": alias => secupd2006-007 } |
|
| 149 | 1 | pkg_deploy { "SecUpd2006-008Univ.dmg": alias => secupd2006-008, require => Package[secupd2006-007] } |
|
| 150 | 1 | pkg_deploy { "iChatUpdateUniv.dmg": alias => ichat10 } |
|
| 151 | 1 | pkg_deploy { "AirPortExtremeUpdate2007001.dmg": alias => airport2007001 } |
|
| 152 | 1 | pkg_deploy { "SecUpd2007-002Univ.dmg": alias => secupd2007-002, require => Package[secupd2007-001] } |
|
| 153 | 1 | } # i386: |
|
| 154 | 1 | "Power Macintosh": { |
|
| 155 | 1 | pkg_deploy { "SecUpd2006-007Ti.dmg": alias => secupd2006-007 } |
|
| 156 | 1 | pkg_deploy { "SecUpd2006-008Ti.dmg": alias => secupd2006-008, require => Package[secupd2006-007] } |
|
| 157 | 1 | pkg_deploy { "iChatUpdatePPC.dmg": alias => ichat10 } |
|
| 158 | 1 | pkg_deploy { "SecUpd2007-002Ti.dmg": alias => secupd2007-002, require => Package[secupd2007-001] } |
|
| 159 | 1 | } # powerpc: |
|
| 160 | 1 | } # case $hardwaremodel |
|
| 161 | 1 | # The following object are deployed regardless of processor architecture. |
|
| 162 | 1 | pkg_deploy { "SecUpd2007-001Ti.dmg": alias => secupd2007-001, require => Package[secupd2006-008] } |
|
| 163 | 1 | pkg_deploy { "DSTUpdateTi-001.dmg": alias => dst_update_tiger } |
|
| 164 | 1 | pkg_deploy { "JavaForMacOSX10.4Release5.dmg": alias => java_r5 } |
|
| 165 | 1 | pkg_deploy { "iTunes-7.0.2-1-ub.pkg.dmg": alias => itunes } |
|
| 166 | 1 | pkg_deploy { "RemoteDesktopClient-3.1.0-1-ub.pkg.dmg": alias => ard-client, |
|
| 167 | 1 | sourcedir => "http://www.math.ohio-state.edu/osx/pkgs/apple/ard" |
|
| 168 | 1 | } |
|
| 169 | 1 | } |
|
| 170 | 1 | ||
| 171 | 1 | # Mac OS X specifc Facts |
|
| 172 | 1 | ||
| 173 | 1 | There's a few Mac OS X specific Facter facts which should be |
|
| 174 | 1 | available in the Facter trunk or versions more recent than 1.3.8. |
|
| 175 | 1 | ||
| 176 | 1 | These facts are generated from system\_profiler -xml and sw\_vers |
|
| 177 | 1 | ||
| 178 | 1 | Of particular interest is the sp\_serial\_number, which is present |
|
| 179 | 1 | on every Mac workstation. |
|
| 180 | 1 | ||
| 181 | 1 | For example: |
|
| 182 | 1 | ||
| 183 | 1 | macosx_buildversion => 9A466 |
|
| 184 | 1 | macosx_productname => Mac OS X |
|
| 185 | 1 | macosx_productversion => 10.5 |
|
| 186 | 1 | sp_boot_mode => normal_boot |
|
| 187 | 1 | sp_boot_rom_version => MBP11.0055.B08 |
|
| 188 | 1 | sp_boot_volume => Leopard |
|
| 189 | 1 | sp_bus_speed => 667 MHz |
|
| 190 | 1 | sp_cpu_type => Intel Core Duo |
|
| 191 | 1 | sp_current_processor_speed => 2.16 GHz |
|
| 192 | 1 | sp_kernel_version => Darwin 9.0.0b1 |
|
| 193 | 1 | sp_l2_cache_share => 2 MB |
|
| 194 | 1 | sp_local_host_name => nutburner |
|
| 195 | 1 | sp_machine_model => MacBookPro1,1 |
|
| 196 | 1 | sp_machine_name => MacBookPro15 |
|
| 197 | 1 | sp_mmm_entry => MMM_stateMMM_enabled |
|
| 198 | 1 | sp_number_processors => 2 |
|
| 199 | 1 | sp_os_version => Mac OS X 10.5 (9A466) |
|
| 200 | 1 | sp_physical_memory => 2 GB |
|
| 201 | 1 | sp_serial_number => W86XXXXXXXX |
|
| 202 | 1 | sp_smc_version => 1.2f10 |
|
| 203 | 1 | sp_uptime => up 0:2:30:33 |
|
| 204 | 1 | sp_user_name => Jeff McCune (mccune) |
|
| 205 | 1 | ||
| 206 | 1 | # Running Puppet via Launchd |
|
| 207 | 1 | ||
| 208 | 1 | Check out the [[Puppet With Launchd]] page for plist files and |
|
| 209 | 1 | information about running puppetd and puppetmasterd automatically |
|
| 210 | 1 | at system startup via launchd. |