Skip to content

Commit

Permalink
mysql-ebs plugin (not just a recipe). organized some resourced into a…
Browse files Browse the repository at this point in the history
… plugins folder.
  • Loading branch information
emiltin committed Jun 16, 2009
1 parent 26edec7 commit a8b9ae2
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 12 deletions.
11 changes: 8 additions & 3 deletions healing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Dir.glob('utilities/*.rb') { |file| require file }
Dir.glob('core/*.rb') { |file| require file }




require 'structure/base.rb'
require 'structure/resources/resource'
require 'structure/resources/file'
Expand All @@ -13,7 +16,6 @@
require 'structure/resources/execute'
require 'structure/resources/repo'
require 'structure/resources/git_repo'
require 'structure/resources/rails_app'
require 'structure/cloud'
require 'structure/instance'
require 'structure/root'
Expand All @@ -28,8 +30,11 @@
require 'app/provisioner'
require 'app/bootstrapper'

CLOUD_UUID_PATH = '/healing/cloud_uuid'

#File.dirname(__FILE__)+"/
Healing::Structure::Rubygem.load_dependencies 'gem_dependencies.yml'


Dir.glob('structure/resources/plugins/*.rb') { |file| require file }

CLOUD_UUID_PATH = '/healing/cloud_uuid'

2 changes: 1 addition & 1 deletion ideal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#rubygem 'sqlite3-ruby'
#rubygem 'mysql'

recipe 'mysql-ebs', :volume_id => 'vol-4943a020'
mysql_ebs 'vol-4943a020'

#rails_app 'poolparty_example', :repo => 'git://github.com/emiltin/poolparty_example.git', :env => :development
end
2 changes: 1 addition & 1 deletion structure/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def nearest_cloud
@parent.nearest_cloud
end

def lingo &block
def recipe &block
pa = parent_cloud
eval("#{pa.class.name}::Lingo").new(self).instance_eval &block
end
Expand Down
2 changes: 1 addition & 1 deletion structure/resources/git_repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class GitRepo < Repo
def initialize parent, path, options={}
super parent, path, options

lingo do
recipe do
package 'git-core'
end

Expand Down
50 changes: 50 additions & 0 deletions structure/resources/plugins/mysql_ebs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module Healing
module Structure
class MysqlEbs < Resource

def initialize parent, volume_id, options={}
super parent, options.merge(:volume_id=>volume_id)

recipe do
volume volume_id if volume_id

package 'mysql-client'
package 'mysql-server'

service 'mysql' => :off

execute 'kill mysqld_safe', "killall mysqld_safe"
execute 'adjust mysql binary logs', "test -f /vol/log/mysql/mysql-bin.index && perl -pi -e 's%/var/log/%/vol/log/%' /vol/log/mysql/mysql-bin.index"

file '/etc/mysql/conf.d/mysql-ec2.cnf', :mode => 644, :content => <<-EOF
[mysqld]
innodb_file_per_table
datadir = /vol/lib/mysql
log_bin = /vol/log/mysql/mysql-bin.log
max_binlog_size = 1000M
#log_slow_queries = /vol/log/mysql/mysql-slow.log
#long_query_time = 10
EOF

service 'mysql' => :on
end
end

def heal
describe_name
super
end

def describe_name
puts_title :mysql_ebs, ''
end

def describe_settings
# puts_setting :volume_id
end


end
end
end

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def initialize parent, name, options
the_repo = repo
the_env = env

lingo do
recipe do
recipe 'passenger'
git_repo "/#{the_name}", :url => the_repo, :user => 'www-data', :group => 'www-data'

Expand Down
2 changes: 1 addition & 1 deletion structure/resources/rubygem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def compile

def include_dependencies
packs = @@dependencies[name]
lingo do
recipe do
packs.each { |pack| package pack } if packs
end
end
Expand Down
9 changes: 5 additions & 4 deletions structure/volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ class Volume < Resource

def initialize parent, vol_id, options={:device => '/dev/sdh'}
super parent, options.merge(:vol_id=>vol_id)
@parent.volumes << self
lingo do
nearest_cloud.volumes << self
the_device = device
recipe do
package 'xfsprogs'
execute 'add device', 'mkfs.xfs /dev/sdh'
execute 'add volume to filetab', 'echo "/dev/sdh /vol xfs noatime 0 0" >> /etc/fstab'
execute 'add device', "mkfs.xfs #{the_device}"
execute 'add volume to filetab', "echo \"#{the_device} /vol xfs noatime 0 0\" >> /etc/fstab"
execute 'mount EBS volume', 'mkdir /vol && mount /vol'
end
end
Expand Down

0 comments on commit a8b9ae2

Please sign in to comment.