Skip to content

Instantly share code, notes, and snippets.

View scottslowe's full-sized avatar

Scott S. Lowe scottslowe

View GitHub Profile
@scottslowe
scottslowe / ugly-json
Last active August 19, 2016 23:59
This is raw JSON-serialized output from a REST API call
{"results": [{"type": "LogicalSwitchConfig", "_schema": "/ws.v1/schema/LogicalSw
itchConfig", "_href": "/ws.v1/lswitch/3ca2d5ef-6a0f-4392-9ec1-a6645234bc55"}, {"
type": "LogicalSwitchConfig", "_schema": "/ws.v1/schema/LogicalSwitchConfig", "_
href": "/ws.v1/lswitch/81f51868-2142-48a8-93ff-ef612249e025"}, {"type": "Logical
SwitchConfig", "_schema": "/ws.v1/schema/LogicalSwitchConfig", "_href": "/ws.v1/
lswitch/9fed3467-dd74-421b-ab30-7bc9bfae6248"}], "result_count": 3}
@scottslowe
scottslowe / pretty-json
Created November 8, 2013 12:09
This output came from running the raw JSON-serialized response to a REST API through the python json.tool command.
{
"result_count": 3,
"results": [
{
"_href": "/ws.v1/lswitch/3ca2d5ef-6a0f-4392-9ec1-a6645234bc55",
"_schema": "/ws.v1/schema/LogicalSwitchConfig",
"type": "LogicalSwitchConfig"
},
{
"_href": "/ws.v1/lswitch/81f51868-2142-48a8-93ff-ef612249e025",
@scottslowe
scottslowe / json-prettify-script
Created November 8, 2013 01:32
This very simple shell script can be used by BBEdit as a text filter to "prettify" JSON output in a more human-readable form.
#!/bin/sh
python -m json.tool
@scottslowe
scottslowe / virt-user-with-ssh-key
Created October 21, 2013 17:44
When used in conjunction with an appropriate define-based virtual resource (see gist named "defined-virt-user-ssh-key"), this will define a user including their public SSH key.
@accounts::virtual { 'jsmith':
uid => 5001,
realname => 'John Smith',
pass => '<insert password hash here>',
sshkeytype => 'ssh-dss',
sshkey => '<insert SSH key here>',
require => Class['accounts::config'],
}
@scottslowe
scottslowe / defined-virt-user-ssh-key
Created October 20, 2013 03:38
This Puppet code uses define-based virtual user resources to help manage user account on systems. This includes user's SSH keys as well as other properties.
define accounts::virtual ($uid,$realname,$pass,$sshkeytype,$sshkey) {
include accounts::params
# Pull in values from accounts::params
$homepath = $accounts::params::homepath
$shell = $accounts::params::shell
# Create the user
user { $title:
ensure => 'present',
@scottslowe
scottslowe / puppet-ovs-packages
Created October 11, 2013 17:04
This portion of Puppet code installs Open vSwitch (OVS) packages from an internal repository, along with prerequisite packages.
if $::operatingsystem == 'Ubuntu' {
# Install prerequisite packages
package {'make':
ensure => 'installed',
}
package {'dkms':
ensure => 'installed',
}
@scottslowe
scottslowe / ubuntu-1204-server-preseed
Created October 10, 2013 20:50
This preseed file automates the installation of Ubuntu Server 12.04. Replace the values bracketed by less than/greater than symbols with values specific to your own environment.
# Ubuntu Server automated installation
d-i debian-installer/locale string en_US
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string us
d-i netcfg/choose_interface select eth0
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/wireless_wep string
d-i mirror/country string manual
@scottslowe
scottslowe / puppet-apt-proxy-config
Created October 10, 2013 20:06
This snippet of Puppet code (which relies upon the Puppet Labs Apt module) will configure apt to use a local Apt proxy (in this example, a local instance of Apt-Cacher-NG).
# Configure apt to use apt-cacher-ng
class {'apt':
proxy_host => 'apt-cacher-ng.example.com',
proxy_port => '3142',
}
@scottslowe
scottslowe / apt-source-ubuntu-cloud
Created October 4, 2013 14:51
This snippet of Puppet code, designed for use with the Puppet Labs apt module, configures an Ubuntu system to use the Ubuntu Cloud Archive.
apt::source { 'ubuntu-cloud':
location => 'http://ubuntu-cloud.archive.canonical.com/ubuntu',
repos => 'main',
release => 'precise-updates/grizzly',
include_src => false,
required_packages => 'ubuntu-cloud-keyring',
}
@scottslowe
scottslowe / ovs-vsctl-list-interface
Created September 4, 2013 14:25
This output from "ovs-vsctl list interface vnet0" shows how to match an OVS interface to a specific VM using the MAC address stored in the external_ids value.
_uuid : d3613f46-4ef8-4e4c-99f6-55676394a32a
admin_state : up
cfm_fault : []
cfm_fault_status : []
cfm_health : []
cfm_mpid : []
cfm_remote_mpids : []
cfm_remote_opstate : []
duplex : full
external_ids : {attached-mac="52:54:00:B5:AE:29", iface-id="d198ac1a-c93e-af49-a0f0-ad78a5b19a56", iface-status=active, vm-id="c0e9b909-7233-d2eb-7fde-3a2d39db1ae5"}