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 / vagrant.rb
Created August 7, 2014 23:33
generic windows vagrant file (you dont actually need .rb)
# -*- mode: ruby -*-
# vi: set ft=ruby :
cookbook_name = "cookbooking"
box = "win2012r2-chef11.14.2-1"
box_url = "~/Documents/ISO_BOX_etc/win2012r2-chef11.14.2-1"
hostname = "windows2012r2"
Vagrant.configure("2") do |config|
config.vm.define cookbook_name do |config|
@vinyar
vinyar / serverspec output.ps1
Created August 8, 2014 21:22
serverspec failing on reg_key numbers
Windows registry key "HKLM\Software\Policies\Microsoft\Power\PowerSettings\3C0BC021-C8A8-4E07-A973-6B14CBCB2B7E" should have property value "ACSettingIndex", :type_dword, "1200"
Failure/Error: it { should have_property_value('ACSettingIndex', :type_dword, '1200')}
$exitCode = 1
$ProgressPreference = "SilentlyContinue"
try {
$success = ((Compare-Object (Get-Item 'Registry::HKLM\Software\Policies\Microsoft\Power\PowerSettings\3C0BC021-C8A8-4E07-A973-6B14CBCB2B7E').GetValue('ACSettingIndex') 4608) -eq $null)
if ($success -is [Boolean] -and $success) { $exitCode = 0 }
} catch {
Write-Output $_.Exception.Message
@vinyar
vinyar / HKLM auditpolicy.ps1
Created August 14, 2014 21:30
Applying audit policies to Registry via Powreshell
# $sddl = 'O:BAG:SYD:PAI(A;CI;KA;;;CO)(A;CI;KA;;;SY)(A;CI;KA;;;BA)(A;CI;KR;;;BU)(A;CI;KR;;;AC)S:AI(AU;CISA;KA;;;WD)' # alternative just in case
$acl = get-acl HKLM:\\SOFTWARE -audit
$audit = "Everyone","FullControl","containerinherit","none","Fail"
$rule = new-object system.security.accesscontrol.registryauditrule $audit
$acl.SetAuditRule($rule)
# $acl.SetSecurityDescriptorSddlForm($sddl) # alternative just in case
set-acl -Path HKLM:\\SOFTWARE -AclObject $acl
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 / rspec output.rb
Created August 21, 2014 23:04
rspec failing on windows against recipe with Multibyte chars
Test:
it "executes dummy command" do
expect(chef_run).to run_execute('random hiragana 料').with_command('puts 料理長')
end
Other notes:
Cookbook upload works fine with Japanese in all parts of the cookbook.
Failure:
@vinyar
vinyar / attribs.rb
Created September 5, 2014 22:31
attribute structure that I like
attributes:
default['winsecureos']['services']['foo'] = {
:action => [ :stop, :disable ],
:name => 'ALG',
:description => 'Application Layer Gateway Service'}
default['winsecureos']['services']['foo1'] = {
:action => [ :stop, :manual ],
:name => 'AppMgmt',
@vinyar
vinyar / nodes.transform.rb
Created September 10, 2014 02:16
nodes.transform(:all) {|n| n.chef_environment("dev")}
0:/opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:2633:Net::HTTPResponse:^: raise error_type().new(@code + ' ' + @message.dump, self)
#0:/opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:2633:Net::HTTPResponse:<: raise error_type().new(@code + ' ' + @message.dump, self)
#0:/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/http.rb:146:Chef::HTTP:-: log_failed_request(response, return_value) unless response.nil?
#0:/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/http.rb:235:Chef::HTTP:>: def log_failed_request(response, return_value)
#0:/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/http.rb:236:Chef::HTTP:-: return_value ||= {}
#0:/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/http.rb:237:Chef::HTTP:-: error_message = "HTTP Request Returned #{response.code} #{response.message}: "
#0:/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/http.rb:238:Chef::HTTP:-: error_message << (return_value["er
@vinyar
vinyar / ohai.rb
Created September 12, 2014 19:35
Rebuilding ohai slide
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
apache Mash.new
apache[:modules] = string.stdout
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')