sunzi 0.1.0 → 0.2.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 +23 -10
- data/lib/sunzi/cli.rb +29 -15
- data/lib/sunzi/version.rb +1 -1
- data/lib/sunzi.rb +0 -1
- data/lib/templates/recipes.yml +2 -0
- data/lib/templates/remote/install.sh +3 -0
- metadata +4 -3
data/README.md
CHANGED
@@ -11,9 +11,10 @@ Sunzi assumes that Linux distributions have (mostly) sane defaults.
|
|
11
11
|
|
12
12
|
Its design goals are:
|
13
13
|
|
14
|
-
* A big-bang overwriting with loads of custom configurations makes it difficult to know **what you are actually doing** - instead, Sunzi let you keep track of as little diff from default as possible.
|
15
|
-
* No mysterious Ruby DSL involved
|
16
|
-
* No configuration server
|
14
|
+
* **Single shell script.** A big-bang overwriting with loads of custom configurations makes it difficult to know **what you are actually doing** - instead, Sunzi let you keep track of as little diff from default as possible.
|
15
|
+
* **No mysterious Ruby DSL involved.** Sunzi recipes are written in a plain shell script. Why? Because, most of the information about server configuration you get on the web is written in a set of shell commands. Why should you translate it into a proprietary DSL, rather than just copy-paste?
|
16
|
+
* **Minimum dependencies.** No configuration server required. You don't even need a Ruby runtime on the remote server.
|
17
|
+
* **Always use the root user.** Think twice before blindly assuming you need a regular user - it doesn't add any security benefit for server provisioning, it just adds extra verbosity for nothing. However, it doesn't mean that you shouldn't create regular users with Sunzi - feel free to write your own recipes.
|
17
18
|
|
18
19
|
Quickstart
|
19
20
|
----------
|
@@ -41,16 +42,17 @@ Now, what it actually does is:
|
|
41
42
|
|
42
43
|
As you can see, what you need to do is edit `install.sh` and add some shell commands. That's it.
|
43
44
|
|
44
|
-
|
45
|
-
|
45
|
+
Directory structure
|
46
|
+
-------------------
|
46
47
|
|
47
48
|
Here's the directory structure that `sunzi create` automatically generates:
|
48
49
|
|
49
50
|
```
|
50
51
|
sunzi/
|
51
|
-
attributes.yml ---- add custom
|
52
|
+
attributes.yml ---- add custom attributes here
|
53
|
+
recipes.yml ---- add remote recipes here
|
52
54
|
remote/ ---- everything under this folder will be transferred to the remote server
|
53
|
-
attributes/ ---- compiled from attributes.yml at deploy
|
55
|
+
attributes/ ---- compiled attributes from attributes.yml at deploy (do not edit directly)
|
54
56
|
env
|
55
57
|
ssh_key
|
56
58
|
recipes/ ---- put commonly used scripts here, referred from install.sh
|
@@ -58,12 +60,23 @@ sunzi/
|
|
58
60
|
install.sh ---- main scripts that gets run on the remote server
|
59
61
|
```
|
60
62
|
|
63
|
+
Remote Recipes
|
64
|
+
--------------
|
65
|
+
|
66
|
+
Recipes can be retrieved remotely via HTTP. Put the URL in `recipes.yml`, and Sunzi automatically loads the content and put it into the `remote/recipes` folder.
|
67
|
+
|
68
|
+
For instance, if you have the following line in `recipes.yml`,
|
69
|
+
|
70
|
+
```
|
71
|
+
rvm: https://raw.github.com/kenn/sunzi-recipes/master/ruby/rvm.sh
|
72
|
+
```
|
73
|
+
|
74
|
+
`rvm.sh` will be available and you can refer to that recipe by `source recipes/rvm.sh`.
|
75
|
+
|
61
76
|
Vagrant
|
62
77
|
-------
|
63
78
|
|
64
|
-
If you're using Sunzi with [Vagrant](http://vagrantup.com/),
|
65
|
-
|
66
|
-
Since it uses port 2222 for SSH, you need to specify the port number:
|
79
|
+
If you're using Sunzi with [Vagrant](http://vagrantup.com/), you need to specify the port number 2222.
|
67
80
|
|
68
81
|
$ vagrant up
|
69
82
|
$ sunzi deploy root@localhost 2222
|
data/lib/sunzi/cli.rb
CHANGED
@@ -15,36 +15,28 @@ module Sunzi
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
map "
|
19
|
-
map "d" => :deploy
|
18
|
+
# map "cr" => :create
|
19
|
+
# map "d" => :deploy
|
20
20
|
|
21
|
-
desc "create [PROJECT]", "Create sunzi project
|
21
|
+
desc "create [PROJECT]", "Create sunzi project"
|
22
22
|
def create(project = 'sunzi')
|
23
23
|
empty_directory project
|
24
24
|
empty_directory "#{project}/remote"
|
25
25
|
empty_directory "#{project}/remote/recipes"
|
26
26
|
template "templates/attributes.yml", "#{project}/attributes.yml"
|
27
|
+
template "templates/recipes.yml", "#{project}/recipes.yml"
|
27
28
|
template "templates/remote/install.sh", "#{project}/remote/install.sh"
|
28
29
|
template "templates/remote/recipes/ssh_key.sh", "#{project}/remote/recipes/ssh_key.sh"
|
29
30
|
end
|
30
31
|
|
31
|
-
desc "deploy [USER@HOST] [PORT]", "Deploy sunzi project
|
32
|
+
desc "deploy [USER@HOST] [PORT]", "Deploy sunzi project"
|
32
33
|
def deploy(*target)
|
33
34
|
if target.empty? or !target.first.match(/@/)
|
34
|
-
|
35
|
+
say shell.set_color("Usage: sunzi deploy root@example.com", :red, true)
|
35
36
|
abort
|
36
37
|
end
|
37
38
|
|
38
|
-
|
39
|
-
unless File.exists?('attributes.yml')
|
40
|
-
puts "You must be in the sunzi folder"
|
41
|
-
abort
|
42
|
-
end
|
43
|
-
hash = YAML.load(File.read('attributes.yml'))
|
44
|
-
FileUtils.mkdir_p('remote/attributes')
|
45
|
-
hash.each do |key, value|
|
46
|
-
File.open("remote/attributes/#{key}", 'w'){|file| file.write(value) }
|
47
|
-
end
|
39
|
+
compile
|
48
40
|
|
49
41
|
host, port = target
|
50
42
|
port ||= 22
|
@@ -75,5 +67,27 @@ module Sunzi
|
|
75
67
|
end
|
76
68
|
end
|
77
69
|
|
70
|
+
desc "compile", "Compile sunzi project"
|
71
|
+
def compile
|
72
|
+
# Check if you're in the sunzi directory
|
73
|
+
unless File.exists?('attributes.yml')
|
74
|
+
say shell.set_color("You must be in the sunzi folder", :red, true)
|
75
|
+
abort
|
76
|
+
end
|
77
|
+
|
78
|
+
# Compile attributes.yml
|
79
|
+
hash = YAML.load(File.read('attributes.yml'))
|
80
|
+
empty_directory 'remote/attributes'
|
81
|
+
hash.each do |key, value|
|
82
|
+
File.open("remote/attributes/#{key}", 'w'){|file| file.write(value) }
|
83
|
+
end
|
84
|
+
|
85
|
+
# Compile recipes.yml
|
86
|
+
hash = YAML.load(File.read('recipes.yml'))
|
87
|
+
empty_directory 'remote/recipes'
|
88
|
+
hash.each do |key, value|
|
89
|
+
get value, "remote/recipes/#{key}.sh"
|
90
|
+
end
|
91
|
+
end
|
78
92
|
end
|
79
93
|
end
|
data/lib/sunzi/version.rb
CHANGED
data/lib/sunzi.rb
CHANGED
@@ -3,6 +3,5 @@ LIB_PATH = File.join(File.dirname(__FILE__), 'sunzi')
|
|
3
3
|
module Sunzi
|
4
4
|
autoload :Base, File.join(LIB_PATH, 'base')
|
5
5
|
autoload :Cli, File.join(LIB_PATH, 'cli')
|
6
|
-
autoload :Dependency, File.join(LIB_PATH, 'dependency')
|
7
6
|
autoload :Version, File.join(LIB_PATH, 'version')
|
8
7
|
end
|
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.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-25 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
|
-
requirement: &
|
16
|
+
requirement: &2156394360 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2156394360
|
25
25
|
description: Server provisioning tool for minimalists
|
26
26
|
email:
|
27
27
|
- kenn.ejima@gmail.com
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- lib/sunzi/cli.rb
|
41
41
|
- lib/sunzi/version.rb
|
42
42
|
- lib/templates/attributes.yml
|
43
|
+
- lib/templates/recipes.yml
|
43
44
|
- lib/templates/remote/install.sh
|
44
45
|
- lib/templates/remote/recipes/ssh_key.sh
|
45
46
|
- sunzi.gemspec
|