Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/ruby -w
# date: 01/13/12
# author: nate
# description: postflight action to stash user files
require 'FileUtils'
def get_users
users = []
static_admins=["root", "daemon", "puppet", "nobody"]
#!/usr/bin/env ruby
require 'facter'
ENV["FACTERLIB"] = "/var/lib/puppet/lib/facter/"
Facter.list.each { |fact| p "#{fact}" => Facter.value(fact)}
#!/usr/bin/env ruby
## parse os x 10.7 shado hash data
#
require "rexml/document"
include REXML
require "base64"
def parse_plist(plist)
parsed = []
doc = Document.new File.new(plist)
#!/usr/bin/env ruby
require 'rubygems'
require 'digest/sha2'
require 'cfpropertylist'
def salted_sha512(password)
seedint = rand(((2**31 - 1)-1+1))
seedhex = ("%x" % seedint).upcase.rjust(8, '0')
seedstring = seedint.to_a.pack("L")
mco rpc etc_facts search -F "operatingsystem=~/[dD]arwin/" --arg="fact=form"

Profile Manager

Profile Manager is neat (as long as it’s not messed up). It’s a Mobile Device Management (MDM) server that also manages profiles for computers and users.

Behind the scenes, it’s a Rails app using the Sproutcore javascript framework to make it pretty and PostgreSQL as the database backend. It generates mobileconfig profiles that are basically special xml docs that are applied to devices.

Clients can either login to the web portal via http://server.example.com/profilemanager to manually download profiles that apply to either users or devices, or updated profiles can be pushed to clients via push notification services (that also have to be enabled, server side) for devices that already have profiles.

Here’s a possibly helpful walk-through. The afp548 folks had a video up but have since removed it. Not sure why, thou

#!/usr/bin/env ruby -wKU
# cf. http://www.puppetlabs.com/blog/facter-part-3-caching-and-ttl/
# requires installing rest-client gem ('gem install rest-client') first
require 'rubygems'
require 'rest_client'
geo_raw=(RestClient.post "http://api.hostip.info/get_html.php", :position=>"true")
geo_data=Hash[*geo_raw.scan(/(.*): (.*)\n/).to_a.flatten]
# 110506
# reposado clone manifest
# pythonversion comes from a custom fact which should be instaled via factsync
case $pythonversion {
/2.6/: {
# will this test actually succeed?
include reposado_install
}
default: {
@rockpapergoat
rockpapergoat / java exceptions starting casper
Created April 19, 2011 14:40
starting tomcat5 with server.xml configured to run jamf's casper web app
errors on start:
Starting tomcat5: [ OK ]
at org.apache.catalina.startup.Catalina.await(Catalina.java:616)
at org.apache.catalina.startup.Catalina.start(Catalina.java:576)
... 6 more
Using CATALINA_BASE: /usr/share/tomcat5
Using CATALINA_HOME: /usr/share/tomcat5
Using CATALINA_TMPDIR: /usr/share/tomcat5/temp
Using JRE_HOME:
@rockpapergoat
rockpapergoat / get_users_etc.rb
Created March 5, 2011 20:37
more user record stuff
#!/usr/bin/env ruby -wKU
# cf. http://twitter.com/nigelkersten/status/44114754112995328
require 'pp'
require 'etc'
users = []
Etc.passwd() { |u|
users << Hash[u.name, u.uid] if u.uid >= 500
}
pp users