Skip to content

Instantly share code, notes, and snippets.

View vinyar's full-sized avatar

Mr. Pacman vinyar

  • Launch Consulting
  • Seattle
View GitHub Profile
@vinyar
vinyar / knife.sh
Created August 20, 2013 22:15 — forked from nukemberg/knife.sh
# vim: ft=sh:ts=4:sw=4:autoindent:expandtab:
# Author: Avishai Ish-Shalom <avishai@fewbytes.com>
# We need to specify GNU sed for OS X, BSDs, etc.
if [[ "$(uname -s)" == "Darwin" ]]; then
SED=gsed
else
SED=sed
fi
<powershell>
#https://gist.github.com/vinyar/6735863
# below two commands are known to fail for arbitrary reasons
try { winrm quickconfig -q }
catch {write-host "winrm quickconfig failed"}
try { Enable-PSRemoting -force}
catch {write-host "Enable-PSRemoting -force failed"}
write-host 'setting up WinRm';
<html>
<body>
<h1>Hello, <%= node['iis_demo']['greeting'] %>!</h1>
<h2>This is server <%= node['hostname']%></h2>
<h3>Do you know the capitals of the following countries?</h3>
<% @country.each do |item| -%>
<p><a href=<%="#{item}"%>.htm><%="#{item}"%></a></p>
<% end -%>
</body>
</html>
# include Windows::Helper from Opscode Windows Cookbook
::Chef::Recipe.send(:include, Windows::Helper)
# now you can call helper methods like win_friendly_path directly
my_batch_file = win_friendly_path(
::File.join( node['cookbook']['batch_dir'],'foo.bat'))
execute "My batch file" do
command my_batch_file
creates "e:/logs/my_batch_file.log"
require 'chef/provider'
require 'restclient'
class Chef
class Provider
class Artifact < Chef::Provider
def load_current_resource
@current_resource = Chef::Resource::Artifact.new(new_resource.name)
art_user = new_resource.user
$Server = "VCENTER SERVER"
$datacenter = Get-Datacenter -Name "DATACENTER NAME"
$cluster = Get-Cluster -Name "CLUSTER NAME" -Location $datacenter
$TemplateName = "TEMPLATE NAME"
$Template = Get-Template -Name $TemplateName -Location $datacenter
$Datastore = Get-DatastoreCluster -Name "DATASTORE NAME"
$ResourcePool = Get-ResourcePool -Name "RESOURCE POOL NAME" -Location $cluster
$folder = "FOLDER NAME"
$vmname = "VM NAME"
describe String do
it "responds to #to_s" do
expect("").to respond_to(:to_s)
end
it "responds to the correct methods" do
[ :to_s, :to_i, :to_f ].each do |method|
expect("").to respond_to(method)
end
@vinyar
vinyar / apache.rb
Last active August 29, 2015 14:06 — forked from mcquin/apache.rb
# plugins/apache/modules.rb
# :ApacheModules good, you might have some other plugin providing modules
# and you wouldn't want to overlap on the :Modules namespace.
Ohai.plugin(:ApacheModules) do
require 'mixlib/shellout'
provides "apache/modules"
collect_data(:default) do
string = Mixlib::ShellOut.new("apachectl -t -D DUMP_MODULES")
string.run_command
# Plugin-specific configurations
if Vagrant.has_plugin?('vagrant-cachier')
puts 'INFO: Vagrant-cachier plugin detected. Optimizing caches.'
config.cache.enable :chef
config.cache.enable :apt
else
puts 'WARN: Vagrant-cachier plugin not detected. Continuing unoptimized.'
end
if Vagrant.has_plugin?('Omnibus')
@vinyar
vinyar / gemrc.erb
Last active August 29, 2015 14:06 — forked from charlesjohnson/gemrc.erb
:sources:
- http://<%= node['gem_file']['host'] %>:<%= node['gem_file']['port'] %>/