Skip to content

Instantly share code, notes, and snippets.

View leifmadsen's full-sized avatar
🏠
Working from home

Leif Madsen leifmadsen

🏠
Working from home
  • Red Hat
  • Caledon, ON, Canada
  • 23:41 (UTC -05:00)
  • LinkedIn in/leifmadsen
View GitHub Profile
@leifmadsen
leifmadsen / vsftpd.rb
Created August 1, 2012 21:30
Chef template using Discovery library
# Configure vsftpd
template "/etc/vsftpd.conf" do
source "vsftpd-conf.erb"
mode 00644
owner "root"
group "root"
variables({
:public_ipv4 => Discovery.ipaddress(:remote_node => node, :node => node, :type => :public)
})
notifies :reload, "service[vsftpd]"
@leifmadsen
leifmadsen / gist:3490852
Created August 27, 2012 17:56
failsauce
webapp_list.each do |webapp|
if webapp.to_hash.include?(va_local_ipaddress)
Chef::Log.info(webapp.name + " has " + webapp.va_local_ipaddress)
else
Chef::Log.info(webapp.name + " doesn't have a value")
end
end
@leifmadsen
leifmadsen / gist:3777809
Created September 24, 2012 19:29
minitest-chef-handler updates for provider_for_resource
NameError: Cannot find a resource for must_be_installed on centos version 5.8
/usr/local/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/resource_platform_map.rb:126:in `get'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/resource.rb:837:in `resource_for_platform'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/resource.rb:854:in `resource_for_node'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-10.14.2/lib/chef/mixin/recipe_definition_dsl_core.rb:58:in `method_missing'
/var/chef/minitest/voiceaxis/init_test.rb:70:in `block (4 levels) in <top (required)>'
diff --git a/lib/minitest-chef-handler/resources.rb b/lib/minitest-chef-handler/resources.rb
index 07fee97..cff5440 100644
package 'build-essential' {}.run_action(:install)
service "opensips" do
supports :status => true, :restart => true
action [ :enable, :start ]
end
## Post opensips start configuration
fs_list.each do |fs|
execute "trusted_fs" do
command "/usr/sbin/opensipsctl trusted add #{fs.va_public_ipaddress} any"
@leifmadsen
leifmadsen / gist:4045661
Created November 9, 2012 13:28
Error with rabbitmq cookbook stop service
# Chef doesn't seem to realize that the service is actually started, so doesn't stop it
#
[2012-11-09T13:22:29+00:00] INFO: Processing service[rabbitmq-server] action restart (rabbitmq::default line 124)
[2012-11-09T13:22:29+00:00] DEBUG: service[rabbitmq-server] you have specified a status command, running..
[2012-11-09T13:22:29+00:00] DEBUG: service[rabbitmq-server] is running
[2012-11-09T13:22:29+00:00] DEBUG: service[rabbitmq-server] runlevel 0, action stop, priority 20
[2012-11-09T13:22:29+00:00] DEBUG: service[rabbitmq-server] runlevel 1, action stop, priority 20
[2012-11-09T13:22:29+00:00] DEBUG: service[rabbitmq-server] runlevel 2, action start, priority 20
[2012-11-09T13:22:29+00:00] DEBUG: service[rabbitmq-server] runlevel 3, action start, priority 20
[2012-11-09T13:22:29+00:00] DEBUG: service[rabbitmq-server] runlevel 4, action start, priority 20
@leifmadsen
leifmadsen / gist:4348851
Created December 20, 2012 21:47
Looping through json in a template
"servers": {
"server1": {
"deet1": "foo",
"deet2": "bar",
"deet3": [ "fan", "boy" ]
},
"server2": {
"deet1": "fab",
"deet2": "ulous",
"deet3": [ "vacuum", "girl" ]
mysql_connection_info = {
:host => "localhost",
:username => 'root',
:password => node['mysql']['server_root_password']
}
template "/etc/odbc.ini" do
source "odbc.ini.erb"
owner "root"
group "root"
pbx*CLI> dialplan show testing
[ Context 'testing' created by 'pbx_config' ]
'100' => 1. NoOp() [pbx_config]
2. Set(FOO=BAR) [pbx_config]
-= 1 extension (2 priorities) in 1 context. =-
(Dir.entries("/etc/.config/var/lib/asterisk/agi-bin") - %w{ . .. }).each do |agi_file|
link "/var/lib/asterisk/agi-bin/#{agi_file}" do
to "/etc/.config/var/lib/asterisk/agi-bin/#{agi_file}"
end
end