Skip to content

Instantly share code, notes, and snippets.

@adamhjk
adamhjk / whitelist.rb
Created May 2, 2012 17:07
Whitelisting node attributes
#
# Author:: Adam Jacob (<[email protected]>)
# Copyright:: Copyright (c) 2011 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
export PROMPT='[%n@%M]%(?,,(%?%))$(git_prompt_info)%# '
export RPROMPT=' %~'
ZSH_THEME_GIT_PROMPT_PREFIX="(%{$fg_bold[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})"
ZSH_THEME_GIT_PROMPT_DIRTY="*"
ZSH_THEME_GIT_PROMPT_CLEAN=""
@adamhjk
adamhjk / i_tried_it.txt
Created November 28, 2011 03:51
Because you are so polite..
chef > var = node.default[:var]
=> #<Chef::Node::Attribute @normal={...}, @current_normal=nil, @default={...}, @current_default={}, @override={...}, @current_override=nil, @automatic={...}, @current_automatic=nil, @current_nesting_level=[:var], @auto_vivifiy_on_read=true, @set_unless_value_present=false, @set_type=:default, @has_been_read=false>
chef > var[:a] = 'a'
=> "a"
chef > var[:b][:c] = 'c'
=> "c"
chef > node.default[:var]
=> #<Chef::Node::Attribute @normal={...}, @current_normal=nil, @default={...}, @current_default={"a"=>"a", "b"=>{"c"=>"c"}}, override{....}, current_overridenil, automatic{....}, current_automaticnil, current_nesting_level[:var], auto_vivifiy_on_readtrue, set_unless_value_presentfalse, set_type:default, has_been_readfalse
chef > node.default[:var].to_hash
=> {"a"=>"a", "b"=>{"c"=>"c"}}
asdf /* this is at the end */
asdf /**/
as
dfa
sdf
as
df
(fs)
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
@adamhjk
adamhjk / file_provider_copy.rb
Created August 31, 2011 23:16
Stick this in a library file...
class Chef
class Provider
class File
class Copy << Chef::Provider::File
def compare_content
checksum(@current_resource.path) == checksum(@new_resource.content)
end
@adamhjk
adamhjk / foo.rb
Created August 15, 2011 22:18
load a template with data
begin
r = resources(:template => "/tmp/yourthing")
rescue Chef::Exceptions::ResourceNotFound => e
r = template "/tmp/yourthing" do
variables { :your_defaults => ... }
end
end
r.variables[:your_stuff] = "here"
Provider -----
action :install do
git "/opt/tumult/src" do
repository "[email protected]:pyronicide/foo.git"
revision "#{node["branch"]}"
ssh_wrapper "/opt/glue/bin/deploy_user.sh"
depth 5
action :sync
end
@adamhjk
adamhjk / client.rb
Created July 28, 2011 17:31
describe a new platform in your config file
require 'chef/platform'
redhat_providers = Chef::Platform.platforms[:redhat][:default]
Chef::Platform.platforms[:cloudlinux] = { :default => redhat_providers }