sunzi 0.6.0 → 0.7.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.
- data/README.md +1 -0
- data/lib/sunzi/cli.rb +13 -7
- data/lib/sunzi/version.rb +1 -1
- data/lib/templates/create/sunzi.yml +10 -0
- metadata +8 -8
data/README.md
CHANGED
|
@@ -18,6 +18,7 @@ Its design goals are:
|
|
|
18
18
|
|
|
19
19
|
### What's new:
|
|
20
20
|
|
|
21
|
+
* v0.7: Added `erase_remote_folder` and `cache_remote_recipes` preferences for customized behavior.
|
|
21
22
|
* v0.6: System function sunzi::silencer() added for succinct log messages.
|
|
22
23
|
* v0.5: Role-based configuration supported. Reworked directory structure. **Incompatible with previous versions**.
|
|
23
24
|
|
data/lib/sunzi/cli.rb
CHANGED
|
@@ -52,7 +52,7 @@ module Sunzi
|
|
|
52
52
|
endpoint = "#{user}@#{host}"
|
|
53
53
|
|
|
54
54
|
# compile attributes and recipes
|
|
55
|
-
|
|
55
|
+
do_compile(role)
|
|
56
56
|
|
|
57
57
|
# The host key might change when we instantiate a new VM, so
|
|
58
58
|
# we remove (-R) the old host key from known_hosts.
|
|
@@ -66,6 +66,8 @@ module Sunzi
|
|
|
66
66
|
bash install.sh
|
|
67
67
|
EOS
|
|
68
68
|
|
|
69
|
+
remote_commands.strip! << ' && rm -rf ~/sunzi' if @config['preferences'] and @config['preferences']['erase_remote_folder']
|
|
70
|
+
|
|
69
71
|
local_commands = <<-EOS
|
|
70
72
|
cd compiled
|
|
71
73
|
tar cz . | ssh -o 'StrictHostKeyChecking no' #{endpoint} -p #{port} '#{remote_commands}'
|
|
@@ -92,18 +94,22 @@ module Sunzi
|
|
|
92
94
|
abort_with "#{role} doesn't exist!" if role and !File.exists?("roles/#{role}.sh")
|
|
93
95
|
|
|
94
96
|
# Load sunzi.yml
|
|
95
|
-
|
|
97
|
+
@config = YAML.load(File.read('sunzi.yml'))
|
|
96
98
|
|
|
97
99
|
# Break down attributes into individual files
|
|
98
|
-
|
|
100
|
+
(@config['attributes'] || []).each {|key, value| create_file "compiled/attributes/#{key}", value }
|
|
99
101
|
|
|
100
102
|
# Retrieve remote recipes via HTTP
|
|
101
|
-
|
|
103
|
+
cache_remote_recipes = @config['preferences'] && @config['preferences']['cache_remote_recipes']
|
|
104
|
+
(@config['recipes'] || []).each do |key, value|
|
|
105
|
+
next if cache_remote_recipes and File.exists?("compiled/recipes/#{key}.sh")
|
|
106
|
+
get value, "compiled/recipes/#{key}.sh"
|
|
107
|
+
end
|
|
102
108
|
|
|
103
109
|
# Copy local files
|
|
104
|
-
Dir['recipes/*'].each
|
|
105
|
-
Dir['roles/*'].each
|
|
106
|
-
|
|
110
|
+
Dir['recipes/*'].each {|file| copy_file File.expand_path(file), "compiled/recipes/#{File.basename(file)}" }
|
|
111
|
+
Dir['roles/*'].each {|file| copy_file File.expand_path(file), "compiled/roles/#{File.basename(file)}" }
|
|
112
|
+
(@config['files'] || []).each {|file| copy_file File.expand_path(file), "compiled/files/#{File.basename(file)}" }
|
|
107
113
|
|
|
108
114
|
# Build install.sh
|
|
109
115
|
if role
|
data/lib/sunzi/version.rb
CHANGED
|
@@ -14,3 +14,13 @@ recipes:
|
|
|
14
14
|
# Files specified here will be copied to compiled/files.
|
|
15
15
|
files:
|
|
16
16
|
- ~/.ssh/id_rsa.pub
|
|
17
|
+
|
|
18
|
+
# Fine tune how Sunzi should work.
|
|
19
|
+
preferences:
|
|
20
|
+
# Erase the generated folder on the server after deploy.
|
|
21
|
+
# Turn on when you are done with testing and ready for production use.
|
|
22
|
+
erase_remote_folder: false
|
|
23
|
+
|
|
24
|
+
# Skip retrieving remote recipes when local copies already exist. This setting helps
|
|
25
|
+
# iterative deploy testing considerably faster, when you have a lot of remote recipes.
|
|
26
|
+
cache_remote_recipes: false
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sunzi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-03-
|
|
12
|
+
date: 2012-03-08 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: thor
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &2156016540 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
@@ -21,10 +21,10 @@ dependencies:
|
|
|
21
21
|
version: '0'
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *2156016540
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: rainbow
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &2156031920 !ruby/object:Gem::Requirement
|
|
28
28
|
none: false
|
|
29
29
|
requirements:
|
|
30
30
|
- - ! '>='
|
|
@@ -32,10 +32,10 @@ dependencies:
|
|
|
32
32
|
version: '0'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *2156031920
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
37
|
name: rake
|
|
38
|
-
requirement: &
|
|
38
|
+
requirement: &2156031000 !ruby/object:Gem::Requirement
|
|
39
39
|
none: false
|
|
40
40
|
requirements:
|
|
41
41
|
- - ! '>='
|
|
@@ -43,7 +43,7 @@ dependencies:
|
|
|
43
43
|
version: '0'
|
|
44
44
|
type: :development
|
|
45
45
|
prerelease: false
|
|
46
|
-
version_requirements: *
|
|
46
|
+
version_requirements: *2156031000
|
|
47
47
|
description: Server provisioning utility for minimalists
|
|
48
48
|
email:
|
|
49
49
|
- kenn.ejima@gmail.com
|