jisota 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -1
- data/README.md +38 -3
- data/Rakefile +18 -1
- data/jisota.gemspec +2 -2
- data/lib/jisota/package.rb +28 -3
- data/lib/jisota/package_script.rb +19 -9
- data/lib/jisota/packages/nginx.rb +25 -0
- data/lib/jisota/packages/nginx_passenger.rb +9 -10
- data/lib/jisota/packages/ruby.rb +3 -1
- data/lib/jisota/version.rb +1 -1
- data/spec/lib/jisota/package_spec.rb +42 -18
- data/spec/spec_helper.rb +5 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a9b6fbe8f6f04bd26ea84192e789ec977a30b28
|
4
|
+
data.tar.gz: 5ea5c9239da6eb97a9da00f1cf4123e86fe05f2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bb3c31c918cf9ab2a17196a6a64ec2ce60dc58c1c69d28148beef395a969253bf80ee0ce795c0fc228b47d10071cf2dfe4069cfed8d4e0344211a88d6451c4a
|
7
|
+
data.tar.gz: e6d0b2c5023dc125dbb1413b07802f3d9e1dd5ccdaf8c3404e4c7ef3c11d7f1c0067b0668f33819a4ad354181f72caa00a458101a3bdd529c28344798727ccaf
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
# Jisota changelog
|
2
2
|
|
3
|
-
## 0.0.
|
3
|
+
## 0.0.3 (current)
|
4
|
+
|
5
|
+
### Features
|
6
|
+
* Packages can have multiple sections of run and verify blocks
|
7
|
+
|
8
|
+
### Improvements
|
9
|
+
* Rake tasks for vagrant
|
10
|
+
* Better acceptance test runner
|
11
|
+
* Ruby package also installs bundler gem
|
12
|
+
|
13
|
+
### New packages
|
14
|
+
* nginx
|
15
|
+
|
16
|
+
|
17
|
+
## 0.0.2
|
4
18
|
|
5
19
|
### Features
|
6
20
|
* Create and Update actions on file upload
|
@@ -17,5 +31,6 @@
|
|
17
31
|
* gem_install
|
18
32
|
* nginx_passenger
|
19
33
|
|
34
|
+
|
20
35
|
## 0.0.1
|
21
36
|
Initial version with basic functionality
|
data/README.md
CHANGED
@@ -83,6 +83,36 @@ the params section below.
|
|
83
83
|
Inside a run-block, packages can be called by their name, somewhat like a Ruby
|
84
84
|
method. See the `apt` example above.
|
85
85
|
|
86
|
+
### Having multiple run and verify blocks
|
87
|
+
|
88
|
+
Sometimes you need to verify only parts of the package. Just specify multiple
|
89
|
+
run and verify blocks:
|
90
|
+
|
91
|
+
package :install_awesome_service do
|
92
|
+
description "Installs a service and starts it"
|
93
|
+
|
94
|
+
run { cmd "sudo apt-get install awesome-service" }
|
95
|
+
verify { cmd "command-to-tell-if-service-is-installed" }
|
96
|
+
|
97
|
+
run { cmd "sudo service awesome start" }
|
98
|
+
verify { cmd "command-to-tell-if-service-is-started" }
|
99
|
+
end
|
100
|
+
|
101
|
+
You can optionally name each of these sections to give a more precise output:
|
102
|
+
|
103
|
+
package :install_awesome_service do
|
104
|
+
description "Installs a service and starts it"
|
105
|
+
|
106
|
+
section "Install the service from apt-get"
|
107
|
+
run { cmd "sudo apt-get install awesome-service" }
|
108
|
+
verify { cmd "command-to-tell-if-service-is-installed" }
|
109
|
+
|
110
|
+
section "Start the service"
|
111
|
+
run { cmd "sudo service awesome start" }
|
112
|
+
verify { cmd "command-to-tell-if-service-is-started" }
|
113
|
+
end
|
114
|
+
|
115
|
+
|
86
116
|
### Defining packages to be used in more than one project
|
87
117
|
|
88
118
|
Defining packages with `Jisota.config` as above will only add the package to
|
@@ -233,6 +263,11 @@ You can also use package params and call packages inside these blocks:
|
|
233
263
|
description "Install nginx with passenger module"
|
234
264
|
param :config_file, required: true
|
235
265
|
|
266
|
+
### nginx
|
267
|
+
|
268
|
+
description "Install nginx from apt"
|
269
|
+
param :config_file
|
270
|
+
|
236
271
|
### More packages?
|
237
272
|
|
238
273
|
Jisota is a young gem. Please contribute with any packages that you think
|
@@ -333,7 +368,7 @@ a near-real environment that is easy to destroy and rebuild.
|
|
333
368
|
|
334
369
|
Start the vagrant:
|
335
370
|
|
336
|
-
$
|
371
|
+
$ rake vagrant:up
|
337
372
|
|
338
373
|
Then run acceptance specs
|
339
374
|
|
@@ -341,11 +376,11 @@ Then run acceptance specs
|
|
341
376
|
|
342
377
|
Or run individual specs. Some of them might take a while:
|
343
378
|
|
344
|
-
$ rspec
|
379
|
+
$ ACCEPTANCE=1 rspec spec/acceptance/some_spec.rb
|
345
380
|
|
346
381
|
To kill vagrant and start with a fresh machine:
|
347
382
|
|
348
|
-
$
|
383
|
+
$ rake vagrant:rebuild
|
349
384
|
|
350
385
|
## Contributing
|
351
386
|
|
data/Rakefile
CHANGED
@@ -4,7 +4,24 @@ require 'rspec/core/rake_task'
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec)
|
5
5
|
namespace :spec do
|
6
6
|
RSpec::Core::RakeTask.new(:acceptance) do |config|
|
7
|
-
|
7
|
+
ENV["ACCEPTANCE"] = "Oh_yeah"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
namespace :vagrant do
|
12
|
+
desc "Starts the vagrant VM"
|
13
|
+
task :up do
|
14
|
+
system "(cd spec/vagrant && vagrant up)"
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Destroys and starts the vagrant VM"
|
18
|
+
task :rebuild do
|
19
|
+
system '(cd spec/vagrant && vagrant destroy --force && vagrant up)'
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Shuts dows the vagrant VM"
|
23
|
+
task :halt do
|
24
|
+
system "(cd spec/vagrant && vagrant halt)"
|
8
25
|
end
|
9
26
|
end
|
10
27
|
|
data/jisota.gemspec
CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "net-ssh", "~> 2.8
|
22
|
-
spec.add_dependency "net-scp", "~> 1.
|
21
|
+
spec.add_dependency "net-ssh", "~> 2.8"
|
22
|
+
spec.add_dependency "net-scp", "~> 1.2"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.5"
|
25
25
|
spec.add_development_dependency "rake"
|
data/lib/jisota/package.rb
CHANGED
@@ -1,15 +1,22 @@
|
|
1
1
|
module Jisota
|
2
2
|
class Package
|
3
|
-
attr_accessor :name, :description, :params, :
|
3
|
+
attr_accessor :name, :description, :params, :sections
|
4
4
|
|
5
5
|
def initialize(name = nil, &block)
|
6
6
|
@params = []
|
7
|
+
@sections = []
|
7
8
|
@name = name
|
8
9
|
DSL.new(self).evaluate(&block) if block_given?
|
9
10
|
end
|
10
11
|
|
11
12
|
alias_method :key, :name
|
12
13
|
|
14
|
+
class InvalidBlockOrder < StandardError; end
|
15
|
+
|
16
|
+
class Section
|
17
|
+
attr_accessor :description, :run_block, :verify_block
|
18
|
+
end
|
19
|
+
|
13
20
|
class DSL < DSLBase
|
14
21
|
def initialize(target)
|
15
22
|
@target = target
|
@@ -23,12 +30,30 @@ module Jisota
|
|
23
30
|
@target.params << Param.new(name, options)
|
24
31
|
end
|
25
32
|
|
33
|
+
def section(description)
|
34
|
+
@target.sections << Section.new.tap do |section|
|
35
|
+
section.description = description
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
26
39
|
def run(&block)
|
27
|
-
|
40
|
+
run_block = ScriptBlock.new(&block)
|
41
|
+
section = @target.sections.last
|
42
|
+
if section && section.run_block.nil?
|
43
|
+
section.run_block = run_block
|
44
|
+
else
|
45
|
+
@target.sections << Section.new.tap do |new_section|
|
46
|
+
new_section.run_block = run_block
|
47
|
+
end
|
48
|
+
end
|
28
49
|
end
|
29
50
|
|
30
51
|
def verify(&block)
|
31
|
-
|
52
|
+
section = @target.sections.last
|
53
|
+
if section.nil? || section.verify_block
|
54
|
+
raise InvalidBlockOrder, "A verify block must come after a run block"
|
55
|
+
end
|
56
|
+
section.verify_block = ScriptBlock.new(&block)
|
32
57
|
end
|
33
58
|
end
|
34
59
|
end
|
@@ -18,7 +18,7 @@ module Jisota
|
|
18
18
|
def execute(context)
|
19
19
|
context.param_scope(parse_params) do
|
20
20
|
context.logger.system_message("Package #{self}") do
|
21
|
-
|
21
|
+
execute_package(context)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -39,23 +39,33 @@ module Jisota
|
|
39
39
|
ParamParser.new(package.params, args).parse
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
43
|
-
|
44
|
-
|
42
|
+
def execute_package(context)
|
43
|
+
package.sections.each do |section|
|
44
|
+
context.logger.system_message("Section #{section.description}") do
|
45
|
+
result = execute_section(section, context)
|
46
|
+
return false unless result
|
47
|
+
end
|
48
|
+
end
|
49
|
+
true
|
50
|
+
end
|
51
|
+
|
52
|
+
def execute_section(section, context)
|
53
|
+
if section.verify_block
|
54
|
+
verify_script = section.verify_block.evaluate(context)
|
45
55
|
result = verify_script.execute(context)
|
46
56
|
if result
|
47
|
-
context.logger.system_message("
|
57
|
+
context.logger.system_message("Section #{section.description} already installed")
|
48
58
|
true
|
49
59
|
else
|
50
|
-
execute_run(context)
|
60
|
+
execute_run(section, context)
|
51
61
|
end
|
52
62
|
else
|
53
|
-
execute_run(context)
|
63
|
+
execute_run(section, context)
|
54
64
|
end
|
55
65
|
end
|
56
66
|
|
57
|
-
def execute_run(context)
|
58
|
-
run_script =
|
67
|
+
def execute_run(section, context)
|
68
|
+
run_script = section.run_block.evaluate(context)
|
59
69
|
run_script.execute(context)
|
60
70
|
end
|
61
71
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'jisota'
|
2
|
+
|
3
|
+
Jisota.global_config do
|
4
|
+
package :nginx do
|
5
|
+
description "Install nginx from apt"
|
6
|
+
param :config_file
|
7
|
+
|
8
|
+
section "Install nginx aåt package"
|
9
|
+
run { apt :nginx }
|
10
|
+
|
11
|
+
section "Files"
|
12
|
+
run do
|
13
|
+
if config_file
|
14
|
+
upload from: config_file, to: '/etc/nginx/nginx.conf' do
|
15
|
+
update { cmd "sudo service nginx restart || true" }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
section "Start nginx"
|
21
|
+
run { cmd "sudo service nginx start" }
|
22
|
+
verify { cmd "ps -C nginx" }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -5,11 +5,18 @@ Jisota.global_config do
|
|
5
5
|
description "Install nginx with passenger module"
|
6
6
|
param :config_file, required: true
|
7
7
|
|
8
|
+
section "Prerequisites"
|
8
9
|
run do
|
9
10
|
gem_install :passenger
|
10
11
|
apt "libcurl4-openssl-dev"
|
11
|
-
|
12
|
+
end
|
13
|
+
|
14
|
+
section "Install nginx with passenger"
|
15
|
+
run { cmd 'sudo passenger-install-nginx-module --auto --auto-download --prefix=/opt/nginx' }
|
16
|
+
verify { cmd 'which /opt/nginx/sbin/nginx' }
|
12
17
|
|
18
|
+
section "Files"
|
19
|
+
run do
|
13
20
|
upload from: config_file, to: '/opt/nginx/conf/nginx.conf' do
|
14
21
|
update { cmd "sudo service nginx restart" }
|
15
22
|
end
|
@@ -17,17 +24,9 @@ Jisota.global_config do
|
|
17
24
|
upload from: "package_files/nginx_passenger/nginx_service", to: "/etc/init.d/nginx" do
|
18
25
|
create { cmd 'sudo update-rc.d nginx defaults 99' }
|
19
26
|
end
|
20
|
-
|
21
|
-
nginx_passenger_start
|
22
27
|
end
|
23
|
-
end
|
24
|
-
|
25
|
-
package :nginx_passenger_install do
|
26
|
-
run { cmd 'sudo passenger-install-nginx-module --auto --auto-download --prefix=/opt/nginx' }
|
27
|
-
verify { cmd 'which /opt/nginx/sbin/nginx' }
|
28
|
-
end
|
29
28
|
|
30
|
-
|
29
|
+
section "Start nginx"
|
31
30
|
run { cmd "sudo service nginx start" }
|
32
31
|
verify { cmd "ps -C nginx" }
|
33
32
|
end
|
data/lib/jisota/packages/ruby.rb
CHANGED
data/lib/jisota/version.rb
CHANGED
@@ -31,28 +31,13 @@ module Jisota
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
describe "#run_block" do
|
35
|
-
it "has one" do
|
36
|
-
package = Package.new
|
37
|
-
package.run_block = :foo
|
38
|
-
expect(package.run_block).to eq(:foo)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "#verify_block" do
|
43
|
-
it "has one" do
|
44
|
-
package = Package.new
|
45
|
-
package.verify_block = :foo
|
46
|
-
expect(package.verify_block).to eq(:foo)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
34
|
describe Package::DSL do
|
51
35
|
it "initializes using DSL" do
|
52
36
|
package = Package.new(:my_awesome_package) do
|
53
37
|
description "Does cool stuff"
|
54
38
|
param :foo
|
55
39
|
param :bar, default: 42
|
40
|
+
|
56
41
|
run { cmd "touch #{foo}" }
|
57
42
|
verify { cmd "[ -f foo ]" }
|
58
43
|
end
|
@@ -62,8 +47,47 @@ module Jisota
|
|
62
47
|
expect(package.params.size).to eq(2)
|
63
48
|
expect(package.params.last.name).to eq(:bar)
|
64
49
|
expect(package.params.last.options).to eq({ default: 42 })
|
65
|
-
expect(package.
|
66
|
-
expect(package.
|
50
|
+
expect(package.sections.size).to eq(1)
|
51
|
+
expect(package.sections.first.run_block).to be_a(ScriptBlock)
|
52
|
+
expect(package.sections.first.verify_block).to be_a(ScriptBlock)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "has many run and verify blocks" do
|
56
|
+
package = Package.new(:something) do
|
57
|
+
run { cmd "touch foo" }
|
58
|
+
verify { cmd "[ -f foo ]" }
|
59
|
+
|
60
|
+
run { cmd "touch bar" }
|
61
|
+
|
62
|
+
run { cmd "touch baz" }
|
63
|
+
verify { cmd "[ -f baz ]" }
|
64
|
+
end
|
65
|
+
|
66
|
+
expect(package.sections.size).to eq(3)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "must have a run block per verify block" do
|
70
|
+
expect {
|
71
|
+
package = Package.new { verify { } }
|
72
|
+
}.to raise_exception(Package::InvalidBlockOrder)
|
73
|
+
|
74
|
+
expect {
|
75
|
+
package = Package.new do
|
76
|
+
run { }
|
77
|
+
verify { }
|
78
|
+
verify { }
|
79
|
+
end
|
80
|
+
}.to raise_exception(Package::InvalidBlockOrder)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "accepts section names" do
|
84
|
+
package = Package.new(:foo) do
|
85
|
+
section "do amazing stuff"
|
86
|
+
run {}
|
87
|
+
end
|
88
|
+
|
89
|
+
expect(package.sections.size).to eq(1)
|
90
|
+
expect(package.sections.first.description).to eq("do amazing stuff")
|
67
91
|
end
|
68
92
|
end
|
69
93
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -13,7 +13,11 @@ require './spec/support/acceptance_helpers'
|
|
13
13
|
|
14
14
|
RSpec.configure do |config|
|
15
15
|
config.filter_run :focus
|
16
|
-
|
16
|
+
if ENV["ACCEPTANCE"]
|
17
|
+
config.filter_run type: :acceptance
|
18
|
+
else
|
19
|
+
config.filter_run_excluding type: :acceptance
|
20
|
+
end
|
17
21
|
config.run_all_when_everything_filtered = true
|
18
22
|
|
19
23
|
config.order = :random
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jisota
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lasse Skindstad Ebert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.8
|
19
|
+
version: '2.8'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.8
|
26
|
+
version: '2.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: net-scp
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: '1.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: '1.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- lib/jisota/package_script.rb
|
169
169
|
- lib/jisota/packages/apt.rb
|
170
170
|
- lib/jisota/packages/gem_install.rb
|
171
|
+
- lib/jisota/packages/nginx.rb
|
171
172
|
- lib/jisota/packages/nginx_passenger.rb
|
172
173
|
- lib/jisota/packages/ruby.rb
|
173
174
|
- lib/jisota/param.rb
|
@@ -266,4 +267,3 @@ test_files:
|
|
266
267
|
- spec/test_files/nginx_default.conf
|
267
268
|
- spec/vagrant/Vagrantfile
|
268
269
|
- spec/vagrant/ssh_key
|
269
|
-
has_rdoc:
|