sunzi 2.0.0 → 2.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 +5 -5
- data/.gitignore +4 -5
- data/CHANGELOG.md +1 -1
- data/Gemfile +1 -1
- data/README.md +16 -6
- data/Rakefile +3 -3
- data/lib/sunzi/cli.rb +2 -2
- data/lib/sunzi/command.rb +12 -13
- data/lib/sunzi/dependency.rb +1 -1
- data/lib/sunzi/plugin.rb +0 -1
- data/sunzi.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ae08190a203a96afbc856240713e37d197d97381
|
4
|
+
data.tar.gz: 4afc33d68da0dc9758c87b0d2f10a6a5edb10f17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74efe9a99bf9579337169c780f7891cd88a1b25aa167bff4a45ca1c994d3e20d6046933beeb9cdb7bf1c1bc6d5a6ebf906336031dbd63ceb6342183f270ccf83
|
7
|
+
data.tar.gz: 065bcc712a06c87d7c488463a145f45c4ea66009c91781f2044aaa2113d94c28f6f84a90fb72e689dcddbffa76486f717e2d89412ac052ea2f38d36a3b793d1a
|
data/.gitignore
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
sandbox
|
1
|
+
/.bundle/
|
2
|
+
/pkg/
|
3
|
+
/tmp/
|
4
|
+
/Gemfile.lock
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,20 +1,30 @@
|
|
1
1
|
Sunzi
|
2
2
|
=====
|
3
3
|
|
4
|
+
[](http://travis-ci.org/kenn/sunzi)
|
5
|
+
|
4
6
|
```
|
5
7
|
"The supreme art of war is to subdue the enemy without fighting." - Sunzi
|
6
8
|
```
|
7
9
|
|
8
|
-
Sunzi is the easiest [
|
10
|
+
Sunzi is the easiest configuration automation and [infrastructure as code](https://en.wikipedia.org/wiki/Infrastructure_as_Code) utility designed for mere mortals.
|
11
|
+
|
12
|
+
If Chef, Puppet, Ansible or SaltStack is driving you nuts, try Sunzi!
|
9
13
|
|
10
14
|
Sunzi assumes that modern Linux distributions have (mostly) sane defaults and great package managers.
|
11
15
|
|
12
16
|
Its design goals are:
|
13
17
|
|
14
18
|
* **It's just shell script.** No clunky Ruby DSL involved. Most of the information about server configuration on the web is written in shell commands. Just copy-paste them, rather than translate it into an arbitrary DSL. Also, Bash is the greatest common denominator on minimum Linux installs.
|
15
|
-
|
16
|
-
* **
|
17
|
-
|
19
|
+
|
20
|
+
* **Minimal diff from default.** No big-bang overwriting. Append or replace the smallest possible piece of data in a config file. Loads of custom configurations make it difficult to reason what you are really doing.
|
21
|
+
|
22
|
+
* **Minimum dependencies.** No configuration server required. You don't even need a Ruby runtime on the remote server, sunzi runs a combined shell script over SSH.
|
23
|
+
|
24
|
+
See also:
|
25
|
+
|
26
|
+
* [sunzi-vps](https://github.com/kenn/sunzi-vps) - Interactive server provisioning plugin for Linode and DigitalOcean.
|
27
|
+
* [sunzi-recipes](https://github.com/kenn/sunzi-recipes) - Sample repository for remote recipes.
|
18
28
|
|
19
29
|
### What's new:
|
20
30
|
|
@@ -26,7 +36,7 @@ Quickstart
|
|
26
36
|
Install:
|
27
37
|
|
28
38
|
```bash
|
29
|
-
$
|
39
|
+
$ gem install sunzi
|
30
40
|
```
|
31
41
|
|
32
42
|
Go into your project directory (if it's a Rails project, `config` would be a good place to start with), then:
|
@@ -119,7 +129,7 @@ For instance, if you have the following line in `sunzi.yml`,
|
|
119
129
|
|
120
130
|
```yaml
|
121
131
|
recipes:
|
122
|
-
rvm: https://raw.
|
132
|
+
rvm: https://raw.githubusercontent.com/kenn/sunzi-recipes/master/ruby/rvm.sh
|
123
133
|
```
|
124
134
|
|
125
135
|
`rvm.sh` will be available and you can refer to that recipe by `source recipes/rvm.sh`.
|
data/Rakefile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rake/testtask'
|
3
3
|
|
4
|
-
Rake::TestTask.new do |t|
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
5
|
t.libs << 'test'
|
6
|
-
t.test_files = FileList['test
|
7
|
-
t.verbose = true
|
6
|
+
t.test_files = FileList['test/**/*_test.rb']
|
8
7
|
end
|
8
|
+
|
9
9
|
task :default => :test
|
data/lib/sunzi/cli.rb
CHANGED
@@ -10,8 +10,8 @@ module Sunzi
|
|
10
10
|
|
11
11
|
desc 'deploy [user@host:port] [role] [--sudo]', 'Deploy sunzi project'
|
12
12
|
method_options sudo: false
|
13
|
-
def deploy(
|
14
|
-
Sunzi::Command.new.deploy(
|
13
|
+
def deploy(target, role = nil)
|
14
|
+
Sunzi::Command.new.deploy(target, role, options)
|
15
15
|
end
|
16
16
|
|
17
17
|
desc 'compile', 'Compile sunzi project'
|
data/lib/sunzi/command.rb
CHANGED
@@ -5,7 +5,7 @@ module Sunzi
|
|
5
5
|
class Command
|
6
6
|
include Sunzi::Actions::Delegate
|
7
7
|
|
8
|
-
delegate_to_thor :copy_file, :template, :get, :append_to_file
|
8
|
+
delegate_to_thor :copy_file, :template, :get, :append_to_file
|
9
9
|
|
10
10
|
def create(project)
|
11
11
|
copy_file 'templates/create/.gitignore', "#{project}/.gitignore"
|
@@ -17,15 +17,13 @@ module Sunzi
|
|
17
17
|
copy_file 'templates/create/files/.gitkeep', "#{project}/files/.gitkeep"
|
18
18
|
end
|
19
19
|
|
20
|
-
def deploy(
|
21
|
-
role = args[0]
|
22
|
-
|
23
|
-
sudo = 'sudo ' if options.sudo?
|
24
|
-
endpoint = Endpoint.new(first)
|
25
|
-
|
20
|
+
def deploy(target, role, options)
|
26
21
|
# compile vars and recipes
|
27
22
|
compile(role)
|
28
23
|
|
24
|
+
sudo = 'sudo ' if options.sudo?
|
25
|
+
endpoint = Endpoint.new(target)
|
26
|
+
|
29
27
|
# The host key might change when we instantiate a new VM, so
|
30
28
|
# we remove (-R) the old host key from known_hosts.
|
31
29
|
`ssh-keygen -R #{endpoint.host} 2> /dev/null`
|
@@ -60,6 +58,7 @@ module Sunzi
|
|
60
58
|
end
|
61
59
|
|
62
60
|
def compile(role = nil)
|
61
|
+
abort_with 'You must be in a sunzi folder' unless File.exist?('sunzi.yml')
|
63
62
|
abort_with "#{role} doesn't exist!" if role && !File.exist?("roles/#{role}.sh")
|
64
63
|
abort_with 'As of v2, "attributes" are now "vars" in sunzi.yml and shell scripts.' if config.attributes
|
65
64
|
|
@@ -73,7 +72,7 @@ module Sunzi
|
|
73
72
|
@vars = config.vars # Used within ERB templates
|
74
73
|
|
75
74
|
# Copy local files to compiled folder
|
76
|
-
files =
|
75
|
+
files = glob('{recipes,roles,files}/**/*').select { |file| File.file?(file) }
|
77
76
|
|
78
77
|
files.each do |file|
|
79
78
|
render file, "compiled/#{file}"
|
@@ -96,11 +95,7 @@ module Sunzi
|
|
96
95
|
private
|
97
96
|
|
98
97
|
def config
|
99
|
-
@config ||=
|
100
|
-
abort_with 'You must be in a sunzi folder' unless File.exist?('sunzi.yml')
|
101
|
-
|
102
|
-
YAML.load(File.read('sunzi.yml')).to_hashugar
|
103
|
-
end
|
98
|
+
@config ||= YAML.load(ERB.new(File.read('sunzi.yml')).result).to_hashugar
|
104
99
|
end
|
105
100
|
|
106
101
|
# template method requires absolute path to work with current directory
|
@@ -109,5 +104,9 @@ module Sunzi
|
|
109
104
|
template File.expand_path(source), target, context: binding
|
110
105
|
end
|
111
106
|
|
107
|
+
def glob(pattern)
|
108
|
+
Dir.glob(pattern, File::FNM_DOTMATCH) - ['.', '..']
|
109
|
+
end
|
110
|
+
|
112
111
|
end
|
113
112
|
end
|
data/lib/sunzi/dependency.rb
CHANGED
data/lib/sunzi/plugin.rb
CHANGED
@@ -2,7 +2,6 @@ module Sunzi
|
|
2
2
|
module Plugin
|
3
3
|
class << self
|
4
4
|
# Find gems that start with "sunzi-*" and require them automatically.
|
5
|
-
# If that gem is a plugin, it will call the register method on load.
|
6
5
|
|
7
6
|
def load
|
8
7
|
plugins = Gem::Specification.find_all.select{|plugin| plugin.name =~ /sunzi-.+/ }
|
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 = '2.
|
5
|
+
spec.version = '2.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.summary = %q{Server provisioning utility for minimalists}
|
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: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenn Ejima
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: '0'
|
150
150
|
requirements: []
|
151
151
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.
|
152
|
+
rubygems_version: 2.6.14
|
153
153
|
signing_key:
|
154
154
|
specification_version: 4
|
155
155
|
summary: Server provisioning utility for minimalists
|