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 / chef-shell output.rb
Last active August 26, 2015 18:00
chef-shell output
alex was here
Last login: Mon Aug 17 17:51:24 on ttys004
alexvinyar@seavinyar02 ~ $ chef-shell
loading configuration: none (standalone session)
Session type: standalone
Loading.......done.
This is the chef-shell.
Chef Version: 12.3.0
@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:
<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
echo Validation key written.
@echo on
> C:\chef\client.rb (
echo.log_level :info
echo.log_location STDOUT
echo.
attribute:
default['ge_opsware_agent']['agent_dir'] = "/opt/opsware/stage/agent"
recipe:
directory node['ge_opsware_agent']['agent_dir'] do
owner "root"
# 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"