Skip to content

Instantly share code, notes, and snippets.

View stathy's full-sized avatar
🎯
Focusing

Stathy T stathy

🎯
Focusing
View GitHub Profile
@stathy
stathy / user_r-XXX.erb
Last active December 14, 2015 01:19
Custom bootstrap template for user space install. rvm + ruby + chef gem 2 variables to define and align omnibus ruby version and chef version.
bash -c '
ruby_version="1.9.3-p374"
chef_version="11.4.0-1"
# Comment line above, uncomment below, to default to knife 'chef' version
#chef_version="<%= %Q(#{knife_config[:bootstrap_version]}) %>"
<%= %Q(export http_proxy="#{knife_config[:bootstrap_proxy]}") if knife_config[:bootstrap_proxy] %>
@stathy
stathy / gist:5525976
Created May 6, 2013 15:47
Fixes to java-quick-start
# cookbooks/mysql/recipes/client.rb
>> ['ruby1.9.1-full', 'ruby1.9.1-dev', 'rubygems', 'mysql-client',
>>'libmysqlclient-dev'].each do |pkg_name|
>> pkg = package pkg_name do
>> action :nothing
>> end
>> pkg.run_action(:install)
>> end
>> chef_gem 'mysql'
@stathy
stathy / gist:5560474
Created May 11, 2013 16:25
Leveraging GCE utils for copying artifacts generated by Jenkins upto Google drive, spinning up instances in parallel.
sha256sum -b ./dbapp.war > ./dbapp.sha256
gsutil cp ./dbapp.war ./dbapp.sha256 gs://stathy/${JOB_NAME}/${BUILD_NUMBER}/
gsutil setacl public-read gs://stathy/${JOB_NAME}/${BUILD_NUMBER}/dbapp.war
gsutil setacl public-read gs://stathy/${JOB_NAME}/${BUILD_NUMBER}/dbapp.sha256
cd ${WORKSPACE}
gcutil addinstance dbapp-db dbapp-app1 dbapp-lb \
--project "opscode.com:stathy" --image "/projects/opscode.com:stathy/images/centos-latest" \
@stathy
stathy / gist:5560492
Created May 11, 2013 16:30
Opscode Chef API interaction with Ruby to bootstrap new nodes generated by GCE within a Jenkins run, set attributes and assign roles to newly provisioned instances for configuration and application deployment.
#!/usr/local/rvm/rubies/ruby-1.9.3-p362/bin/ruby
#
require 'ridley'
require 'pathname'
require 'openssl'
require 'digest'
require 'json'
class BootstrapError < StandardError; end
@stathy
stathy / gist:5560501
Created May 11, 2013 16:32
Opscode Chef API directly for setting override env attributes so newly bootstrapped nodes can pickup new artifacts for deployment.
#!/opt/opscode/embedded/bin/ruby
#
#!/opt/opscode/embedded/bin/ruby
#
require 'chef/environment'
require 'chef/knife'
require 'chef/knife/cookbook_upload'
require 'chef'
@stathy
stathy / ami_factory_sample_code
Created October 24, 2014 19:09
a sample code snippet for our ami factory booth demo.
include_recipe 'apt'
include_recipe 'nginx'
directory '/var/www/nginx-default' do
owner 'www-data'
group 'www-data'
mode '0755'
recursive true
action :create
end
expect(chef_run.node['bacon']['temperature']).to eq(150)
@stathy
stathy / powershell flag resource example
Last active August 29, 2015 14:17
Example representation of Chef resource converted from powershell_script resource.
powershell_script "Set ExecutionPolicy to Unrestricted" do
code %q(Set-ExecutionPolicy Unrestricted -force)
end
## CONVERT TO
powershell_execution_policy
restricted false
end
powershell_script "Set ExecutionPolicy to Restricted" do
code "Set-ExecutionPolicy Restricted -force"
powershell_script "Setup Team0 Adapter" do
code <<-'EOH'
New-NetLbfoTeam -Name Team0 -TeamNicName TeamNIC0 -TeamMembers NIC0700,NIC1000 -TeamingMode LACP -LoadBalancingAlgorithm TransportPorts -Confirm:$False
'EOH'
end
powershell_script "Setup Team1 Adapter" do
code <<-'EOH'
New-NetLbfoTeam -Name Team1 -TeamNicName TeamNIC1 -TeamMembers NIC0300,NIC0301 -TeamingMode LACP -LoadBalancingAlgorithm TransportPorts -Confirm:$False
'EOH'
@stathy
stathy / gist:92f2089bb81148fa49f2
Last active August 29, 2015 14:24
Sample cluster vagrant file
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
{
:lb => {
:ip => '192.168.65.50',
:memory => 512,