Skip to content

Instantly share code, notes, and snippets.

View tcotav's full-sized avatar

James Francis tcotav

View GitHub Profile
@tcotav
tcotav / winrm_chef_setup_on_vm
Created July 1, 2014 17:20
winrm chef setup on vm
## Notes on Azure Windows VM Creation
We want to be able to spin up from scripts Windows images in Azure with Chef fully provisioned and working.
### Requirements
- chef workstation and hosted/enterprise chef account
- [Azure Command-Line Tools](http://azure.microsoft.com/en-us/downloads/) for your os
- [knife azure plugin](http://docs.opscode.com/plugin_knife_azure.html) on your chef workstation
### Knife Azure A Windows Server, Right?
@tcotav
tcotav / microsoft_azure_storage_container:retrieve.rb
Created July 1, 2014 17:10
using microsoft_azure_storage_container :retrieve
## use this for your metadata.rb
# for setup info -- see this https://github.com/chef-partners/azure-cookbook
depends 'microsoft_azure'
depends 'iis'
depends '7-zip'
###########################################
## how to use the resource
@tcotav
tcotav / azure_get_blob_fail
Created June 27, 2014 21:06
NoMemoryError: microsoft_azure_storage_container -- fails on getblob
test-box-0.cloudapp.net [2014-06-27T21:05:00+00:00] INFO: Processing chef_gem[azure] action install (microsoft_azure::default line 28)
test-box-0.cloudapp.net [2014-06-27T21:05:00+00:00] INFO: Processing microsoft_azure_storage_container[my-node] action retrieve (windowsapp::default line 25)
test-box-0.cloudapp.net Target content length: 118525358
test-box-0.cloudapp.net
test-box-0.cloudapp.net ================================================================================
test-box-0.cloudapp.net Error executing action `retrieve` on resource 'microsoft_azure_storage_container[my-node]'
test-box-0.cloudapp.net ================================================================================
test-box-0.cloudapp.net
test-box-0.cloudapp.net NoMemoryError
test-box-0.cloudapp.net -------------
@tcotav
tcotav / azure_get_blob.rb
Created June 27, 2014 19:03
Working around the chef azure cookbook -- no blob download method... here, let me write one for you :-/ Will need to rewrite to integrate with actual cookbook.
require 'azure'
# run looks like this
#
# $ ruby get_blob.rb
# write-pdf - length: 9613706, last-modified: Fri, 27 Jun 2014 18:28:49 GMT
# Target content length: 9613706
# --- progress 43.63 percent, time: 29.08 s
# --- progress 87.26 percent, time: 26.68 s
tmp james$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'opscode-ubuntu-13.04'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: tmp_default_1400693061955_85059
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
@tcotav
tcotav / VagrantChefInitialSetup
Created March 20, 2014 23:09
Vagrant and Chef quick initial setup
Quick Spin up for Chef
1) sign up for hosted chef
https://preview.opscode.com/signup
This gives you 5 free nodes. Follow instructions they give you to get chef workstation installed/working.
2) download and install virtualbox - http://virtualbox.org
@tcotav
tcotav / Vagrantfile
Created March 18, 2014 23:49
Edit the below Vagrant file to match you environment and off you go with a shiny chef-client
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
# set this variable and off you go
orgName='YOUR_CHEF_HOSTED_ORG_NAME_HERE'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
@tcotav
tcotav / Vagrantfile
Created March 6, 2014 02:15
Vagrantfile for test local salt + minion
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos6.4"
# Every Vagrant virtual environment requires a box to build off of.
config.vm.define "master", primary: true do |box|
box.vm.hostname = "salt"
box.vm.network "public_network"
box.vm.network "private_network", ip: "192.168.56.160"
@tcotav
tcotav / gist:7948702
Created December 13, 2013 18:18
dynamically adding a variable to an object (for tagging source, for example)

adding a variable into the object

Here's now we dynamically add that variable/accessor on an already created object:

def tagList(item_list)
item_list.each do |item|
  item.class.module_eval { attr_accessor :source_type}
  item.source_type = some_source_type_A
done
itemlist
@tcotav
tcotav / ohai_disable_windows
Last active December 28, 2015 21:39
Ohai Plugin config to disable irrelevant or poorly performing plugins on windows
Ohai::Config::disabled_plugins= [
#
# add to client.rb file -- c:\chef\client.rb
#
# ref: http://www.slideshare.net/opscode/chef-conf-windowsdougireton # slide 30
# ohai plugins that have poor perf or are irrelevant to windows
#
"c", "cloud", "ec2", "rackspace", "eucalyptus", "command", "dmi", "dmi_common",
"erlang", "groovy", "ip_scopes", "java", "keys", "lua", "mono", "network_listeners",
"passwd", "perl", "php", "python", "ssh_host_key", "uptime", "virtualization",