sunzi 1.3.0 → 1.4.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/CHANGELOG.md +13 -0
- data/README.md +2 -10
- data/lib/sunzi/cli.rb +3 -3
- data/lib/sunzi/cloud/base.rb +27 -13
- data/lib/sunzi/cloud/digital_ocean.rb +1 -0
- data/lib/templates/create/install.sh +1 -0
- data/lib/templates/create/sunzi.yml +3 -2
- data/sunzi.gemspec +2 -1
- data/test/test_cli.rb +2 -3
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e3cdb0743553811ee1eabba13a157b8e083bb0c
|
4
|
+
data.tar.gz: 1a84c8f3f1de7377d64eb0b81ec1c0b5bb53f3c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d02df7f0f7be31227a1a31221afec080d4e642e314426d9b9053e8c874f70aa1d7f4913cb017e3e33194bbff979af2ac5236064611354c85525aa590a6198eb
|
7
|
+
data.tar.gz: 68ed831c1d46e064dfd442ac43a4bf57a8c755965e513bbb9bf2beafb1cda0c372280ed77d5ea416b673ce3febb247c728cd31ef228e21fa2f2937173c9efb4c
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
## 1.4, release 2013-09-27
|
2
|
+
* `sunzi teardown` no longer requires instance names as an argument, it lets you choose from a list instead.
|
3
|
+
|
4
|
+
## Past Releases
|
5
|
+
* v1.3: SSH config support. Thanks to @toooooooby
|
6
|
+
* v1.2: Evaluate everything as ERB templates by default. Added "files" folder.
|
7
|
+
* v1.1: "set -e" by default. apt-get everywhere in place of aptitude. Linode DNS support for DigitalOcean instances.
|
8
|
+
* v1.0: System functions are refactored into sunzi.mute() and sunzi.install().
|
9
|
+
* v0.9: Support for [DigitalOcean](https://www.digitalocean.com) setup / teardown.
|
10
|
+
* v0.8: Added `--sudo` option to `sunzi deploy`.
|
11
|
+
* v0.7: Added `erase_remote_folder` and `cache_remote_recipes` preferences for customized behavior.
|
12
|
+
* v0.6: System function sunzi::silencer() added for succinct log messages.
|
13
|
+
* v0.5: Role-based configuration supported. Reworked directory structure. **Incompatible with previous versions**.
|
data/README.md
CHANGED
@@ -18,15 +18,7 @@ Its design goals are:
|
|
18
18
|
|
19
19
|
### What's new:
|
20
20
|
|
21
|
-
|
22
|
-
* v1.2: Evaluate everything as ERB templates by default. Added "files" folder.
|
23
|
-
* v1.1: "set -e" by default. apt-get everywhere in place of aptitude. Linode DNS support for DigitalOcean instances.
|
24
|
-
* v1.0: System functions are refactored into sunzi.mute() and sunzi.install().
|
25
|
-
* v0.9: Support for [DigitalOcean](https://www.digitalocean.com) setup / teardown.
|
26
|
-
* v0.8: Added `--sudo` option to `sunzi deploy`.
|
27
|
-
* v0.7: Added `erase_remote_folder` and `cache_remote_recipes` preferences for customized behavior.
|
28
|
-
* v0.6: System function sunzi::silencer() added for succinct log messages.
|
29
|
-
* v0.5: Role-based configuration supported. Reworked directory structure. **Incompatible with previous versions**.
|
21
|
+
Please see the [CHANGELOG](https://github.com/kenn/sunzi/blob/master/CHANGELOG.md).
|
30
22
|
|
31
23
|
Quickstart
|
32
24
|
----------
|
@@ -73,7 +65,7 @@ $ sunzi create # Create a new Sunzi project
|
|
73
65
|
$ sunzi deploy [user@host:port] [role] [--sudo] # Deploy Sunzi project
|
74
66
|
|
75
67
|
$ sunzi setup [linode|digital_ocean] # Setup a new VM on the cloud services
|
76
|
-
$ sunzi teardown [linode|digital_ocean]
|
68
|
+
$ sunzi teardown [linode|digital_ocean] # Teardown an existing VM on the cloud services
|
77
69
|
```
|
78
70
|
|
79
71
|
Directory structure
|
data/lib/sunzi/cli.rb
CHANGED
@@ -27,9 +27,9 @@ module Sunzi
|
|
27
27
|
Sunzi::Cloud.new(self, provider).setup
|
28
28
|
end
|
29
29
|
|
30
|
-
desc 'teardown [linode|digital_ocean]
|
31
|
-
def teardown(provider
|
32
|
-
Sunzi::Cloud.new(self, provider).teardown
|
30
|
+
desc 'teardown [linode|digital_ocean]', 'Teardown an existing VM'
|
31
|
+
def teardown(provider)
|
32
|
+
Sunzi::Cloud.new(self, provider).teardown
|
33
33
|
end
|
34
34
|
|
35
35
|
desc 'version', 'Show version'
|
data/lib/sunzi/cloud/base.rb
CHANGED
@@ -12,14 +12,13 @@ module Sunzi
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def setup
|
15
|
-
unless File.exist?
|
15
|
+
unless File.exist? provider_config_path
|
16
16
|
@cli.empty_directory "#{@provider}/instances"
|
17
|
-
@cli.template "templates/setup/#{
|
17
|
+
@cli.template "templates/setup/#{provider_config_path}", provider_config_path
|
18
18
|
exit_with "Now go ahead and edit #{@provider}.yml, then run this command again!"
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
@dns = Sunzi::DNS.new(@config, @provider) if @config['dns']
|
21
|
+
assign_config_and_dns
|
23
22
|
|
24
23
|
if @config['fqdn']['zone'] == 'example.com'
|
25
24
|
abort_with "You must have your own settings in #{@provider}.yml"
|
@@ -32,27 +31,29 @@ module Sunzi
|
|
32
31
|
abort_with '"label" field in linode.yml is no longer supported. rename it to "name".' if @config['label']
|
33
32
|
@fqdn = @config['fqdn'][@env].gsub(/%{host}/, @host)
|
34
33
|
@name = @config['name'][@env].gsub(/%{host}/, @host)
|
34
|
+
abort_with "#{@name} already exists!" if instance_config_path.exist?
|
35
35
|
|
36
36
|
assign_api
|
37
37
|
@attributes = {}
|
38
38
|
do_setup
|
39
39
|
|
40
40
|
# Save instance info
|
41
|
-
@cli.create_file
|
41
|
+
@cli.create_file instance_config_path, YAML.dump(@instance)
|
42
42
|
|
43
43
|
# Register IP to DNS
|
44
44
|
@dns.add(@fqdn, @public_ip) if @dns
|
45
45
|
end
|
46
46
|
|
47
|
-
def teardown
|
48
|
-
|
49
|
-
|
50
|
-
end
|
47
|
+
def teardown
|
48
|
+
names = Dir.glob("#{@provider}/instances/*.yml").map{|i| i.split('/').last.sub('.yml','') }
|
49
|
+
abort_with "No match found with #{@provider}/instances/*.yml" if names.empty?
|
51
50
|
|
52
|
-
|
53
|
-
@
|
51
|
+
names.each{|i| say i }
|
52
|
+
@name = ask("which instance?: ", String) {|q| q.in = names }
|
54
53
|
|
55
|
-
|
54
|
+
assign_config_and_dns
|
55
|
+
|
56
|
+
@instance = YAML.load(instance_config_path.read)
|
56
57
|
|
57
58
|
# Are you sure?
|
58
59
|
moveon = ask("Are you sure about deleting #{@instance[:fqdn]} permanently? (y/n) ", String) {|q| q.in = ['y','n']}
|
@@ -66,11 +67,24 @@ module Sunzi
|
|
66
67
|
@dns.delete(@instance[ip_key]) if @dns
|
67
68
|
|
68
69
|
# Remove the instance config file
|
69
|
-
@cli.remove_file
|
70
|
+
@cli.remove_file instance_config_path
|
70
71
|
|
71
72
|
say 'Done.'
|
72
73
|
end
|
73
74
|
|
75
|
+
def assign_config_and_dns
|
76
|
+
@config = YAML.load(provider_config_path.read)
|
77
|
+
@dns = Sunzi::DNS.new(@config, @provider) if @config['dns']
|
78
|
+
end
|
79
|
+
|
80
|
+
def provider_config_path
|
81
|
+
Pathname.new "#{@provider}/#{@provider}.yml"
|
82
|
+
end
|
83
|
+
|
84
|
+
def instance_config_path
|
85
|
+
Pathname.new "#{@provider}/instances/#{@name}.yml"
|
86
|
+
end
|
87
|
+
|
74
88
|
def ask(question, answer_type, &details)
|
75
89
|
@ui.ask(@ui.color(question, :green, :bold), answer_type, &details)
|
76
90
|
end
|
@@ -55,6 +55,7 @@ module Sunzi
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def choose(key, result)
|
58
|
+
abort "no #{key} found!" if result.first.nil?
|
58
59
|
result.each{|i| say "#{i.id}: #{i.name}" }
|
59
60
|
@attributes[:"#{key}_id"] = ask("which #{key}?: ", Integer) {|q| q.in = result.map(&:id); q.default = result.first.id }
|
60
61
|
@attributes[:"#{key}_name"] = result.find{|i| i.id == @attributes[:"#{key}_id"] }.name
|
@@ -10,6 +10,7 @@ export DEBIAN_FRONTEND=noninteractive
|
|
10
10
|
|
11
11
|
# Add Dotdeb repository. Recommended if you're using Debian. See http://www.dotdeb.org/about/
|
12
12
|
# source recipes/dotdeb.sh
|
13
|
+
# source recipes/backports.sh
|
13
14
|
|
14
15
|
# Update apt catalog and upgrade installed packages
|
15
16
|
sunzi.mute "apt-get update"
|
@@ -7,7 +7,8 @@ attributes:
|
|
7
7
|
# Remote recipes here will be downloaded to compiled/recipes.
|
8
8
|
recipes:
|
9
9
|
rvm: https://raw.github.com/kenn/sunzi-recipes/master/ruby/rvm.sh
|
10
|
-
# dotdeb: https://raw.github.com/kenn/sunzi-recipes/master/debian/dotdeb.sh
|
10
|
+
# dotdeb: https://raw.github.com/kenn/sunzi-recipes/master/debian/dotdeb-wheezy.sh
|
11
|
+
# backports: https://raw.github.com/kenn/sunzi-recipes/master/debian/backports-wheezy.sh
|
11
12
|
# mongodb-10gen: https://raw.github.com/kenn/sunzi-recipes/master/debian/mongodb-10gen.sh
|
12
13
|
|
13
14
|
# Files specified here will be copied to compiled/files.
|
@@ -18,7 +19,7 @@ recipes:
|
|
18
19
|
preferences:
|
19
20
|
# Erase the generated folder on the server after deploy.
|
20
21
|
# Turn on when you are done with testing and ready for production use.
|
21
|
-
erase_remote_folder:
|
22
|
+
erase_remote_folder: true
|
22
23
|
|
23
24
|
# Skip retrieving remote recipes when local copies already exist. This setting helps
|
24
25
|
# iterative deploy testing considerably faster, when you have a lot of remote recipes.
|
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.4.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'
|
@@ -19,4 +19,5 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.add_runtime_dependency 'rainbow'
|
20
20
|
spec.add_runtime_dependency 'net-ssh'
|
21
21
|
spec.add_development_dependency 'rake'
|
22
|
+
spec.add_development_dependency 'minitest'
|
22
23
|
end
|
data/test/test_cli.rb
CHANGED
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.4.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-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: Server provisioning utility for minimalists
|
70
84
|
email:
|
71
85
|
- kenn.ejima@gmail.com
|
@@ -76,6 +90,7 @@ extra_rdoc_files: []
|
|
76
90
|
files:
|
77
91
|
- .gitignore
|
78
92
|
- .travis.yml
|
93
|
+
- CHANGELOG.md
|
79
94
|
- Gemfile
|
80
95
|
- README.md
|
81
96
|
- Rakefile
|
@@ -124,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
139
|
version: '0'
|
125
140
|
requirements: []
|
126
141
|
rubyforge_project:
|
127
|
-
rubygems_version: 2.0.
|
142
|
+
rubygems_version: 2.0.6
|
128
143
|
signing_key:
|
129
144
|
specification_version: 4
|
130
145
|
summary: Server provisioning utility for minimalists
|