Installing and configuring Munki with Puppet

2013, Jul 25    

Puppet is a powerful system administration tool for Macs. But Munki is better at managing software packages. Do the smart thing and use puppet to deploy and configure Munki on your Mac clients.” – Chris McCafferty

I couldn’t have said it better myself. Thanks for the recipe! Here’s my version of the same solution …

Place the following code in your modules/munki/manifests/init.pp file:

class munki {
	# http://go.vertigion.com/PuppetModules-Munki
	$munki = 'munkitools-0.9.0.1803.0'
	$munki_download = "https://munki.googlecode.com/files/$munki.dmg"
	$munki_server = 'http://munki.example.com'

	# https://code.google.com/p/munki/wiki/BootstrappingWithMunki
	$bootstrap = '/usr/bin/touch /Users/Shared/.com.googlecode.munki.checkandinstallatstartup'
	$managed_installs = '/Library/Preferences/ManagedInstalls'

	package { "$munki.dmg" :
		provider => pkgdmg,
		alias => 'munkitools',
		ensure => installed,
		source => $munki_download,
		notify => Exec[$bootstrap],
	}

	exec {$bootstrap :
		refreshonly => true,
		notify => Exec['/sbin/reboot']
	}

	exec {'/sbin/reboot' :
		refreshonly => true,
	}

	file {"$managed_installs.plist" :
		ensure => present,
		owner => root,
		group => admin,
	}

	exec {"/usr/bin/defaults write $managed_installs SoftwareRepoURL "$server/munki_repo"" :
		before => Package['munkitools'],
		require => File["$managed_installs.plist"],
	}

	exec {"/usr/bin/defaults write $managed_installs ClientIdentifier "workstation"" :
		before => Package['munkitools'],
		require => File["$managed_installs.plist"],
	}

	exec {"/usr/bin/defaults write $managed_installs InstallAppleSoftwareUpdates -bool True" :
		before => Package['munkitools'],
		require => File["$managed_installs.plist"],
	}
}