conjure 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.md +4 -0
- data/License.txt +21 -0
- data/README.md +5 -0
- data/bin/conjure +5 -0
- data/lib/conjure/command.rb +10 -0
- data/lib/conjure/service/machine_instance.rb +54 -0
- data/lib/conjure/service/rails_application.rb +17 -0
- data/lib/conjure/service/rails_server.rb +36 -0
- data/lib/conjure/service/rvm_shell.rb +30 -0
- data/lib/conjure/service/source_tree.rb +25 -0
- data/lib/conjure/service.rb +31 -0
- data/lib/conjure.rb +7 -0
- metadata +91 -0
data/History.md
ADDED
data/License.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Brian Auton
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
data/bin/conjure
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module Conjure
|
4
|
+
module Service
|
5
|
+
class MachineInstance < Basic
|
6
|
+
def start
|
7
|
+
@config_path = File.expand_path "../../../../config", __FILE__
|
8
|
+
load_environment
|
9
|
+
install_base_image
|
10
|
+
@vm = @vagrant.primary_vm
|
11
|
+
start_vm
|
12
|
+
issue_test_command
|
13
|
+
end
|
14
|
+
|
15
|
+
def load_environment
|
16
|
+
@vagrant = Vagrant::Environment.new :cwd => @config_path
|
17
|
+
end
|
18
|
+
|
19
|
+
def install_base_image
|
20
|
+
unless @vagrant.boxes.find "precise64"
|
21
|
+
puts "Downloading 300MB Ubuntu base image for Vagrant, this may take a few minutes..."
|
22
|
+
@vagrant.boxes.add "precise64", "http://files.vagrantup.com/precise64.box"
|
23
|
+
load_environment
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def start_vm
|
28
|
+
unless @vm.state == :running
|
29
|
+
puts "Starting a VM..."
|
30
|
+
@vm.up
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def ssh_address
|
35
|
+
info = @vm.ssh.info
|
36
|
+
"#{info[:username]}@#{info[:host]}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def ssh_options
|
40
|
+
info = @vm.ssh.info
|
41
|
+
"-p #{info[:port]} -i #{info[:private_key_path]}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def remote_command_output(command)
|
45
|
+
command.gsub! "'", "'\\\\''"
|
46
|
+
`ssh #{ssh_address} #{ssh_options} '#{command}'`
|
47
|
+
end
|
48
|
+
|
49
|
+
def issue_test_command
|
50
|
+
puts "OS info reported by the VM: #{remote_command_output 'uname -mrs'}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Conjure
|
2
|
+
module Service
|
3
|
+
class RailsApplication < Basic
|
4
|
+
def initialize(source_path)
|
5
|
+
source_path = source_path
|
6
|
+
@instance = Service::MachineInstance.new
|
7
|
+
@source_tree = Service::SourceTree.new source_path, @instance
|
8
|
+
@server = Service::RailsServer.new @source_tree, @instance
|
9
|
+
end
|
10
|
+
|
11
|
+
def dependencies
|
12
|
+
[@instance, @source_tree, @server]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Conjure
|
2
|
+
module Service
|
3
|
+
class RailsServer < Basic
|
4
|
+
def initialize(source_tree, instance)
|
5
|
+
@working_dir = "codebase"
|
6
|
+
@instance = instance
|
7
|
+
@source_tree = source_tree
|
8
|
+
@rvm_shell = Service::RvmShell.new instance, "1.9.3", "codebase"
|
9
|
+
end
|
10
|
+
|
11
|
+
def dependencies
|
12
|
+
[@instance, @source_tree, @rvm_shell]
|
13
|
+
end
|
14
|
+
|
15
|
+
def started?
|
16
|
+
shell("bundle check").include? "dependencies are satisfied"
|
17
|
+
end
|
18
|
+
|
19
|
+
def start
|
20
|
+
puts "Installing gems..."
|
21
|
+
execute "cd codebase; bundle"
|
22
|
+
puts "Starting rails server..."
|
23
|
+
if execute("rails server -d").include? "application starting"
|
24
|
+
puts "The app is running at http://localhost:4000/"
|
25
|
+
else
|
26
|
+
puts "The rails server failed to start."
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def execute(command)
|
31
|
+
command = "cd #{@working_dir}; #{command}" if @working_dir
|
32
|
+
@rvm_shell.execute command
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Conjure
|
2
|
+
module Service
|
3
|
+
class RvmShell < Basic
|
4
|
+
def initialize(machine_instance, ruby_version, gemset)
|
5
|
+
@instance = machine_instance
|
6
|
+
@ruby_version = ruby_version
|
7
|
+
@gemset = gemset
|
8
|
+
end
|
9
|
+
|
10
|
+
def dependences
|
11
|
+
[@instance]
|
12
|
+
end
|
13
|
+
|
14
|
+
def start
|
15
|
+
shell "sudo apt-get -y install curl libyaml-dev build-essential libsqlite3-dev nodejs"
|
16
|
+
shell "curl -L https://get.rvm.io | bash -s -- --ignore-dotfiles"
|
17
|
+
shell "echo \"source $HOME/.rvm/scripts/rvm\" >> ~/.bash_profile"
|
18
|
+
shell "source $HOME/.rvm/scripts/rvm"
|
19
|
+
shell "rvm install #{@ruby_version}"
|
20
|
+
shell "rvm use #{@ruby_version}@#{@gemset} --create --default"
|
21
|
+
end
|
22
|
+
|
23
|
+
def execute(command)
|
24
|
+
command.gsub! "'", "'\\\\''"
|
25
|
+
command = "bash --login -c '#{command}' 2>&1"
|
26
|
+
@instance.remote_command_output command
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Conjure
|
2
|
+
module Service
|
3
|
+
class SourceTree < Basic
|
4
|
+
def initialize(source_path, machine_instance)
|
5
|
+
@source_path = source_path
|
6
|
+
@instance = machine_instance
|
7
|
+
end
|
8
|
+
|
9
|
+
def copy_to(instance, dest_path)
|
10
|
+
options = "-a -e \"ssh #{instance.ssh_options}\""
|
11
|
+
source = "#{@source_path}/"
|
12
|
+
dest = "#{instance.ssh_address}:#{dest_path}"
|
13
|
+
system "rsync #{options} #{source} #{dest}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def start(dest_path="codebase")
|
17
|
+
puts "Transferring source code..."
|
18
|
+
copy_to @instance, dest_path
|
19
|
+
size = "#{@instance.remote_command_output "du -hs #{dest_path}"}"
|
20
|
+
size = size.split(/\s/).first
|
21
|
+
puts "Installed codebase size is #{size}."
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Conjure
|
2
|
+
module Service
|
3
|
+
autoload :RailsApplication, "conjure/service/rails_application"
|
4
|
+
autoload :RailsServer, "conjure/service/rails_server"
|
5
|
+
autoload :RvmShell, "conjure/service/rvm_shell"
|
6
|
+
autoload :MachineInstance, "conjure/service/machine_instance"
|
7
|
+
autoload :SourceTree, "conjure/service/source_tree"
|
8
|
+
end
|
9
|
+
|
10
|
+
class Basic
|
11
|
+
def dependencies
|
12
|
+
[]
|
13
|
+
end
|
14
|
+
|
15
|
+
def started?
|
16
|
+
false
|
17
|
+
end
|
18
|
+
|
19
|
+
def start
|
20
|
+
end
|
21
|
+
|
22
|
+
def save
|
23
|
+
dependencies.each &:start
|
24
|
+
start unless started?
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.create(*args)
|
28
|
+
new(*args).save
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/conjure.rb
ADDED
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: conjure
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Brian Auton
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-10-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: thor
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: vagrant
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description:
|
47
|
+
email:
|
48
|
+
- brianauton@gmail.com
|
49
|
+
executables:
|
50
|
+
- conjure
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- lib/conjure.rb
|
55
|
+
- lib/conjure/service/rails_server.rb
|
56
|
+
- lib/conjure/service/rails_application.rb
|
57
|
+
- lib/conjure/service/machine_instance.rb
|
58
|
+
- lib/conjure/service/source_tree.rb
|
59
|
+
- lib/conjure/service/rvm_shell.rb
|
60
|
+
- lib/conjure/service.rb
|
61
|
+
- lib/conjure/command.rb
|
62
|
+
- README.md
|
63
|
+
- History.md
|
64
|
+
- License.txt
|
65
|
+
- bin/conjure
|
66
|
+
homepage: http://github.com/brianauton/conjure
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 1.3.6
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 1.8.25
|
88
|
+
signing_key:
|
89
|
+
specification_version: 3
|
90
|
+
summary: Magically powerful deployment for Rails applications
|
91
|
+
test_files: []
|