VladTheEnterprising 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of VladTheEnterprising might be problematic. Click here for more details.

@@ -0,0 +1,39 @@
1
+ require 'vlad'
2
+ require 'vlad/translator'
3
+ require 'vlad/environmentalist'
4
+ require 'vlad/xen_master'
5
+ require 'vlad/dba/mysql'
6
+ require 'vlad/webmaster/apache'
7
+ VLAD_ENTERPRISING_VERSION = '0.1.4' unless defined? VLAD_ENTERPRISING_VERSION
8
+
9
+
10
+ # rsync the given files to <tt>target_host</tt>.
11
+ def scp local, remote
12
+ Thread.current[:task].scp local, remote
13
+ end
14
+
15
+ class Rake::RemoteTask
16
+
17
+ ##
18
+ # Use scp to send +local+ to +remote+ on target_host.
19
+
20
+ def scp local, remote
21
+ cmd = ["scp", "-rp", local, "#{@target_host}:#{remote}"].flatten.compact
22
+ puts cmd.join(' ')
23
+ success = system(*cmd)
24
+ unless success then
25
+ raise Vlad::CommandFailedError, "execution failed: #{cmd.join ' '}"
26
+ end
27
+ end
28
+
29
+ end
30
+ namespace :vlad do
31
+ namespace :enterprising do
32
+ desc "setup vlad the enterprising dependencies in the current project"
33
+ task :setup do
34
+ unless File.exists? "files"
35
+ FileUtils.cp_r(File.dirname(__FILE__) + "/../../files", "files")
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,32 @@
1
+ require 'fileutils'
2
+ target ||= ENV['TARGET'] ||= ENV['RAILS_ENV'] ||= "testing"
3
+ namespace :vlad do
4
+ namespace :environmentalist do
5
+ task :setup do
6
+ unless File.exists? "files"
7
+ FileUtils.cp_r(File.dirname(__FILE__) + "../files", "files")
8
+ end
9
+ end
10
+ end
11
+ end
12
+
13
+ if target
14
+ if target.to_s.match(/([a-z0-9_-]+):([a-z0-9_-]+)/i)
15
+ f = File.join( 'config', 'environments', "#{$1}.rb")
16
+ set(:target_environment, "#{$1}".to_sym)
17
+ Kernel.load f if File.exists? f
18
+ f = File.join('config', 'environments', "#{$1}", "#{$2}.rb")
19
+ set(:target_subset, "#{$2}".to_sym)
20
+ Kernel.load f if File.exists? f
21
+ elsif target.to_s.match(/([a-z0-9_-]+)/i)
22
+ f = File.join('config', 'environments', "#{$1}.rb")
23
+ set(:target_environment, $1.to_sym)
24
+ Kernel.load f if File.exists? f
25
+ all_files = Dir.glob( File.join( "config", "environments", $1, "*.rb") )
26
+ all_files.each do |f|
27
+ Kernel.load f
28
+ end
29
+ end
30
+ end
31
+
32
+
@@ -0,0 +1,138 @@
1
+
2
+ def host_env *args, &b
3
+ Thread.current[:task].host_env
4
+ end
5
+
6
+ def dialect(arg)
7
+ Rake::RemoteTask.dialect(arg)
8
+ end
9
+
10
+ class Rake::RemoteTask
11
+ @@host_dialects ||= {}
12
+ def host_env
13
+ self.class.host_env
14
+ end
15
+
16
+ def self.dialect(arg={ :set => {}})
17
+ @@env["host_dialects"] ||= []
18
+ @@env["host_dialects"] << arg
19
+ arg[:set].keys.each do |var|
20
+ unless self.respond_to? var
21
+ Object.send :define_method, var do
22
+ Rake::RemoteTask.fetch var
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ def self.host_env
29
+ return {} unless Thread.current[:task]
30
+ h = Thread.current[:task].target_host
31
+ return {} unless h
32
+ unless @@host_dialects[h]
33
+ _cenv = {}
34
+ @@env["host_dialects"].each do |env|
35
+ begin
36
+ env[:assert].call if env[:assert] && env[:assert].respond_to?(:call)
37
+ _cenv.merge!(env[:set])
38
+ rescue
39
+ end
40
+ end
41
+ @@host_dialects[h] = _cenv
42
+ end
43
+ @@host_dialects[h]
44
+ end
45
+
46
+ ##
47
+ # Fetches environment variable +name+ from the environment using
48
+ # default +default+.
49
+
50
+ def self.fetch name, default = nil
51
+ name = name.to_s if Symbol === name
52
+
53
+ if @@env.has_key? name then
54
+ protect_env(name) do
55
+ v = @@env[name]
56
+ v = @@env[name] = v.call if Proc === v
57
+ v
58
+ end
59
+ elsif host_env.has_key? name.to_sym
60
+ v = host_env[name.to_sym]
61
+ if Proc === v
62
+ v.call
63
+ else
64
+ v
65
+ end
66
+ elsif default
67
+ v = @@env[name] = default
68
+ else
69
+ raise "can't fetch '#{name}'"
70
+ raise Vlad::FetchError
71
+ end
72
+ end
73
+ end
74
+
75
+ set(:dialects, []) unless defined? dialects
76
+ set(:examined_hosts, {}) unless defined? examined_hosts
77
+ #these will be run in order, with the later
78
+ #proceed from the more
79
+ #general to more specific per host settings
80
+ #raise exception for assertion if values should not be set
81
+ dialect(:name => :unknown,
82
+ :assert => lambda { true },
83
+ :set => {
84
+ :os => :unknown,
85
+ :php_enabled => :false,
86
+ })
87
+
88
+ dialect(:name => :linux,
89
+ :assert => lambda { run "uname -a | grep '^Linux' && exit 0" },
90
+ :set => {
91
+ :os => :linux
92
+ })
93
+
94
+ dialect(:name => :free_bsd,
95
+ :assert => lambda { run "uname -a | grep '^FreeBSD' && exit 0" },
96
+ :set => {
97
+ :os => :free_bsd
98
+ })
99
+
100
+ dialect(:name => :solaris,
101
+ :assert => lambda { run "uname -a | grep '^SunOS' && exit 0" },
102
+ :set => {
103
+ :os => :solaris,
104
+ :make => "/usr/ccs/bin/make"
105
+ })
106
+
107
+ dialect(:name => :solaris_coolstack_amp,
108
+ :assert => lambda { run "pkginfo CSKamp 2> /dev/null" },
109
+ :set => {
110
+ :php_enabled => true,
111
+ :php_ini => "/opt/coolstack/php5/lib/php.ini",
112
+ :apache_conf => "/opt/coolstack/apache2/conf/httpd.conf",
113
+ :apache_start => lambda { run "sudo /opt/coolstack/apache2/bin/apachectl start" },
114
+ :apache_stop => lambda { run "sudo /opt/coolstack/apache2/bin/apachectl stop" },
115
+ })
116
+
117
+
118
+
119
+
120
+
121
+ namespace :vlad do
122
+ namespace :dialect do
123
+ desc "Show host inspection results"
124
+ remote_task :conclusions do
125
+ puts "#{target_host}"
126
+ puts "==========="
127
+ output = { }
128
+ host_env.keys.each do |key|
129
+ begin
130
+ output[key] = Rake::RemoteTask.fetch(key);
131
+ rescue Exception => e
132
+ output[key] = "ERR: #{e}"
133
+ end
134
+ end
135
+ puts YAML::dump(output)
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,95 @@
1
+ require 'vlad/translator'
2
+ dialect( :name => :xen_default_image,
3
+ :assert => lambda { true },
4
+ :set => {
5
+ :xen_config_sxp_src => "files/xen_master/xend-config.sxp",
6
+ :xen_config_sxp_dest => lambda{ "#{version}/xend-config.sxp" },
7
+ :xen_config_sxp => "/etc/xen/xend-config.sxp",
8
+ :xen_tools_conf_src => "files/xen_master/xen-tools-edgy.conf",
9
+ :xen_tools_conf_dest => lambda {"#{version}/xen-tools.conf" },
10
+ :xen_role_d_src => "files/xen_master/role.d/",
11
+ :xen_role_d_dest => lambda{ "#{version}/role.d" },
12
+ :xen_role_d => "/etc/xen-tools/role.d",
13
+ :xen_tools_conf => "/etc/xen-tools/xen-tools.conf",
14
+ :xen_create_image => "xen-create-image --role=default-edgy",
15
+ :xm => "xm" } )
16
+
17
+ dialect( :name => :xen_centos5_image ,
18
+ :assert => lambda { xen_use_centos5; set(:xen_use_centos, true ); },
19
+ :set => {
20
+ :xen_tools_conf_src => "files/xen_master/xen-tools-centos5.conf",
21
+ :xen_centos_img_src => "http://jailtime.org/lib/exe/fetch.php?cache=cache&media=download%3Acentos%3Acentos.5-0.20070424.img.tar.bz2",
22
+ :xen_centos_img_dest => "/xen-images/centos5/centos.5-0.img.tar.bz2",
23
+ :xen_centos_img => "/xen-images/centos5/centos.5-0.img",
24
+ :xen_centos_img_dir => "/xen-images/centos5"
25
+ })
26
+
27
+ dialect( :name => :xen_centos4_image ,
28
+ :assert => lambda { xen_use_centos4; set(:xen_use_centos, true); },
29
+ :set => {
30
+ :xen_tools_conf_src => "files/xen_master/xen-tools-centos4.conf",
31
+ :xen_centos_img_src => "http://jailtime.org/lib/exe/fetch.php?cache=cache&media=download%3Acentos%3Acentos.4-4.20061223.img.tar.bz2",
32
+ :xen_centos_img_dest => "/xen-images/centos4.4/centos.4-4.img.tar.bz2",
33
+ :xen_centos_img => "/xen-images/centos4.4/centos.4-4.img",
34
+ :xen_centos_img_dir => "/xen-images/centos4.4"
35
+ })
36
+
37
+ dialect( :name => :xen_mysql_image,
38
+ :assert => lambda { roles().include?(:mysql_server) },
39
+ :set => {
40
+ :xen_create_image => "xen-create-image --role=mysql-server-edgy" })
41
+
42
+
43
+ namespace :vlad do
44
+ namespace :xen do
45
+
46
+ desc "creates, configures, and starts all hosts with role :xen_candidate defined"
47
+ task :bootstrap_candidates => [:copy_configs, :create_images, :configure_images]
48
+
49
+ remote_task :copy_configs, :roles => :xen_builder do
50
+ run "if [ ! -d #{ver} ]; then mkdir #{ver}; fi"
51
+ rsync xen_tools_conf_src, xen_tools_conf_dest
52
+ rsync xen_config_sxp_src, xen_config_sxp_dest
53
+ rsync xen_role_d_src, xen_role_d_dest
54
+ run "rm -rf #{xen_role_d_dest}/CVS; exit 0"
55
+ run "sudo cp #{xen_role_d_dest}/* #{xen_role_d}"
56
+ run "sudo cp #{xen_tools_conf_dest} #{xen_tools_conf}"
57
+ run "sudo cp #{xen_config_sxp_dest} #{xen_config_sxp}"
58
+ end
59
+
60
+ remote_task :create_images, :roles => :xen_builder do
61
+ if defined? xen_use_centos && xen_use_centos
62
+ run "if [ ! -d #{xen_centos_img_dir} ]; then sudo mkdir -p #{xen_centos_img_dir}; fi;"
63
+ run "if [ ! -e #{xen_centos_img_dest} ]; then sudo wget '#{xen_centos_img_src}' -O #{xen_centos_img_dest}; fi"
64
+ run "if [ ! -e #{xen_centos_img} ]; then cat #{xen_centos_img_dest} | bunzip2 - | sudo /bin/bash -c '(cd #{xen_centos_img_dir}; tar xvf - )'; fi"
65
+ Rake::RemoteTask.hosts_for(:xen_image).each do |candidate|
66
+ run "sudo #{xm} destroy #{candidate}; exit 0"
67
+ run "sudo mkdir -p /xen-images/domains/#{candidate}"
68
+ run "sudo rsync #{xen_centos_img} /xen-images/domains/#{candidate}/disk.img"
69
+ run "sudo rsync #{xen_centos_img_dir}/centos.swap /xen-images/domains/#{candidate}/swap.img"
70
+ run "echo 'kernel = \"/boot/vmlinuz-2.6.19-4-server\"' | sudo /bin/bash -c 'cat > /etc/xen/#{candidate}.cfg'"
71
+ run "echo 'ramdisk = \"/boot/initrd.img-2.6.19-4-server\"' | sudo /bin/bash -c 'cat >> /etc/xen/#{candidate}.cfg'"
72
+ run "echo 'name = \"#{candidate}\"' | sudo /bin/bash -c 'cat >> /etc/xen/#{candidate}.cfg'"
73
+ run "echo 'memory = \"128\"' | sudo /bin/bash -c 'cat >> /etc/xen/#{candidate}.cfg'"
74
+ run "echo 'vif = [ \"\" ]' | sudo /bin/bash -c 'cat >> /etc/xen/#{candidate}.cfg'"
75
+ run "echo 'dhcp = \"dhcp\"' | sudo /bin/bash -c 'cat >> /etc/xen/#{candidate}.cfg'"
76
+ run "echo 'root = \"/dev/sda1 ro\"' | sudo /bin/bash -c 'cat >> /etc/xen/#{candidate}.cfg'"
77
+ run "echo 'disk = [ \"file:/xen-images/domains/#{candidate}/disk.img,sda1,w\", \"file:/xen-images/domains/#{candidate}/swap.img,sda2,w\" ]' | sudo /bin/bash -c 'cat >> /etc/xen/#{candidate}.cfg'"
78
+ run "sudo #{xm} create /etc/xen/#{candidate}.cfg"
79
+ end
80
+ else
81
+ Rake::RemoteTask.hosts_for(:xen_image).each do |candidate|
82
+ run "sudo #{xen_create_image} --hostname=#{candidate}"
83
+ run "sudo #{xm} create -c /etc/xen/#{candidate}.cfg"
84
+ end
85
+ end
86
+ end
87
+
88
+ remote_task :configure_images, :roles => :xen_candidate do
89
+ if defined? ssh_copy_id
90
+ `#{ssh_copy_id} #{target_host}`
91
+ end
92
+ end
93
+
94
+ end
95
+ end
File without changes
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: VladTheEnterprising
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.4
7
+ date: 2007-10-17 00:00:00 -04:00
8
+ summary: Adds 'enterprisey' features to Vlad The Deployer
9
+ require_paths:
10
+ - lib
11
+ email: michael.welles@nytimes.com
12
+ homepage: " by Michael L. Welles"
13
+ rubyforge_project: vlad_the_enterprising
14
+ description: "Currently consists of the following: * Vlad the Translator * Vlad the Environmentalist * Vlad the DBA * Vlad the Xen Master == FEATURES/PROBLEMS: * Management of heterogenious enironments, dynamic discovery and flexible handling of remote host types. * Support of multiple environments and subenvironments, multiple projects withing an environemnt * Automation of common, time consuming, dba tasks, like installing, syncronizing and bringing up new mysql slave instances."
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ - |
29
+ -----BEGIN CERTIFICATE-----
30
+ MIIDQjCCAiqgAwIBAgIBADANBgkqhkiG9w0BAQUFADBHMRcwFQYDVQQDDA5taWNo
31
+ YWVsLndlbGxlczEXMBUGCgmSJomT8ixkARkWB255dGltZXMxEzARBgoJkiaJk/Is
32
+ ZAEZFgNjb20wHhcNMDcxMDE1MjEzODU1WhcNMDgxMDE0MjEzODU1WjBHMRcwFQYD
33
+ VQQDDA5taWNoYWVsLndlbGxlczEXMBUGCgmSJomT8ixkARkWB255dGltZXMxEzAR
34
+ BgoJkiaJk/IsZAEZFgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
35
+ AQDVtkXn/lO4i371ddkOxrOQAG0170ACJZQpmrMXoDyjVIyzUvTgCnI345CffdjV
36
+ 7vZGNjdYXK/X+37rOpjI4OJbDAzKj4zzyS3FX3mudRralbsDuWMw9RhQmrLWEKxV
37
+ tsIEBOJvhDrsXhDJbJvXUnaRCXSzqM79ME9gxDMpEVxNkxg+SUcmv3tOM8r89dHq
38
+ SuO9m6fcOI1L7FvDtjU32LeTo4F5u/hsbT23LwEw3GCkKnW/j4E4W5YKv4Z08DAd
39
+ 25bRSamFMFbhduozPIBEvKCFJik6Gya+cgO2S4bP8UqFvO0TRO3u6zu9f6m2FsO9
40
+ 8lvj7m+goTw3EvS6ykhOr9GnAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQD
41
+ AgSwMB0GA1UdDgQWBBTwMfaJ1/nqohLepLBl4zPldVxnFzANBgkqhkiG9w0BAQUF
42
+ AAOCAQEAvo7FqF5e9Hollx1J6r5t5opLNlpU7k694a2aaMf7NVCOUKwd5M4vfA0j
43
+ A2iMi+TW5PB4oQFE5/9NjrPpTSdO7KuCwCmUVxeZkaGAt6kZ8YH1Yo9DLS8Iq+Bf
44
+ DGD+BcCLq2adl016AWR7WK/S1sXtDNX0E8705zxJ6fpCQbmtu/WhekInqimy6w5r
45
+ JLjGrTzRMQwkIyWbgcFymqa77Zfywr5Hoj5H9P3Vj/VJqIpNK/qXjn0x0Nj+EPbx
46
+ WiJ17Z0V4OTr+GftgdtrYPzQz3dH82q6imCkHKb8J3k7XpQoQQK3ydoQJRhnLASz
47
+ PwjwANkbPAZ/02Nuh4ivSQn/b0KeDg==
48
+ -----END CERTIFICATE-----
49
+
50
+ post_install_message:
51
+ authors:
52
+ - Michael L. Welles
53
+ files:
54
+ - History.txt
55
+ - Manifest.txt
56
+ - README.txt
57
+ - Rakefile
58
+ - lib/vlad/enterprising.rb
59
+ - lib/vlad/translator.rb
60
+ - lib/vlad/environmentalist.rb
61
+ - lib/vlad/dba/mysql.rb
62
+ - lib/vlad/xen_master.rb
63
+ - files
64
+ - files/mysql
65
+ - files/mysql/configs
66
+ - files/mysql/templates
67
+ - files/mysql/templates/db_slave.cnf.tmpl
68
+ - files/xen_master
69
+ - files/xen_master/xend-config.sxp
70
+ - files/xen_master/xen-tools-centos4.conf
71
+ - files/xen_master/xen-tools-edgy.conf
72
+ - files/xen_master/role.d
73
+ - files/xen_master/role.d/mysql-server-centos5
74
+ - files/xen_master/role.d/default-edgy
75
+ - files/xen_master/role.d/centos5-default
76
+ - files/xen_master/role.d/mysql-server-edgy
77
+ - files/xen_master/centos4.1
78
+ - files/xen_master/xen-tools-centos5.conf
79
+ test_files:
80
+ - test/test_vlad_the_enterprising.rb
81
+ rdoc_options:
82
+ - --main
83
+ - README.txt
84
+ extra_rdoc_files:
85
+ - History.txt
86
+ - Manifest.txt
87
+ - README.txt
88
+ executables: []
89
+
90
+ extensions: []
91
+
92
+ requirements: []
93
+
94
+ dependencies:
95
+ - !ruby/object:Gem::Dependency
96
+ name: highline
97
+ version_requirement:
98
+ version_requirements: !ruby/object:Gem::Version::Requirement
99
+ requirements:
100
+ - - ">"
101
+ - !ruby/object:Gem::Version
102
+ version: 0.0.0
103
+ version:
104
+ - !ruby/object:Gem::Dependency
105
+ name: vlad
106
+ version_requirement:
107
+ version_requirements: !ruby/object:Gem::Version::Requirement
108
+ requirements:
109
+ - - ">"
110
+ - !ruby/object:Gem::Version
111
+ version: 1.0.0
112
+ version:
113
+ - !ruby/object:Gem::Dependency
114
+ name: hoe
115
+ version_requirement:
116
+ version_requirements: !ruby/object:Gem::Version::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 1.3.0
121
+ version:
metadata.gz.sig ADDED
@@ -0,0 +1,3 @@
1
+ n��B�)��R�_���UPo�=T�ü�RU)��*�<D:��ڃl�#�:ex��K�C֐[
2
+ 0e��d�5��@�'�{\��o}�F~��������_��~>��Ĕ]��lj�+g�2ڳ?�4A�X�D��K�͓�;{3����J�4+d��m u�V�u�*ىt��^�|�v��42���D􊮀R>�O�m��{�R�
3
+ [�e=�nZaN��"�B�Y�>��e�>FL���!��y��M��}0}�I��~�.�d