Skip to content

Instantly share code, notes, and snippets.

View tcotav's full-sized avatar

James Francis tcotav

View GitHub Profile
@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 / 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
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 / 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
@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 / 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 / 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 / reinit-salt-minion.sh
Last active August 29, 2015 14:05
Re-initialize salt-minion
#!/bin/bash
# basically delete all signs of previous id and data
# and start over
/etc/init.d/salt-minion stop
rm -Rf /var/cache/salt/minion
rm /etc/salt/minion_id
rm -Rf /etc/salt/pki
@tcotav
tcotav / gist:ea4dd5535aef9bb5da8c
Created August 19, 2014 20:39
Using module.run with salt modules

Wut

There are multiple kinds of modules in salt. Some you can use in the jinja templates directly, but the big list requires you to use module.run

Sample code

Here's a sampe of us using module.run to invoke the module linux_sysctl.persist method:

redis_sysctl:

module.run:

@tcotav
tcotav / mongodb
Created September 4, 2014 19:50
WORKING Ubuntu Mongodb Start Script
#!/bin/sh
#
# init.d script with LSB support.
#
# Copyright (c) 2007 Javier Fernandez-Sanguino <[email protected]>
#
# This is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2,
# or (at your option) any later version.