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 / kine.rb - file.rb
Created February 4, 2015 14:36
chef file resource with laze attribute evaluation
file File.join(tmp_infra_dir, 'knife.rb') do
content lazy {
<<-EOH
node_name 'james'
chef_server_url '#{chef_server_url}'
client_key '#{tmp_infra_dir}/james.pem'
cookbook_path '#{Chef::Config[:cookbook_path]}'
trusted_certs_dir '#{Chef::Config[:trusted_certs_dir]}'
EOH
}
@vinyar
vinyar / default_ad_container.ps1
Last active August 29, 2015 14:15
Configuring DNS and WINS for Win2k8r2 NIC to allow domain joining
Import-Module ActiveDirectory
$ou = (Get-ADOrganizationalUnit -Filter 'New Members').DistinguishedName
redircmp $ou
redirusr $ou
@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
@vinyar
vinyar / create.rb
Created March 25, 2015 13:02
Creating Azure instance with Chef-Provisioning
#
# Cookbook Name:: chef-provisioning-azure
# Recipe:: default
#
# Copyright 2015, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
require 'chef/provisioning/azure_driver'
@vinyar
vinyar / hello.rb
Created March 26, 2015 07:33
using root group on OSX with chef-apply
$ chef-apply test.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* file[hello.txt] action create
* cannot determine group id for 'root', does the group exist on this system?
================================================================================
Error executing action `create` on resource 'file[hello.txt]'
================================================================================
Chef::Exceptions::GroupIDNotFound
---------------------------------
@vinyar
vinyar / chef -v.rb
Last active August 29, 2015 14:18
gems for Sean
$ chef -v
Chef Development Kit Version: 0.4.0
@vinyar
vinyar / gist:c77721949db8f7cb0884
Last active August 29, 2015 14:19
Using Rubymine Chef plugin - Observations
*) When I opened a cookbook, it would throw a bunch of VCS errors.
It offered me to add VCS paths to project.
- I dont know what VCS is
- I dont know what it would do
*) I would expect the 'project' to automatically detect that I am opening a Chef cookbook (Given the relatively unique and predictable structure of a chef coobook)
_ I could not figure out how to make Rubymine see an existing cookbook as a cookbook
-- Eventually I found a blogpost (http://blog.jetbrains.com/ruby/2014/09/whats-mining-chef-integration/)
--- blog post mentioned setting the project as a cookbook via some menu. I could not find the menu
--- Eventually I found that I can right click on the root of the project (cookbook), select 'mark directory as' and select 'cookbook root'
@vinyar
vinyar / full.rb
Last active August 29, 2015 14:20
reboot required after chef-server install on RHEL 6.6 (possibly related to rabbitmq)
2015-04-29_21:47:32.52056 transient,infinity,supervisor,
2015-04-29_21:47:32.52057 [tcp_listener_sup]}}}}}}}}}
2015-04-29_21:47:32.52057
2015-04-29_21:47:32.52058 Log files (may contain more information):
2015-04-29_21:47:32.52058 /var/opt/opscode/rabbitmq/log/[email protected]
2015-04-29_21:47:32.52058 /var/opt/opscode/rabbitmq/log/[email protected]
2015-04-29_21:47:32.52059
2015-04-29_21:47:33.61615 {"init terminating in do_boot",{rabbit,failure_during_boot,{could_not_start,rabbit,{bad_return,{{rabbit,start,[normal,[]]},{'EXIT',{rabbit,failure_during_boot,{case_clause,{error,{{shutdown,{failed_to_start_child,tcp_listener,{cannot_listen,{127,0,0,1},5672,eaddrinuse}}},{child,undefined,'rabbit_tcp_listener_sup_127.0.0.1:5672',{tcp_listener_sup,start_link,[{127,0,0,1},5672,[inet,binary,{packet,raw},{reuseaddr,true},{backlog,128},{nodelay,true},{linger,{true,0}},{exit_on_close,false}],{rabbit_networking,tcp_listener_started,[amqp]},{rabbit_networking,tcp_listener_stoppe
@vinyar
vinyar / gist:3a722c21f002c950a2c3
Created May 6, 2015 19:44
tiered chef server errors in /var/log/opscode/opscode-erchef/current
2015-05-06_19:42:24.92758 [error] Could not start the network driver: econnrefused
2015-05-06_19:42:24.92761
2015-05-06_19:42:24.93009 [error] gen_server <0.1906.0> terminated with reason: econnrefused
2015-05-06_19:42:24.93264 [error] CRASH REPORT Process <0.1906.0> with 0 neighbours exited with reason: econnrefused in gen_server:terminate/6 line 744
2015-05-06_19:42:24.93492 [error] Supervisor {<0.1904.0>,amqp_connection_sup} had child at module undefined at <0.1906.0> exit with reason econnrefused in context child_terminated
2015-05-06_19:42:24.93713 [error] Supervisor {<0.1904.0>,amqp_connection_sup} had child at module undefined at <0.1906.0> exit with reason reached_max_restart_intensity in context shutdown
2015-05-06_19:42:24.94114 [error] "Could not connect, scheduling reconnect.", error: {{error,{badmatch,{error,{auth_failure_likely,{econnrefused,{gen_server,call,[<0.1906.0>,connect,infinity]}}}}},[{bunny_util,connect,1,[{file,"src/bunny_util.erl"},{line,191}]},{gen_bunny_mon,do_connect,3,[{file,"src
@vinyar
vinyar / Chef server 10 to 12 migration - fix_ACL_perms.rb
Last active August 29, 2015 14:23
fix node permissions for chef server 10 to 12 migration
#!/usr/bin/env ruby
require 'rubygems'
require 'chef/knife'
Chef::Config.from_file(File.join(Chef::Knife.chef_config_dir, 'knife.rb'))
rest = Chef::REST.new(Chef::Config[:chef_server_url])
Chef::Node.list.each do |node|
%w{read update delete grant}.each do |perm|
ace = rest.get("nodes/#{node[0]}/_acl")[perm]