Skip to content

Instantly share code, notes, and snippets.

View cyberswat's full-sized avatar

Kevin Bridges cyberswat

View GitHub Profile
use_inline_resources if defined?(use_inline_resources)
def whyrun_supported?
true
end
action :create do
template new_resource.name do
group new_resource.group
mode new_resource.mode
require 'fileutils'
require 'tempfile'
action :ensure do
t_file = Tempfile.new('/root/.profile_temp')
::File.open(new_resource.profile, 'r') do |f|
f.each_line do |line|
if line.match(/PATH=/)
if ::File.readlines(new_resource.profile).grep(/:#{new_resource.path.gsub('/','\/')}/).length > 0
t_file.puts line
{
"mysql": {
"tunable": {
"innodb_log_file_size": "8M",
"key_buffer_size": "128M"
}
},
"drupal": {
"sites": {
"drupal": {
execute "drush-site-install" do
drupal_user = data_bag_item('users', 'drupal')[node.chef_environment]
install = site[:install]
if site[:database].nil?
cmd = "drush -y site-install #{site[:profile]}"
install.each do |flag, value|
cmd << " #{flag}=#{value}"
end
cmd << " --db-url=mysql://#{drupal_user['dbuser']}:#{drupal_user['dbpass']}@localhost/#{site_name}" if install['db-url'].nil?
cmd << " --account-name=#{drupal_user['admin_user']}" if install['account-name'].nil?
@cyberswat
cyberswat / gist:5678391
Created May 30, 2013 14:43
A sample LWRP per #drupal-colorado conversation
require 'fileutils'
require 'tempfile'
action :ensure do
t_file = Tempfile.new('/root/.profile_temp')
::File.open(new_resource.profile, 'r') do |f|
f.each_line do |line|
if line.match(/PATH=/)
if ::File.readlines(new_resource.profile).grep(/:#{new_resource.path.gsub('/','\/')}/).length > 0
t_file.puts line
files_sorted_by_time = Dir["#{node[:drupal][:server][:base]}/#{site_name}/releases/*"].sort_by{ |f| File.mtime(f) }
previous_release = files_sorted_by_time.length > 1 ? files_sorted_by_time[1] : files_sorted_by_time[0]
command <<-EOF
cp #{files_sorted_by_time[file_index]}/#{site[:settings]} #{release_path}/#{site[:settings]}
EOF
only_if { ::File.exists?("#{files_sorted_by_time[-2]}/#{site[:settings]}") }
def clean_releases(vars)
directories = []
Dir.entries(vars[:directory]).each do |f|
directories.push f if (f=~/^#{vars[:app_name]}-[0-9]+/)
end
directories.sort.reverse.drop(vars[:quantity]).each do |i|
system "rm -rf #{vars[:directory]}/#{i}"
end
end
Drupal is a vivid and exciting community, creating and maintaining an ecosystem
of talent in many different areas of knowledge. When it comes to discussing and
embracing the future of Drupal, developers are the front line, making sure we
are capable of meeting our clients needs while delivering performant applications
more efficiently and securely.
The Coding and Development track for Drupalcon Sao Paoulo is dedicated to
the new options, capabilities and direction that will shape the future of Drupal.
We will offer many must-see sessions with a focus on the RESTful future of
Drupal and harnessing the power of the Symfony framework. We will introduce you
# dirty ruby syslog
def log(msg)
Syslog.open($0, Syslog::LOG_PID | Syslog::LOG_CONS) { |s| s.warning "#{msg}" }
end
@cyberswat
cyberswat / jenkins-auto-git.sh
Created February 28, 2012 16:41
Jenkins job to manage jenkins configs
# Move into the jenkins directory
cd /var/lib/jenkins
#Add all top level xml files.
git add *.xml
# Add all job config.xml files.
git add jobs/*/config.xml
# Add all user config.xml files.