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 / metadata.rb
Created June 27, 2014 23:22
Optional dependencies for metadata.rb (untested)
if platform_family?("windows")
depends 'windows'
depends '7-zip'
end
@vinyar
vinyar / TK on windows.txt
Created July 11, 2014 01:37
Test Kitchen blowing up due to dep-selector
Salims TK on windows host
C:\Users\vinyara\Documents\clients> cd .\ge_tk
C:\Users\vinyara\Documents\clients\ge_tk> git clone https://github.com/afiune/tk-windows
Cloning into 'tk-windows'...
remote: Counting objects: 39, done.
remote: Compressing objects: 100% (22/22), done.
remote: Total 39 (delta 6), reused 35 (delta 4)
Unpacking objects: 100% (39/39), done.
C:\Users\vinyara\Documents\clients\ge_tk> cd .\tk-windows
56 puts node['ge_netbackup']['bpcd_start_command']
57 service "bpcd" do
58 start_command node['ge_netbackup']['bpcd_start_command']
59 action :start
60 end
12:43PM
> [#] Recipe: ge_netbackup::configure_linux
> [#] * service[bpcd] action start[2014-07-11T15:38:53-04:00] INFO: Processing service[bpcd] action start (ge_netbackup::configure_linux line 57)
> [#]
> [#] * service[bpcd]: unable to locate the init.d script!
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"
@vinyar
vinyar / custom resource definition.rb
Last active August 29, 2015 14:04
handing undefined attributes in chef/ruby loops
chef:recipe > a = 'stuff'
chef:recipe >
chef:recipe > service 'testing_start' do
chef:recipe > action defined?(a) ? :start : :stop
chef:recipe ?> end
=> <service[testing_start] @name: "testing_start" @noop: nil @before: nil @params: {} @provider: nil @allowed_actions: [:nothing, :enable, :disable, :start, :stop, :restart, :reload] @action: [:start] @updated: false @updated_by_last_action: false @supports: {:restart=>false, :reload=>false, :status=>false} @ignore_failure: false @retries: 0 @retry_delay: 2 @source_line: "(irb#2):144:in `irb_binding'" @guard_interpreter: :default @elapsed_time: 0 @resource_name: :service @service_name: "testing_start" @enabled: nil @running: nil @parameters: nil @pattern: "testing_start" @start_command: nil @stop_command: nil @status_command: nil @restart_command: nil @reload_command: nil @init_command: nil @priority: nil @cookbook_name: nil @recipe_name: nil>
chef:recipe >
chef:recipe >
chef:recipe > d
'
chef:attributes >
chef:attributes > default['ge_registry_framework']['HKLM\Software\Policies\Microsoft\Windows\TCPIP\v6Transition'] =
chef:attributes > {:name => 'Force_Tuneling', :type => :multi_string, :data => 'Enabled'}
=> {:name=>"Force_Tuneling", :type=>:multi_string, :data=>"Enabled"}
chef:attributes >
chef:attributes > recipe_mode
chef:recipe >
chef:recipe >
chef:recipe >
chef:recipe > node['ge_registry_framework'].each do |k,v|
@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|
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: