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 / aws_automation.ps1
Created October 4, 2013 19:20
Windows automation
function Disable-InternetExplorerESC {
$AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}"
$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0
Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0
Stop-Process -Name Explorer
Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." -ForegroundColor Green
}
Disable-InternetExplorerESC
# -original- class PendingReboot # < Chef::Handler
class Chef
class Resource
# include Chef::Mixin::ShellOut
def reboot_pending?
# Any files listed here means reboot needed
(Registry.key_exists?('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations') &&
Registry.get_value('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager','PendingFileRenameOperations').any?) ||
@vinyar
vinyar / gist:8463920
Last active January 3, 2016 12:39
config verification for vagrant
winrm get winrm/config
winrm get winrm/config/winrs
winrm get winrm/config/service
winrm get winrm/config/service/auth
winrm get winrm/config/service/auth
---- you want to confirm that the values you have match these:
winrm set winrm/config '@{MaxTimeoutms="1800000"}';
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="300"}';
@vinyar
vinyar / not sure if a bug
Created April 10, 2014 07:14
installing pry on chef 11.12.2 on windows
PS C:\chef> gem install pry
Successfully installed pry-0.9.12.6-x86-mingw32
1 gem installed
Installing ri documentation for pry-0.9.12.6-x86-mingw32...
RDoc::Parser::Ruby failure around line 25 of
lib/pry/commands/ls.rb
Before reporting this, could you check that the file you're documenting
has proper syntax:
@vinyar
vinyar / search.rb
Created April 10, 2014 08:34
Using knife search with Windows IIS
#
# Cookbook Name:: iis_demo
# Recipe:: default
#
# Copyright 2014, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
powershell_script "Install IIS" do
<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>
require 'spec_helper'
describe 'mysql::server' do
let(:centos5_run) { ChefSpec::Runner.new(platform: 'centos', version: '5.9').converge(described_recipe) }
let(:centos6_run) { ChefSpec::Runner.new(platform: 'centos', version: '6.4').converge(described_recipe) }
let(:ubuntu_1004_run) { ChefSpec::Runner.new(platform: 'ubuntu', version: '10.04').converge(described_recipe) }
let(:ubuntu_1204_run) { ChefSpec::Runner.new(platform: 'ubuntu', version: '10.04').converge(described_recipe) }
let(:ubuntu_1304_run) { ChefSpec::Runner.new(platform: 'ubuntu', version: '13.04').converge(described_recipe) }
it 'includes _server_rhel on centos5' do
@vinyar
vinyar / chef bootstrap.ps1
Last active August 29, 2015 14:01
Opening up WinRm for Chef bottstrap to work
# Get the instance ready for our bootstrapper, commands courtesy of Julian Dunn
winrm quickconfig -q;
Enable-PSRemoting -force;
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="300"}';
winrm set winrm/config '@{MaxTimeoutms="1800000"}';
winrm set winrm/config/service '@{AllowUnencrypted="true"}';
winrm set winrm/config/service/auth '@{Basic="true"}';
netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" profile=public protocol=tcp localport=5985 new remoteip=any;
@vinyar
vinyar / chef windows registry.rb
Created May 10, 2014 02:18
Troubleshooting idempotence with registry_key resource on chef 11.8.0
Attribute file:
default['winsecureos']['registry']['eventlog']['HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application'] =
[
{:name => 'MaxSize', :type => :dword, :data => '20971520'},
{:name => 'RestrictGuestAccess', :type => :dword, :data => '1'},
{:name => 'Retention', :type => :dword, :data => '1'},
{:name => 'AutoBackupLogFiles', :type => :dword, :data => '1'}
]
Recipe:
@vinyar
vinyar / helpers.rb
Created May 29, 2014 09:13
hotfix for chef-client for when administrator is renamed (chef-client/libraries/helpers.rb)
def root_owner
if ['windows'].include?(node['platform'])
adminAccount = WMI::Win32_UserAccount.find(:first,:conditions => "SID like 'S-1-5-21-%-500' AND LocalAccount=True")
adminAccount.Name
else
'root'
end
end
def dir_owner