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
remote_file "/tmp/nagios_libexec.tar.gz" do
source "#{node[:app][:remote_resource]}/nagios/nagios_libexec.tar.gz"
mode "0644"
action :create_if_missing
end
bash "Unpack libexec" do
cwd "/home/nagios/libexec"
code <<-EOH
rm -rf /home/nagios/libexec/*
bash "Add nagios group to AllowGroups in sshd_config" do
user "root"
code <<-EOH
sed -i 's/\(^AllowGroups.*\)/\1 nagios/' /etc/ssh/sshd_config
/sbin/service sshd restart
EOH
end
@Maniacal
Maniacal / gist:2727761
Created May 18, 2012 21:43
resource notification issue
remote_file "/tmp/apache-tomcat-#{node[:tomcat][:version]}.tar.gz" do
source "#{node[:app][:remote_resource]}/apache-tomcat-#{node[:tomcat][:version]}.tar.gz"
mode "0644"
action :create_if_missing
notifies :run, "bash[Unpack Tomcat]", :immediately
notifies :create, "link[#{tomcat_dir}/default]", :immediately
end
bash "Unpack Tomcat" do
cwd "#{tomcat_dir}"
@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")
@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 / 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
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
$ 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'
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
@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