Skip to content

Instantly share code, notes, and snippets.

View glarizza's full-sized avatar

Gary Larizza glarizza

  • Open Infrastructure Services
  • Portland, Oregon
View GitHub Profile
#!/usr/bin/env ruby
#
#
# This External Node classifier script will return appropriate classes for Puppet depending
# on the machine's huron_class fact. The script will dip into the Server's YAML depository,
# search for the passed certname, extract the fact information, and return a YAML block to
# puppet.
#
# Created by Gary Larizza - 6.10.2010
# Last Modified - 11.30.2010
#!/usr/bin/env ruby
# MC Agent for facts.txt
#
# This is my test at pushing/popping/querying data from facts.txt
#
# Initial file contains:
#
# huron_class=staff,shel
# environment=production
module MCollective
module Agent
class Etc_facts<RPC::Agent
metadata :name => "Utility for /etc/facts.txt Fact File",
:description => "A conduit to inspect and modify your /etc/facts.txt file.",
:author => "Gary Larizza <[email protected]>",
:license => "Apache License, Version 2.0",
:version => "1.0",
:url => "http://marionette-collective.org/",
:timeout => 3
# This code leaves me with a hash of values called h
h = {}
File.open("/etc/facts.txt") do |fp|
fp.each do |line|
key, value = line.chomp.split("=")
h[key] = value
end

There are a couple of great Apple Packaging applications out there that have functionalities including snapshot and fseventsd monitoring as well as integration with popular application deployment suites, but there are very few, if any, that allow for easy code review, consistency, and portability.

Enter The Luggage.

Joe Block has created an open source tool that will allow you to create packages based on GNU make that he calls The Luggage. With The Luggage, package definitions are clearly spelled out in plaintext files, can be shared and stored in version control systems, and can be replicated by peers with ease.

Since GNU make can be daunting at first, I've written an article on creating packages with make and The Luggage. As we all move towards modular imaging techniques (InstaDMG, System Image Utility), it's becoming more important to have all our applications, scripts, and customizat

#!/usr/bin/ruby
# pclean.rb
# cgi to clean a puppet ssl cert
class Puppetca
# removes old certificate if it exists
# The certname parameter is the node's certname
# Make sure to add the _www user to your sudoers file
# added using visudo:
# _www ALL = NOPASSWD: /usr/bin/puppet, !/usr/bin/puppet cert --clean --all
def self.clean certname, addr
from threading import Thread
import subprocess
from Queue import Queue
num_threads = 4
queue = Queue()
ips = ["odm.huronhs.com", "10.13.2.1"]
#wraps system ping command
def pinger(i, q):
"""Pings subnet"""
bash-3.2# networksetup -listnetworkserviceorder | awk -F': ' '/Ethernet,/ {gsub(/\)/,"");print $3}'
bash-3.2# networksetup -listnetworkserviceorder
An asterisk (*) denotes that a network service is disabled.
(1) Ethernet 1
(Hardware Port: Ethernet 1, Device: en0)
(*) Ethernet 2
(Hardware Port: Ethernet 2, Device: en1)
(*) Built-in Serial Port (1)
#!/usr/bin/python2.5
#
# Grab BSD interface names for the first Airport and Ethernet interfaces on your computer.
#
import subprocess
ethTest = "networksetup -listnetworkserviceorder | awk -F': ' '/Ethernet,/ || /Ethernet .,/ {gsub(/\)/,\"\");print $3}'"
apTest = "networksetup -listnetworkserviceorder | awk -F': ' '/AirPort,/ {gsub(/\)/,\"\");print $3}'"
newdict = {}
def searchContactNodes(self, nodeToFind):
"""A utility function to search through Contact nodes looking for a specific node
---
Arguments:
nodeToFind - The node you're looking to find.
Returns: Nothing
"""
for node in pymacds.GetLDAPv3ContactsNodes():
if node == nodeToFind:
return "true"