Skip to content

Instantly share code, notes, and snippets.

View vinyar's full-sized avatar

Mr. Pacman vinyar

  • Launch Consulting
  • Seattle
View GitHub Profile
<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
@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'] %>/
# 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')
powershell_script "Install IIS" do
code "add-windowsfeature Web-Server"
action :run
end
service "w3svc" do
action [:enable, :start ]
end
#node.default["iis_demo"]["indexfile"] = "Default2.htm"
@vinyar
vinyar / knife.rb
Last active August 29, 2015 14:17 — forked from jtimberman/knife.rb
# Knife Configuration File.
#
# This is a Ruby DSL to set configuration parameters for Knife's
# general options. The default location for this file is
# ~/.chef/knife.rb. If multiple Chef repositories are used,
# per-repository configuration files can be created. A per repository
# configuration file must be .chef/knife.rb in the base directory of
# the Chef repository. For example,
#
# ~/Development/chef-repo/.chef/knife.rb