Skip to content

Instantly share code, notes, and snippets.

View Maniacal's full-sized avatar

Michael Glenney Maniacal

  • New Context
  • Phoenix, Arizona, US
View GitHub Profile
var1 = node['domain_home'] + "/" + node['domain_name'] + "/var1"
var2 = node['domain_home'] + "/somepath/var2"
%w{var1 var2} each do |domain_directory|
directory domain_directory do
mode 0775
owner 'weblogic'
group 'weblogic'
action :create
recursive true
@Maniacal
Maniacal / gist:7016848
Created October 16, 2013 23:35
chef attributes weirdness
Here's some test stuff I've setup to figure this out:
access_control provider:
action :add do
if new_resource.environments.include?(node.chef_environment)
case new_resource.type
when "user"
puts ""
puts "Default before add: #{node.default.authorization.access.users}"
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.7
- RUBY VERSION: 1.9.3 (2013-06-27 patchlevel 448) [x86_64-linux]
- INSTALLATION DIRECTORY: /opt/ruby/1.9.3-p448/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /opt/ruby/1.9.3-p448/bin/ruby
- EXECUTABLE DIRECTORY: /opt/ruby/1.9.3-p448/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
@Maniacal
Maniacal / gist:5733278
Created June 8, 2013 00:14
dos2unix only files that need it
IFS=:
while read -r name data; do
if [[ "$data" =~ CRLF ]]; then
dos2unix $name
fi
done < <(find . -type f -exec file {} \;)
unset IFS
e = execute "yum install -y -q libxml2 libxml2-devel libxslt libxslt-devel" do
action :nothing
end
e.run_action(:run)
g = gem_package "fog" do
version "1.1.2"
action :nothing
$ sudo cat /var/chef/cache/chef-stacktrace.out
Generated at 2012-12-03 16:41:30 -0700
NoMethodError: gem_package[fog] (s3_file::default line 27) had an error: NoMethodError: undefined method `full_name' for nil:NilClass
/usr/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:136:in `block in gather_dependencies'
/usr/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:136:in `map'
/usr/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:136:in `gather_dependencies'
/usr/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:267:in `install'
/usr/lib/ruby/gems/1.9.1/gems/chef-10.12.0/lib/chef/provider/package/rubygems.rb:169:in `block (2 levels) in install'
/usr/lib/ruby/gems/1.9.1/gems/chef-10.12.0/lib/chef/provider/package/rubygems.rb:192:in `with_correct_verbosity'
/usr/lib/ruby/gems/1.9.1/gems/chef-10.12.0/lib/chef/provider/package/rubygems.rb:168:in `block in install'
NoMethodError: gem_package[fog] (s3_file::default line 27) had an error: NoMethodError: undefined method `full_name' for nil:NilClass
/usr/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:136:in `block in gather_dependencies'
/usr/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:136:in `map'
/usr/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:136:in `gather_dependencies'
/usr/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:267:in `install'
/usr/lib/ruby/gems/1.9.1/gems/chef-10.12.0/lib/chef/provider/package/rubygems.rb:169:in `block (2 levels) in install'
/usr/lib/ruby/gems/1.9.1/gems/chef-10.12.0/lib/chef/provider/package/rubygems.rb:192:in `with_correct_verbosity'
/usr/lib/ruby/gems/1.9.1/gems/chef-10.12.0/lib/chef/provider/package/rubygems.rb:168:in `block in install'
/usr/lib/ruby/gems/1.9.1/gems/chef-10.12.0/lib/chef/provider/package/rubygems.rb:103:in `with_gem_sources'
/usr/lib/ruby/gems/1.9.1/gems/chef-10.12.0/lib/chef/provider/package/rubygems.rb:167:in `install
@Maniacal
Maniacal / gist:3006472
Created June 27, 2012 20:00
Problem with awk command
This is what I have in my recipe:
bash "Set newrelic java options" do
user "root"
group "root"
cwd glassfishconfig
code <<-EOH
awk -v searchterm="<java-config" -v payload=" <jvm-options>-javaagent:#{newrelic_dir}/newrelic-#{node[:newrelic][:version]}/newrelic.jar</jvm-options>\n <jvm-options>-Dnewrelic.config.file=#{newrelic_dir}/#{node[:app][:key]}/newrelic.yml</jvm-options>\n <jvm-options>-Dnewrelic.config.log_file_path=#{newrelic_dir}/#{node[:app][:key]}/logs</jvm-options>" '{ if ($0 ~ searchterm) print $0 "\n" payload; else print $0 }' domain.xml.newrelic.bak > domain.xml
EOH
action :nothing
@Maniacal
Maniacal / gist:2925821
Created June 13, 2012 19:04
Problem with chef server resource
The following is for a chef-client 0.10.8 run
This is what it says in chef wiki concerning the service resource (http://wiki.opscode.com/display/chef/Resources#Resources-Service):
:status - the init script or other service provider can use a status command to determine if the service is running. If this is not specified, Chef will attempt to match the service_name against the process table as a regular expression, unless pattern is specified as a parameter attribute.
I have a service who's init script isn't proper so it doesn't support chkconfig, status, etc. It will eventually be fixed but not now. In the mean time it doesn't appear as if chef is doing what the wiki says it'll do.
Here's the resource from the recipe:
@Maniacal
Maniacal / logmover.rb
Created May 23, 2012 17:56
Log mover script for moving logs to s3
#!/usr/bin/env ruby
#
# Script for pushing logs to s3
#
#require 'rubygems'
#require 'yaml'
require 'fog'
config_file = File.join(File.dirname(__FILE__),"logmoverconfig.yml")