sunzi 1.0.0 → 1.1.0
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -2
- data/README.md +3 -2
- data/Rakefile +5 -7
- data/lib/sunzi/cli.rb +0 -1
- data/lib/sunzi/cloud/digital_ocean.rb +14 -0
- data/lib/sunzi/dependency.rb +1 -1
- data/lib/templates/create/install.sh +6 -6
- data/lib/templates/create/recipes/sunzi.sh +8 -5
- data/lib/templates/create/roles/db.sh +3 -3
- data/lib/templates/create/roles/web.sh +2 -2
- data/lib/templates/setup/digital_ocean/digital_ocean.yml +4 -2
- data/sunzi.gemspec +1 -1
- metadata +3 -5
- data/lib/templates/create/roles/app.sh +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a3f735ba4adee8e29059770569406897d42e9a7
|
4
|
+
data.tar.gz: 3ec26e19e5ca10213f79726d0963e29b03672dc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 361584e1a3104439e3c1e4ab735ce920b32fdbb052af1815d47f3c5c88c7ffb801cb2b007c7cd5edb53897848aec88dd67239921a1edac9d585d61119c0b49cc
|
7
|
+
data.tar.gz: 564fa3ae5ac3f99ce117c79251a5249307f7e81a79dabbb5c49b973c3f3e1e9fdba766ae124377166600e8d000c9d435e6e5a946f420266cbea7475cf580a57d
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -18,6 +18,8 @@ Its design goals are:
|
|
18
18
|
|
19
19
|
### What's new:
|
20
20
|
|
21
|
+
* v1.1: "set -e" by default. apt-get everywhere in place of aptitude. Linode DNS support for DigitalOcean instances.
|
22
|
+
* v1.0: System functions are refactored into sunzi.mute() and sunzi.install().
|
21
23
|
* v0.9: Support for [DigitalOcean](https://www.digitalocean.com) setup / teardown.
|
22
24
|
* v0.8: Added `--sudo` option to `sunzi deploy`.
|
23
25
|
* v0.7: Added `erase_remote_folder` and `cache_remote_recipes` preferences for customized behavior.
|
@@ -85,8 +87,7 @@ sunzi/
|
|
85
87
|
recipes/ # put commonly used scripts here, referred from install.sh
|
86
88
|
sunzi.sh
|
87
89
|
roles/ # when role is specified, scripts here will be concatenated
|
88
|
-
|
89
|
-
db.sh
|
90
|
+
db.sh # to install.sh in the compile phase
|
90
91
|
web.sh
|
91
92
|
compiled/ # everything under this folder will be transferred to the
|
92
93
|
# remote server (do not edit directly)
|
data/Rakefile
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
2
|
require 'rake/testtask'
|
3
3
|
|
4
|
-
|
5
4
|
Rake::TestTask.new do |t|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
t.libs << 'test'
|
6
|
+
t.test_files = FileList['test/test*.rb']
|
7
|
+
t.verbose = true
|
8
|
+
end
|
11
9
|
task :default => :test
|
data/lib/sunzi/cli.rb
CHANGED
@@ -47,7 +47,6 @@ module Sunzi
|
|
47
47
|
template 'templates/create/sunzi.yml', "#{project}/sunzi.yml"
|
48
48
|
template 'templates/create/install.sh', "#{project}/install.sh"
|
49
49
|
template 'templates/create/recipes/sunzi.sh', "#{project}/recipes/sunzi.sh"
|
50
|
-
template 'templates/create/roles/app.sh', "#{project}/roles/app.sh"
|
51
50
|
template 'templates/create/roles/db.sh', "#{project}/roles/db.sh"
|
52
51
|
template 'templates/create/roles/web.sh', "#{project}/roles/web.sh"
|
53
52
|
end
|
@@ -80,6 +80,13 @@ module Sunzi
|
|
80
80
|
# Set the public IP to AWS Route 53
|
81
81
|
say "Setting the public IP to AWS Route 53..."
|
82
82
|
Route53::DNSRecord.new(@fqdn, "A", "300", [@public_ip], @route53_zone).create
|
83
|
+
when 'linode'
|
84
|
+
Sunzi::Dependency.load('linode') # FIXME: this should run at the beginning
|
85
|
+
linode = ::Linode.new(:api_key => @config['linode']['api_key'])
|
86
|
+
# Set the public IP to Linode DNS Manager
|
87
|
+
say "Setting the public IP to Linode DNS Manager..."
|
88
|
+
domainid = linode.domain.list.find{|i| i.domain == @config['fqdn']['zone'] }.domainid
|
89
|
+
linode.domain.resource.create(:DomainID => domainid, :Type => 'A', :Name => @fqdn, :Target => @public_ip)
|
83
90
|
end
|
84
91
|
|
85
92
|
# Save the instance info
|
@@ -128,6 +135,13 @@ module Sunzi
|
|
128
135
|
say 'deleting the public IP from AWS Route 53...'
|
129
136
|
@record = @route53_zone.get_records.find{|i| i.values.first == @instance[:ip_address] }
|
130
137
|
@record.delete if @record
|
138
|
+
when 'linode'
|
139
|
+
Sunzi::Dependency.load('linode') # FIXME: this should run at the beginning
|
140
|
+
linode = ::Linode.new(:api_key => @config['linode']['api_key'])
|
141
|
+
say 'deleting the public IP from Linode DNS Manager...'
|
142
|
+
domainid = linode.domain.list.find{|i| i.domain == @config['fqdn']['zone'] }.domainid
|
143
|
+
resource = linode.domain.resource.list(:DomainID => domainid).find{|i| i.target == @instance[:ip_address] }
|
144
|
+
linode.domain.resource.delete(:DomainID => domainid, :ResourceID => resource.resourceid)
|
131
145
|
end
|
132
146
|
|
133
147
|
# Remove the instance config file
|
data/lib/sunzi/dependency.rb
CHANGED
@@ -5,7 +5,7 @@ module Sunzi
|
|
5
5
|
'linode' => { :require => 'linode', :version => '>= 0.7.9' },
|
6
6
|
'highline' => { :require => 'highline', :version => '>= 1.6.11'},
|
7
7
|
'route53' => { :require => 'route53', :version => '>= 0.2.1' },
|
8
|
-
'digital_ocean' => { :require => 'digital_ocean', :version => '>= 0.0
|
8
|
+
'digital_ocean' => { :require => 'digital_ocean', :version => '>= 1.0.0' },
|
9
9
|
}
|
10
10
|
end
|
11
11
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/bin/bash
|
2
|
+
set -e
|
2
3
|
|
3
4
|
# Load base utility functions like sunzi.mute() and sunzi.install()
|
4
5
|
source recipes/sunzi.sh
|
@@ -11,11 +12,11 @@ export DEBIAN_FRONTEND=noninteractive
|
|
11
12
|
# source recipes/dotdeb.sh
|
12
13
|
|
13
14
|
# Update installed packages
|
14
|
-
sunzi.mute "
|
15
|
-
sunzi.mute "
|
15
|
+
sunzi.mute "apt-get update"
|
16
|
+
sunzi.mute "apt-get -y upgrade"
|
16
17
|
|
17
18
|
# Install packages
|
18
|
-
sunzi.install
|
19
|
+
sunzi.mute "apt-get -y install git-core ntp curl"
|
19
20
|
|
20
21
|
# Set RAILS_ENV
|
21
22
|
environment=$(cat attributes/environment)
|
@@ -32,13 +33,12 @@ ruby_version=$(cat attributes/ruby_version)
|
|
32
33
|
|
33
34
|
if [[ "$(which ruby)" != /usr/local/rvm/rubies/ruby-$ruby_version* ]]; then
|
34
35
|
echo "Installing ruby-$ruby_version"
|
35
|
-
|
36
|
-
rvm install $ruby_version
|
36
|
+
# Install dependencies using RVM autolibs - see https://blog.engineyard.com/2013/rvm-ruby-2-0
|
37
|
+
rvm install --autolibs=3 $ruby_version
|
37
38
|
rvm $ruby_version --default
|
38
39
|
echo 'gem: --no-ri --no-rdoc' > ~/.gemrc
|
39
40
|
|
40
41
|
# Install Bundler
|
41
|
-
gem update --system
|
42
42
|
gem install bundler
|
43
43
|
fi
|
44
44
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# This file is used to define functions under the sunzi.* namespace.
|
2
2
|
|
3
|
-
# Set $sunzi_pkg to "
|
3
|
+
# Set $sunzi_pkg to "apt-get" or "yum", or abort.
|
4
4
|
#
|
5
|
-
if which
|
6
|
-
export sunzi_pkg=
|
5
|
+
if which apt-get >/dev/null 2>&1; then
|
6
|
+
export sunzi_pkg=apt-get
|
7
7
|
elif which yum >/dev/null 2>&1; then
|
8
8
|
export sunzi_pkg=yum
|
9
9
|
fi
|
10
10
|
|
11
11
|
if [ "$sunzi_pkg" = '' ]; then
|
12
|
-
echo 'sunzi only supports
|
12
|
+
echo 'sunzi only supports apt-get or yum!' >&2
|
13
13
|
exit 1
|
14
14
|
fi
|
15
15
|
|
@@ -24,7 +24,7 @@ function sunzi.mute() {
|
|
24
24
|
# Installer
|
25
25
|
#
|
26
26
|
function sunzi.installed() {
|
27
|
-
if [ "$sunzi_pkg" = '
|
27
|
+
if [ "$sunzi_pkg" = 'apt-get' ]; then
|
28
28
|
dpkg -s $@ >/dev/null 2>&1
|
29
29
|
elif [ "$sunzi_pkg" = 'yum' ]; then
|
30
30
|
rpm -qa | grep $@ >/dev/null
|
@@ -32,6 +32,9 @@ function sunzi.installed() {
|
|
32
32
|
return $?
|
33
33
|
}
|
34
34
|
|
35
|
+
# When there's "set -e" in install.sh, sunzi.install should be used with if statement,
|
36
|
+
# otherwise the script may exit unexpectedly when the package is already installed.
|
37
|
+
#
|
35
38
|
function sunzi.install() {
|
36
39
|
for name in $@
|
37
40
|
do
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Install Database Server
|
2
2
|
|
3
|
-
source recipes/mongodb-10gen.sh
|
4
|
-
#
|
5
|
-
#
|
3
|
+
# source recipes/mongodb-10gen.sh # MongoDB
|
4
|
+
# apt-get -q -y install mysql-server-5.5 # MySQL 5.5 - You may need to enable Dotdeb in install.sh first
|
5
|
+
# apt-get -y install redis-server # Redis - You may need to enable Dotdeb in install.sh first
|
@@ -17,10 +17,12 @@ name:
|
|
17
17
|
# filter out large lists by keyword
|
18
18
|
distributions_filter: debian
|
19
19
|
|
20
|
-
#
|
20
|
+
# DNS takes "route53" or "linode"
|
21
21
|
# dns: route53
|
22
22
|
|
23
|
-
#
|
23
|
+
# Credentials for DNS
|
24
24
|
route53:
|
25
25
|
key: your_aws_key
|
26
26
|
secret: your_aws_secret
|
27
|
+
linode:
|
28
|
+
api_key: your_linode_api_key
|
data/sunzi.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'sunzi'
|
5
|
-
spec.version = '1.
|
5
|
+
spec.version = '1.1.0' # retrieve this value by: Gem.loaded_specs['sunzi'].version.to_s
|
6
6
|
spec.authors = ['Kenn Ejima']
|
7
7
|
spec.email = ['kenn.ejima@gmail.com']
|
8
8
|
spec.homepage = 'http://github.com/kenn/sunzi'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunzi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenn Ejima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -76,7 +76,6 @@ files:
|
|
76
76
|
- lib/templates/create/.gitignore
|
77
77
|
- lib/templates/create/install.sh
|
78
78
|
- lib/templates/create/recipes/sunzi.sh
|
79
|
-
- lib/templates/create/roles/app.sh
|
80
79
|
- lib/templates/create/roles/db.sh
|
81
80
|
- lib/templates/create/roles/web.sh
|
82
81
|
- lib/templates/create/sunzi.yml
|
@@ -104,10 +103,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
103
|
version: '0'
|
105
104
|
requirements: []
|
106
105
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.0.
|
106
|
+
rubygems_version: 2.0.2
|
108
107
|
signing_key:
|
109
108
|
specification_version: 4
|
110
109
|
summary: Server provisioning utility for minimalists
|
111
110
|
test_files:
|
112
111
|
- test/test_cli.rb
|
113
|
-
has_rdoc:
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# Install Application Server
|
2
|
-
|
3
|
-
# Required attributes: env, ruby_version
|
4
|
-
export ENVIRONMENT=$(cat attributes/environment)
|
5
|
-
export RUBY_VERSION=$(cat attributes/ruby_version)
|
6
|
-
|
7
|
-
# Install RVM
|
8
|
-
source recipes/rvm.sh
|
9
|
-
|
10
|
-
# Set RAILS_ENV
|
11
|
-
if grep -Fq "RAILS_ENV" ~/.bash_profile; then
|
12
|
-
echo 'RAILS_ENV entry already exists'
|
13
|
-
else
|
14
|
-
echo "export RAILS_ENV=$ENVIRONMENT" >> ~/.bash_profile
|
15
|
-
source ~/.bash_profile
|
16
|
-
fi
|
17
|
-
|
18
|
-
# Install Ruby
|
19
|
-
if [[ "$(which ruby)" == /usr/local/rvm/rubies/ruby-$RUBY_VERSION* ]]; then
|
20
|
-
echo 'ruby-$RUBY_VERSION already installed'
|
21
|
-
else
|
22
|
-
aptitude -y install curl build-essential libssl-dev libreadline6-dev
|
23
|
-
rvm install $RUBY_VERSION
|
24
|
-
rvm $RUBY_VERSION --default
|
25
|
-
echo 'gem: --no-ri --no-rdoc' > ~/.gemrc
|
26
|
-
|
27
|
-
# Install RubyGems
|
28
|
-
gem update --system
|
29
|
-
gem install bundler
|
30
|
-
fi
|