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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 7c118fcfb05d687e587068fea6079f6e365ffbf637ef0a4f73dbd1920dc8f138
4
- data.tar.gz: 251b57a131bd76db42637bdcd0dad5b373b1a37e964680f5fde2531ff995b768
2
+ SHA1:
3
+ metadata.gz: ae08190a203a96afbc856240713e37d197d97381
4
+ data.tar.gz: 4afc33d68da0dc9758c87b0d2f10a6a5edb10f17
5
5
  SHA512:
6
- metadata.gz: 19c134eda8a7b0b53570ad335e79b019daa553ae46cb5f554bc80f2157ac11e10e04e51f0c6444d249d6b97f14aa806a85a7c78a11e555eddccb849fd320666b
7
- data.tar.gz: be46e99817efb6b0a8e85c5b562297b1b755c3a552ff4977039e70bf672aea636b6fc9cc4e81520120c82f5267e3ff2ba249aed0f061dae9fa4b9adcc48ee1c4
6
+ metadata.gz: 74efe9a99bf9579337169c780f7891cd88a1b25aa167bff4a45ca1c994d3e20d6046933beeb9cdb7bf1c1bc6d5a6ebf906336031dbd63ceb6342183f270ccf83
7
+ data.tar.gz: 065bcc712a06c87d7c488463a145f45c4ea66009c91781f2044aaa2113d94c28f6f84a90fb72e689dcddbffa76486f717e2d89412ac052ea2f38d36a3b793d1a
data/.gitignore CHANGED
@@ -1,5 +1,4 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
5
- sandbox
1
+ /.bundle/
2
+ /pkg/
3
+ /tmp/
4
+ /Gemfile.lock
@@ -1,4 +1,4 @@
1
- ## 2.0, release 2018-01
1
+ ## 2.0, release 2018-01-14
2
2
  * Plug-in support for commands.
3
3
  * Separate "setup" and "teardown" commands for VPS into the "sunzi-vps" gem as a plugin.
4
4
  * "attributes" are now "vars" in sunzi.yml and shell scripts.
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
data/README.md CHANGED
@@ -1,20 +1,30 @@
1
1
  Sunzi
2
2
  =====
3
3
 
4
+ [![Build Status](https://secure.travis-ci.org/kenn/sunzi.png)](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 [server provisioning](http://en.wikipedia.org/wiki/Provisioning#Server_provisioning) utility designed for mere mortals. If Chef or Puppet is driving you nuts, try Sunzi!
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
- * **Focus on 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 understand what you are really doing.
16
- * **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
- * **Minimum dependencies.** No configuration server required. You don't even need a Ruby runtime on the remote server.
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
- $ [sudo] gem install sunzi
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.github.com/kenn/sunzi-recipes/master/ruby/rvm.sh
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/test*.rb']
7
- t.verbose = true
6
+ t.test_files = FileList['test/**/*_test.rb']
8
7
  end
8
+
9
9
  task :default => :test
@@ -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(first, *args)
14
- Sunzi::Command.new.deploy(first, *args)
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'
@@ -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, :options
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(first, *args)
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 = Dir['{recipes,roles,files}/**/*'].select { |file| File.file?(file) }
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 ||= begin
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
@@ -28,7 +28,7 @@ module Sunzi
28
28
  else
29
29
  'install'
30
30
  end
31
- text = ERB.new(base.join("#{which}.erb").read, nil, '-').result(binding)
31
+ text = ERB.new(base.join("#{which}.erb").read).result(binding)
32
32
  abort_with text
33
33
  end
34
34
  end
@@ -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-.+/ }
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'sunzi'
5
- spec.version = '2.0.0' # retrieve this value by: Gem.loaded_specs['sunzi'].version.to_s
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.0.0
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-14 00:00:00.000000000 Z
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.7.3
152
+ rubygems_version: 2.6.14
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: Server provisioning utility for minimalists