Monthly Archives: August 2014

Save AppleTV password to System Keychain

DXkiVMLevwtJhwga

I have several Apple TV’s setup in lab environments. To make it easy for students and faculty to connect to the Apple TV, I save the password into the system Keychain. That way they are not prompted for the password to connect, and it provides a basic level of security from other users trying to connect with there laptops or iOS devices.

I can either save the password into the Keychain before I make the image, which works fine, if the Apple TV is already setup. But if it’s a late addition to a lab. My option becomes to manually save the password on each machine.

So I deiced to script it and then push the command out with ARD which took a whole 5 seconds.

#!/bin/bash
#version 1.0

#saves Apple TV password to system keychain for all users
appletvmac="change to Apple TV's MAC Address"
appletvdescription="example: Room 206"
appletvpassword=xxx

sudo security add-generic-password -A -a $appletvmac -s $appletvdescription -w $appletvpassword "/Library/Keychains/System.keychain"

Using Puppet to manage Java auto updates on Mac OS X

I’ve been toying with a virtual setup of puppet open source over the last week. My Puppet Master is Ubuntu 12.04, my Puppet Agent is Mac OS X 10.9.

I’ve been looking at puppet for over two years and have tried twice in the past to stand up a virtual machine and make it do something!!!. It usually ends with some crisis being more important and by the time I come back to puppet … I’m lost. I get frustrated and delete the VM’s. Rinse and repeat.

This time I”m up and running and my two big goals, both of which I accomplished, were too manage a local admin account, and install and manage printers for Mac OS X. Two things I can manage in several different ways, but I’d like to see if Puppet’s way is better/different. My thoughts are still out on that. I’m trying to consider how puppet could fit into my current workflows. But it is neat to watch puppet work. Which got me thinking. What kind of creative things can puppet do to manage a Mac OS X desktop?

If one of the things Puppet can manage are file resources, and plist are just formatted xml files. Can puppet manage plist for Mac OS X? So I decided to try something very simple. I want to turn off Java 7’s auto update feature. No matter how many times you turn it off, when you install a new version of Java, it’s re-checked. This is a good test because the plist only contains 1 entry.

Typically to disable auto updates, you can just open terminal and run:

sudo defaults write /Library/Preferences/com.oracle.java.Java-Updater.plist JavaAutoUpdateEnabled -false

But with puppet, I want to make sure of a couple things:

– The file “com.oracle.java.Java-Updater.plist” exist at /Library/Preferences/

– That the mode is set to 644

– The contents of the file contains the entire plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>JavaAutoUpdateEnabled</key>
    <false/>
</dict>
</plist>

so my puppet code looks like this:

Screen Shot 2014-08-15 at 9.06.00 AM

node pup{
        file {'com.oracle.java.Java-Updater.plist':
                path    => '/Library/Preferences/com.oracle.java.Java-Updater.plist',
                ensure  => present,
                mode    => 644,
                content => '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>JavaAutoUpdateEnabled</key>
        <false/>
</dict>
</plist>',
        }

And after I run puppet on my node, I did a restart for good measure and then checked the auto update box. Which appears to have worked.

Screen Shot 2014-08-15 at 9.04.54 AM

Pretty neat for a quick test. It has me thinking what else might Puppet be able to do?