yamato 0.0.1

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.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in yamato.gemspec
4
+ gemspec
@@ -0,0 +1,18 @@
1
+ Yamato
2
+ ===============
3
+
4
+
5
+ deployment to the battle stations
6
+
7
+ to use:
8
+
9
+ add 'yamato' to Gemfile
10
+ echo "serverhostname" > yamato # add hostname of destination server
11
+
12
+ rake yamato:install_passenger
13
+
14
+ type root password, twice ( i know )
15
+ you will be also prompted for Mysql root password
16
+ Your server is ready
17
+ for now it doesnt actually deploy an app, it only prepares the server
18
+
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,96 @@
1
+ #task :default => ['yamato:install_passenger']
2
+
3
+
4
+ desc 'my plugins rake task'
5
+ task :do_something do
6
+ puts "the rake task did something"
7
+ end
8
+
9
+
10
+ raise "Cant find yamato file" unless File.exists?('yamato')
11
+
12
+
13
+ SERVER_NAME=IO.read('yamato').chomp
14
+ PROJECT_NAME=File.basename(Dir.pwd)
15
+
16
+ def ssh cmd, non_interactive = false
17
+ raise 'Not yet implemented' if non_interactive
18
+ sh "ssh #{PROJECT_NAME}@#{SERVER_NAME} '#{cmd}'"
19
+ end
20
+
21
+ def apt_get_install packages
22
+ ssh_as_root "apt-get install -y #{packages}"
23
+ end
24
+
25
+ def ssh_as_root cmd, non_interactive = false
26
+ cmd_string = "ssh root@#{SERVER_NAME} '#{cmd}'"
27
+ if non_interactive
28
+ `#{cmd_string}`
29
+ else
30
+ sh cmd_string
31
+ end
32
+ end
33
+
34
+ namespace :yamato do
35
+ desc 'Prepares Root and Project user for passwordless connection'
36
+ task :prepare_users do
37
+ ssh_as_root 'mkdir -p ~/.ssh'
38
+ sh "scp ~/.ssh/id_dsa.pub root@#{SERVER_NAME}:.ssh/authorized_keys"
39
+
40
+ #sh "cat ~/.ssh/id_dsa.pub | ssh root@#{SERVER_NAME} \"mkdir -m 0700 -p .ssh && cat - >> .ssh/authorized_keys && chmod 0622 .ssh/authorized_keys\""
41
+
42
+ if not ssh_as_root('ls /home',true).split.include?(PROJECT_NAME)
43
+ ssh_as_root "useradd -m -s /bin/bash #{PROJECT_NAME}"
44
+ end
45
+
46
+ ssh_as_root "su #{PROJECT_NAME} -c \"mkdir -p ~/.ssh\""
47
+ ssh_as_root "cp ~/.ssh/authorized_keys /home/#{PROJECT_NAME}/.ssh/"
48
+
49
+
50
+ # TODO PATCH nginx conf
51
+ # server {
52
+ # listen 80;
53
+ # server_name www.yourhost.com;
54
+ # root /somewhere/public; # <--- be sure to point to 'public'!
55
+ # passenger_enabled on;
56
+ # }
57
+ end
58
+
59
+ desc 'installes all native packages need for rails deployment'
60
+ task :debian_deps => [:prepare_users] do
61
+ ssh_as_root 'apt-get update'
62
+ apt_get_install 'git-core build-essential'
63
+ apt_get_install 'mysql-server libmysqlclient-dev libssl-dev libcurl4-openssl-dev libreadline-dev libzip-dev'
64
+ apt_get_install 'libxml2-dev libxslt-dev'
65
+ end
66
+
67
+ desc 'installs ruby 1.9.2'
68
+ task :ruby => [:debian_deps] do
69
+ if ssh_as_root('which ruby',true).chomp != '/usr/local/bin/ruby'
70
+ ssh_as_root 'wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz'
71
+ ssh_as_root 'tar xpf ruby-*'
72
+ ssh_as_root 'cd ruby-* && ./configure && make && make install'
73
+
74
+ ssh_as_root 'ruby -v'
75
+ end
76
+ end
77
+
78
+ desc 'Install bundler'
79
+ task :bundler => [:ruby] do
80
+ ssh_as_root 'gem install bundler'
81
+ end
82
+
83
+ desc 'Installs passenger'
84
+ task :passenger => [:debian_deps,:ruby,:bundler] do
85
+ if not ssh_as_root('ls /opt',true).split.include?('nginx')
86
+ ssh_as_root 'gem install passenger'
87
+ ssh_as_root 'passenger-install-nginx-module --auto --auto-download --prefix=/opt/nginx'
88
+ end
89
+ end
90
+
91
+ desc 'Rails stack, ruby,mysql,passenger'
92
+ task :rails => [:passenger] do
93
+ ssh_as_root 'gem install rails'
94
+ end
95
+
96
+ end
@@ -0,0 +1,11 @@
1
+ require "yamato/version"
2
+
3
+ require 'rails'
4
+
5
+ module Yamato
6
+ class Railtie < Rails::Railtie
7
+ rake_tasks do
8
+ Dir[File.join(File.dirname(__FILE__),'tasks/*.rake')].each { |f| load f }
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Yamato
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "yamato/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "yamato"
7
+ s.version = Yamato::VERSION
8
+ s.authors = ["Kirill Radzikhovskyy"]
9
+ s.email = ["kirillrdy@silverpond.com.au"]
10
+ s.homepage = ""
11
+ s.summary = %q{To battle stations!}
12
+ s.description = %q{List of useful rake tasks for rails projects}
13
+
14
+ s.rubyforge_project = "yamato"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yamato
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kirill Radzikhovskyy
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-08-01 00:00:00.000000000 +10:00
13
+ default_executable:
14
+ dependencies: []
15
+ description: List of useful rake tasks for rails projects
16
+ email:
17
+ - kirillrdy@silverpond.com.au
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - README.md
25
+ - Rakefile
26
+ - lib/tasks/yamato.rake
27
+ - lib/yamato.rb
28
+ - lib/yamato/version.rb
29
+ - yamato.gemspec
30
+ has_rdoc: true
31
+ homepage: ''
32
+ licenses: []
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project: yamato
51
+ rubygems_version: 1.6.2
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: To battle stations!
55
+ test_files: []