dployr 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +60 -23
- data/lib/dployr/cli.rb +1 -0
- data/lib/dployr/commands/config.rb +21 -13
- data/lib/dployr/compute/aws.rb +33 -32
- data/lib/dployr/compute/common.rb +28 -0
- data/lib/dployr/compute/gce.rb +24 -13
- data/lib/dployr/configuration.rb +19 -4
- data/lib/dployr/version.rb +1 -1
- data/spec/commands_config_spec.rb +83 -0
- data/spec/configuration_spec.rb +14 -2
- data/spec/fixtures/basic/Dployrfile.yml +41 -0
- data/spec/fixtures/{config → german}/Dployrfile.yml +5 -11
- data/spec/fixtures/hello/createExecUser.sh +18 -0
- data/spec/fixtures/hello/jetty +562 -0
- data/spec/fixtures/hello/jetty.sh +28 -0
- metadata +18 -7
- /data/spec/fixtures/{config/hello → hello}/hello.sh +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55e8744de1ada22c752a30e73a533774383b957a
|
4
|
+
data.tar.gz: 71bd763bd9e8de49200a57c9622f6c142de98aec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59247fbc73d154f5d8535adbc1e20584be2e5e243764260e033482f09b12f73f29513b7f2887f7676d5bd1706a733237c9257aed82533f5cf22aa4db00c4f1fc
|
7
|
+
data.tar.gz: 964b34cf57543d3db61b460147d920b539ac7e40202dd5194488354fd21e8f3d29842d1038910b4602bbe0e719fe71a1767265a6f00d7fcc92839e798c5721c6
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
> Multicloud management and deployment made simple
|
4
4
|
|
5
|
-
> **Spoiler! Alpha project.
|
5
|
+
> **Spoiler! Alpha project. Use it by your own risk**
|
6
6
|
|
7
7
|
<table>
|
8
8
|
<tr>
|
@@ -18,8 +18,8 @@
|
|
18
18
|
**Dployr** is a Ruby utility that simplifies cloud management
|
19
19
|
and deployment across different providers
|
20
20
|
|
21
|
-
You can configure your infraestructure and deployment from a
|
22
|
-
|
21
|
+
You can configure your infraestructure and deployment from a
|
22
|
+
simple configuration file which support built-in rich features
|
23
23
|
|
24
24
|
Dployr only works in Ruby >= `1.9.x`
|
25
25
|
|
@@ -29,12 +29,13 @@ Dployr only works in Ruby >= `1.9.x`
|
|
29
29
|
$ gem install dployr
|
30
30
|
```
|
31
31
|
|
32
|
-
|
32
|
+
If you need to use it from another Ruby package,
|
33
|
+
add it as dependency in your `Gemfile` or `.gemspec` file
|
33
34
|
```ruby
|
34
35
|
# gemspec
|
35
|
-
spec.add_dependency 'dployr', '>= 0.0.
|
36
|
+
spec.add_dependency 'dployr', '>= 0.0.3'
|
36
37
|
# Gemfile
|
37
|
-
gem 'dployr', '>= 0.0.
|
38
|
+
gem 'dployr', '>= 0.0.3'
|
38
39
|
```
|
39
40
|
|
40
41
|
## Documentation
|
@@ -43,7 +44,18 @@ Dployr documentation and API is available from [RubyDoc][rubydoc]
|
|
43
44
|
|
44
45
|
## Features
|
45
46
|
|
46
|
-
|
47
|
+
- Fully configurable from Ruby or YAML file with rich features like templating
|
48
|
+
- Supports deployment to multiple providers
|
49
|
+
- Built-in support for defailted instances configuration
|
50
|
+
- Local and remote scripts execution per stage phase (start, test, provision, update, stop...)
|
51
|
+
- Featured command-line and programmatic API
|
52
|
+
|
53
|
+
## Supported providers
|
54
|
+
|
55
|
+
Note that as Dployr is still in alpha stage, there are only a few providers supported
|
56
|
+
|
57
|
+
- Amazon Web Services (`aws`)
|
58
|
+
- Google Compute Engine (`gce`)
|
47
59
|
|
48
60
|
## Configuration
|
49
61
|
|
@@ -76,9 +88,15 @@ Notation: `%{attribute-name}`
|
|
76
88
|
|
77
89
|
##### Iteration context variables
|
78
90
|
|
79
|
-
You can
|
91
|
+
You can use references from config strings to specific iteration context values
|
80
92
|
|
81
|
-
Notation: `${
|
93
|
+
Notation: `${value}`
|
94
|
+
|
95
|
+
Supported values:
|
96
|
+
|
97
|
+
- **provider** - Current context provider name identifier
|
98
|
+
- **region** - Current context region name identifier
|
99
|
+
- **name** - Current context template name identifier
|
82
100
|
|
83
101
|
##### Environment variables
|
84
102
|
|
@@ -140,7 +158,6 @@ default:
|
|
140
158
|
args: "%{name}"
|
141
159
|
path: ./scripts/updatedns.sh
|
142
160
|
|
143
|
-
|
144
161
|
custom:
|
145
162
|
name: 1
|
146
163
|
web-server:
|
@@ -159,23 +176,26 @@ custom:
|
|
159
176
|
attributes:
|
160
177
|
instance_type: m1.large
|
161
178
|
scripts:
|
162
|
-
|
179
|
+
pre-start:
|
163
180
|
-
|
164
181
|
args:
|
165
182
|
- "%{name}"
|
166
183
|
- "%{type}"
|
167
184
|
- "%{domain}"
|
168
|
-
path: ./scripts
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
185
|
+
path: ./scripts/pre-start.sh
|
186
|
+
start:
|
187
|
+
-
|
188
|
+
args:
|
189
|
+
- "%{hydra}"
|
190
|
+
path: ./scripts/configure.sh
|
191
|
+
provision:
|
192
|
+
-
|
193
|
+
args:
|
194
|
+
- "%{$provider}-%{region}"
|
195
|
+
- "%{type}"
|
196
|
+
path: ./scripts/provision.sh
|
197
|
+
test:
|
198
|
+
- path: ./scripts/serverspec.sh
|
179
199
|
```
|
180
200
|
|
181
201
|
## Command-line interface
|
@@ -194,18 +214,35 @@ Commands
|
|
194
214
|
provision instance provisioning
|
195
215
|
config generate configuration in YAML from Dployrfile
|
196
216
|
execute run custom stages
|
217
|
+
ssh ssh into machine
|
197
218
|
init create a sample Dployrfile
|
198
219
|
|
199
220
|
Options
|
200
221
|
|
201
222
|
-n, --name NAME template name identifier to load
|
202
223
|
-f, --file PATH custom config file path to load
|
203
|
-
-a, --attributes ATTRS aditional attributes to pass to the configuration in matrix query
|
224
|
+
-a, --attributes ATTRS aditional attributes to pass to the configuration in matrix query
|
204
225
|
-p, --provider VALUES provider to use (allow multiple values comma-separated)
|
205
226
|
-r, --region REGION region to use (allow multiple values comma-separated)
|
206
227
|
-v, -V, --version version
|
207
228
|
-h, --help help
|
229
|
+
```
|
208
230
|
|
231
|
+
### Examples
|
232
|
+
|
233
|
+
Start a new instance. If it don't exists, it will be created
|
234
|
+
```bash
|
235
|
+
$ dployr start -n name -p aws -r eu-west-1 -a 'env=dev'
|
236
|
+
```
|
237
|
+
|
238
|
+
Provision an existent working instance
|
239
|
+
```bash
|
240
|
+
$ dployr provision -n name -p aws -r eu-west-1 -a 'env=dev'
|
241
|
+
```
|
242
|
+
|
243
|
+
Test a working instance
|
244
|
+
```bash
|
245
|
+
$ dployr test -n name -p aws -r eu-west-1 -a 'env=dev'
|
209
246
|
```
|
210
247
|
|
211
248
|
## Programmatic API
|
data/lib/dployr/cli.rb
CHANGED
@@ -15,24 +15,32 @@ module Dployr
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
private
|
19
|
+
|
18
20
|
def render_file
|
19
21
|
raise "Dployrfile was not found" if @dployr.file_path.nil?
|
20
22
|
raise "Configuration is missing" unless @dployr.config.exists?
|
23
|
+
|
21
24
|
begin
|
22
|
-
|
23
|
-
config = get_region_config options
|
24
|
-
elsif @name
|
25
|
-
config = @dployr.config.get_config @name, @attrs
|
26
|
-
else
|
27
|
-
config = @dployr.config.get_config_all @attrs
|
28
|
-
end
|
29
|
-
unless config.nil?
|
30
|
-
puts config.to_yaml
|
31
|
-
else
|
32
|
-
@log.info "Missing configuration data"
|
33
|
-
end
|
25
|
+
print_config
|
34
26
|
rescue Exception => e
|
35
|
-
|
27
|
+
puts "Cannot generate the config: #{e}"
|
28
|
+
exit 1
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def print_config
|
33
|
+
if @name and @options[:provider] and @options[:region]
|
34
|
+
config = get_region_config @options
|
35
|
+
elsif @name
|
36
|
+
config = @dployr.config.get_config @name, @attrs
|
37
|
+
else
|
38
|
+
config = @dployr.config.get_config_all @attrs
|
39
|
+
end
|
40
|
+
unless config.nil?
|
41
|
+
puts config.to_yaml
|
42
|
+
else
|
43
|
+
raise "Missing configuration data"
|
36
44
|
end
|
37
45
|
end
|
38
46
|
|
data/lib/dployr/compute/aws.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'fog'
|
2
|
-
require '
|
2
|
+
require 'dployr/compute/common'
|
3
3
|
|
4
4
|
module Dployr
|
5
5
|
module Compute
|
6
6
|
class AWS
|
7
|
-
|
7
|
+
|
8
|
+
include Dployr::Compute::Common
|
9
|
+
|
8
10
|
def initialize(region)
|
9
11
|
@options = {
|
10
12
|
region: region[0..-2],
|
@@ -15,16 +17,6 @@ module Dployr
|
|
15
17
|
@compute = Fog::Compute.new @options
|
16
18
|
end
|
17
19
|
|
18
|
-
def get_instance(name, states)
|
19
|
-
servers = @compute.servers.all
|
20
|
-
servers.each do |instance|
|
21
|
-
if instance.tags["Name"] == name and states.include? instance.state
|
22
|
-
return instance
|
23
|
-
end
|
24
|
-
end
|
25
|
-
nil
|
26
|
-
end
|
27
|
-
|
28
20
|
def get_ip(name)
|
29
21
|
instance = get_instance(name, ["running"])
|
30
22
|
instance.private_ip_address if instance
|
@@ -63,36 +55,45 @@ module Dployr
|
|
63
55
|
subnet_id: attributes["subnet_id"],
|
64
56
|
security_group_ids: attributes["security_groups"],
|
65
57
|
tags: { Name: attributes["name"] }
|
66
|
-
#private_ip_address : private_ip_address,
|
67
|
-
#user_data : user_data,
|
68
|
-
#elastic_ip : elastic_ip,
|
69
|
-
#allocate_elastic_ip : allocate_elastic_ip,
|
70
|
-
#block_device_mapping : block_device_mapping,
|
71
|
-
#instance_initiated_shutdown_behavior : terminate_on_shutdown == true ? "terminate" : nil,
|
72
|
-
#monitoring : monitoring,
|
73
|
-
#ebs_optimized : ebs_optimized
|
74
58
|
}
|
75
59
|
puts options.to_yaml
|
76
60
|
server = @compute.servers.create(options)
|
77
61
|
end
|
78
62
|
print "Wait for instance to get online".yellow
|
79
63
|
server.wait_for { print ".".yellow; ready? }
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
64
|
+
print "\n"
|
65
|
+
elastic_ip(attributes, server)
|
66
|
+
wait_ssh(attributes, server)
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def get_instance(name, states)
|
72
|
+
servers = @compute.servers.all
|
73
|
+
servers.each do |instance|
|
74
|
+
if instance.tags["Name"] == name and states.include? instance.state
|
75
|
+
return instance
|
91
76
|
end
|
92
77
|
end
|
93
|
-
print "\n"
|
94
78
|
nil
|
95
79
|
end
|
80
|
+
|
81
|
+
def elastic_ip(attributes, server)
|
82
|
+
if attributes["public_ip"]
|
83
|
+
if attributes["public_ip"] == "new"
|
84
|
+
puts "Creating new elastic ip...".yellow
|
85
|
+
response = @compute.allocate_address(server.vpc_id)
|
86
|
+
allocation_id = response[:body]["allocationId"]
|
87
|
+
attributes["public_ip"] = response[:body]["publicIp"]
|
88
|
+
else
|
89
|
+
puts "Looking for elastic ip #{attributes["public_ip"]}...".yellow
|
90
|
+
eip = @compute.addresses.get(attributes["public_ip"])
|
91
|
+
allocation_id = eip.allocation_id
|
92
|
+
end
|
93
|
+
puts "Associating elastic ip #{attributes["public_ip"]}...".yellow
|
94
|
+
@compute.associate_address(server.id,nil,nil,allocation_id)
|
95
|
+
end
|
96
|
+
end
|
96
97
|
|
97
98
|
end
|
98
99
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'net/ssh'
|
2
|
+
|
3
|
+
module Dployr
|
4
|
+
module Compute
|
5
|
+
module Common
|
6
|
+
|
7
|
+
module_function
|
8
|
+
|
9
|
+
def wait_ssh(attributes, server)
|
10
|
+
print "Wait for ssh to get ready...".yellow
|
11
|
+
while true
|
12
|
+
begin
|
13
|
+
Net::SSH.start(server.private_ip_address, attributes["username"], :keys => attributes["private_key_path"]) do |ssh|
|
14
|
+
print "\n"
|
15
|
+
return server.private_ip_address
|
16
|
+
end
|
17
|
+
rescue Exception => e
|
18
|
+
print ".".yellow
|
19
|
+
sleep 2
|
20
|
+
end
|
21
|
+
end
|
22
|
+
print "\n"
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/dployr/compute/gce.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'fog'
|
2
|
-
require '
|
2
|
+
require 'dployr/compute/common'
|
3
3
|
|
4
4
|
module Dployr
|
5
5
|
module Compute
|
6
6
|
class GCE
|
7
7
|
|
8
|
+
include Dployr::Compute::Common
|
9
|
+
|
8
10
|
def initialize(region)
|
9
11
|
@options = {
|
10
12
|
provider: 'Google',
|
@@ -85,11 +87,13 @@ module Dployr
|
|
85
87
|
end
|
86
88
|
|
87
89
|
def start(attributes, region)
|
90
|
+
external_ip(attributes, region)
|
88
91
|
server = get_instance(attributes["name"], ["stopped", "stopping"])
|
89
92
|
if server
|
90
93
|
puts "Starting stopped instance for #{attributes["name"]} in #{region}...".yellow
|
91
94
|
server.start
|
92
95
|
else
|
96
|
+
puts "Creating boot disk...".yellow
|
93
97
|
disks = create_disk(attributes["name"], 10, region, attributes["image_name"])
|
94
98
|
if defined? attributes["autodelete_disk"]
|
95
99
|
autodelete_disk = attributes["autodelete_disk"]
|
@@ -105,6 +109,7 @@ module Dployr
|
|
105
109
|
machine_type: attributes["instance_type"],
|
106
110
|
network: attributes["network"],
|
107
111
|
disks: [disks.get_as_boot_disk(true, autodelete_disk)],
|
112
|
+
external_ip: attributes["public_ip"]
|
108
113
|
}
|
109
114
|
|
110
115
|
puts options.to_yaml
|
@@ -112,21 +117,27 @@ module Dployr
|
|
112
117
|
end
|
113
118
|
print "Wait for instance to get online".yellow
|
114
119
|
server.wait_for { print ".".yellow; ready? }
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
120
|
+
print "\n"
|
121
|
+
wait_ssh(attributes, server)
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
def external_ip(attributes, region)
|
127
|
+
if attributes["public_ip"] == "new"
|
128
|
+
puts "Looking for previous public_ip...".yellow
|
129
|
+
ip = @compute.insert_address(attributes["name"], region[0..-3])
|
130
|
+
while true
|
131
|
+
ip = @compute.get_address(attributes["name"], region[0..-3])
|
132
|
+
if ip[:body]["address"]
|
133
|
+
attributes["public_ip"].replace ip[:body]["address"]
|
134
|
+
puts "Using public_ip #{attributes["public_ip"]}".yellow
|
135
|
+
break
|
122
136
|
end
|
123
|
-
|
124
|
-
|
125
|
-
sleep 2
|
137
|
+
puts "Waiting for ip to be ready...".yellow
|
138
|
+
sleep 1
|
126
139
|
end
|
127
140
|
end
|
128
|
-
print "\n"
|
129
|
-
return nil
|
130
141
|
end
|
131
142
|
|
132
143
|
end
|
data/lib/dployr/configuration.rb
CHANGED
@@ -37,8 +37,8 @@ module Dployr
|
|
37
37
|
def get_config(name, attributes = {})
|
38
38
|
instance = get_instance name
|
39
39
|
attributes = @attributes.merge (attributes or {})
|
40
|
-
raise
|
41
|
-
|
40
|
+
raise Error.new "Instance '#{name.to_s}' do not exists" if instance.nil?
|
41
|
+
render_config name, instance, attributes
|
42
42
|
end
|
43
43
|
|
44
44
|
def get_config_all(attributes = {})
|
@@ -74,6 +74,18 @@ module Dployr
|
|
74
74
|
|
75
75
|
private
|
76
76
|
|
77
|
+
def render_config(name, instance, attributes)
|
78
|
+
attributes = replace_variables attributes
|
79
|
+
config = merge_config instance, attributes
|
80
|
+
config = replace_name name, config
|
81
|
+
config = replace_variables config, attributes
|
82
|
+
config
|
83
|
+
end
|
84
|
+
|
85
|
+
def replace_name(name, config)
|
86
|
+
replace_keywords 'name', name, config
|
87
|
+
end
|
88
|
+
|
77
89
|
def create_instance(name = 'unnamed', config)
|
78
90
|
Dployr::Config::Instance.new do |i|
|
79
91
|
i.name = name
|
@@ -104,8 +116,11 @@ module Dployr
|
|
104
116
|
attrs
|
105
117
|
end
|
106
118
|
|
107
|
-
def merge_config(instance)
|
108
|
-
|
119
|
+
def merge_config(instance, attributes = {})
|
120
|
+
config = merge_defaults instance.get_values
|
121
|
+
config[:attributes] =
|
122
|
+
(get_by_key(config, :attributes) or {}).merge attributes if attributes
|
123
|
+
merge_providers merge_parents config
|
109
124
|
end
|
110
125
|
|
111
126
|
def merge_defaults(config)
|
data/lib/dployr/version.rb
CHANGED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'dployr/commands/config'
|
3
|
+
|
4
|
+
describe Dployr::Commands::Config do
|
5
|
+
|
6
|
+
dployrfile = "spec/fixtures/basic/Dployrfile.yml"
|
7
|
+
arguments = "config -f #{dployrfile} -n dployr -p aws -r sa-east-1a -a 'index=100'"
|
8
|
+
|
9
|
+
before :all do
|
10
|
+
@result = `bin/dployr #{arguments}`
|
11
|
+
@exit_code = $?.exitstatus
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have a valid exit code" do
|
15
|
+
@result.should be_a String
|
16
|
+
@exit_code.should be 0
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "attributes" do
|
20
|
+
it "should have a valid attribute name" do
|
21
|
+
@result.should include "name: dployr"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should have a valid attribute index" do
|
25
|
+
@result.should match /index: [']?100[']?/
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should have a valid attribute prefix" do
|
29
|
+
@result.should include "prefix: dev"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should have a valid attribute private_key_path" do
|
33
|
+
@result.should match /private_key_path: [\"]?~\/pems\/innotechdev.pem[\"]?/
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should have a valid attribute username" do
|
37
|
+
@result.should include "username: innotechdev"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should have a valid attribute instance_type" do
|
41
|
+
@result.should include "instance_type: t1.micro"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should have a valid attribute ami" do
|
45
|
+
@result.should include "ami: ami-370daf2a"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should have a valid attribute username" do
|
49
|
+
@result.should include "username: innotechdev"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should have a valid attribute keypair" do
|
53
|
+
@result.should include "keypair: vagrant-aws-saopaulo"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should have a valid attribute security_groups" do
|
57
|
+
@result.should include "security_groups:\n - sg-3cf3e45e"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should have a valid attribute subnet_id" do
|
61
|
+
@result.should include "subnet_id: subnet-1eebe07c"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "scripts" do
|
66
|
+
it "should have a valid script in pre-provision stage" do
|
67
|
+
@result.should match /:scripts:\n pre-provision:\n - source: [\"]?.\/hello[\"]?\n target: [\"]?\/tmp[\"]?/
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should have a valid script in provision stage" do
|
71
|
+
@result.should match /provision:\n - remote_path: [\"]?\/tmp\/hello\/jetty.sh[\"]?\n args: ''/
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should have a valid script in provision stage with template value" do
|
75
|
+
@result.should match /- remote_path: [\"]?\/tmp\/test.sh 100[\"]?\n/
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should have a valid script in stop stage with template value" do
|
79
|
+
@result.should match /stop:\n - remote_path: [\"]?\/tmp\/stop.sh 100[\"]?\n/
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
data/spec/configuration_spec.rb
CHANGED
@@ -110,7 +110,7 @@ describe Dployr::Configuration do
|
|
110
110
|
key_path: "path/to/key.pem"
|
111
111
|
},
|
112
112
|
scripts: [
|
113
|
-
{ path: "setup.sh", args: ["--id ${index}"], remote: true }
|
113
|
+
{ path: "setup.sh", args: ["--id ${index}", "--name ${name}"], remote: true }
|
114
114
|
],
|
115
115
|
providers: {
|
116
116
|
aws: {
|
@@ -327,6 +327,14 @@ describe Dployr::Configuration do
|
|
327
327
|
zeus[:providers][:aws][:scripts][1][:path].should eql "setup.sh"
|
328
328
|
end
|
329
329
|
|
330
|
+
it "should have a valid number of arguments" do
|
331
|
+
zeus[:providers][:aws][:scripts][1][:args].should have(2).items
|
332
|
+
end
|
333
|
+
|
334
|
+
it "should have a remote property" do
|
335
|
+
zeus[:providers][:aws][:scripts][1][:remote].should eql true
|
336
|
+
end
|
337
|
+
|
330
338
|
it "should have a valid path" do
|
331
339
|
zeus[:providers][:aws][:scripts][2][:path].should eql "router.sh"
|
332
340
|
end
|
@@ -335,6 +343,10 @@ describe Dployr::Configuration do
|
|
335
343
|
it "should replace the argument with the instance name" do
|
336
344
|
zeus[:providers][:aws][:scripts][2][:args][0].should eql "zeus"
|
337
345
|
end
|
346
|
+
|
347
|
+
it "should replace the name context value" do
|
348
|
+
zeus[:providers][:aws][:scripts][1][:args][1].should eql "--name zeus"
|
349
|
+
end
|
338
350
|
end
|
339
351
|
end
|
340
352
|
|
@@ -471,7 +483,7 @@ describe Dployr::Configuration do
|
|
471
483
|
end
|
472
484
|
|
473
485
|
it "should have a valid name" do
|
474
|
-
@config[:attributes][:name].should eql "
|
486
|
+
@config[:attributes][:name].should eql "hera"
|
475
487
|
end
|
476
488
|
end
|
477
489
|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
default:
|
2
|
+
attributes:
|
3
|
+
index: 1
|
4
|
+
|
5
|
+
dployr:
|
6
|
+
attributes:
|
7
|
+
name: dployr-test
|
8
|
+
prefix: dev
|
9
|
+
private_key_path: ~/pems/innotechdev.pem
|
10
|
+
username: innotechdev
|
11
|
+
scripts:
|
12
|
+
pre-provision:
|
13
|
+
- source: ./hello
|
14
|
+
target: /tmp
|
15
|
+
provision:
|
16
|
+
- remote_path: /tmp/hello/jetty.sh
|
17
|
+
args: ""
|
18
|
+
- remote_path: "/tmp/test.sh %{index}"
|
19
|
+
providers:
|
20
|
+
aws:
|
21
|
+
attributes:
|
22
|
+
instance_type: t1.micro
|
23
|
+
regions:
|
24
|
+
sa-east-1a:
|
25
|
+
attributes:
|
26
|
+
ami: ami-370daf2a # centos-base-v7
|
27
|
+
keypair: vagrant-aws-saopaulo
|
28
|
+
security_groups:
|
29
|
+
- sg-3cf3e45e # lib_aws_saopaulo
|
30
|
+
subnet_id: subnet-1eebe07c
|
31
|
+
scripts:
|
32
|
+
stop:
|
33
|
+
- remote_path: "/tmp/stop.sh %{index}"
|
34
|
+
gce:
|
35
|
+
attributes:
|
36
|
+
instance_type: f1-micro
|
37
|
+
regions:
|
38
|
+
europe-west1-a:
|
39
|
+
attributes:
|
40
|
+
image_name: centos-base-v7 # centos-base-v7
|
41
|
+
network: liberty-gce
|
@@ -1,4 +1,4 @@
|
|
1
|
-
german-
|
1
|
+
german-template:
|
2
2
|
attributes:
|
3
3
|
name: "german-dployr"
|
4
4
|
prefix: dev
|
@@ -9,16 +9,8 @@ german-dployr:
|
|
9
9
|
- source: ./hello
|
10
10
|
target: /tmp
|
11
11
|
provision:
|
12
|
-
|
13
|
-
|
14
|
-
# remote_path: "/tmp/hello/hello.sh"
|
15
|
-
# -
|
16
|
-
# args: ""
|
17
|
-
# local_path: "ls -l /tmp/"
|
18
|
-
# - args: ""
|
19
|
-
# remote_path: "sudo service jetty restart"
|
20
|
-
- args: ""
|
21
|
-
remote_path: "/tmp/hello/jetty.sh"
|
12
|
+
- remote_path: /tmp/hello/jetty.sh
|
13
|
+
args: ""
|
22
14
|
providers:
|
23
15
|
aws:
|
24
16
|
attributes:
|
@@ -31,6 +23,7 @@ german-dployr:
|
|
31
23
|
security_groups:
|
32
24
|
- sg-3cf3e45e # lib_aws_saopaulo
|
33
25
|
subnet_id: subnet-1eebe07c
|
26
|
+
#public_ip: new
|
34
27
|
gce:
|
35
28
|
attributes:
|
36
29
|
instance_type: f1-micro
|
@@ -39,3 +32,4 @@ german-dployr:
|
|
39
32
|
attributes:
|
40
33
|
image_name: centos-base-v7 # centos-base-v7
|
41
34
|
network: liberty-gce
|
35
|
+
#public_ip: 146.148.27.56
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
createExecUser() {
|
4
|
+
USERNAME=$1
|
5
|
+
shift
|
6
|
+
DIRECTORIES=$@
|
7
|
+
|
8
|
+
NOLOGIN_PATH=$(which nologin)
|
9
|
+
sudo useradd -M -U -s $NOLOGIN_PATH $USERNAME
|
10
|
+
for dir in $DIRECTORIES; do
|
11
|
+
if [ ! -d $dir ]
|
12
|
+
then
|
13
|
+
sudo mkdir $dir
|
14
|
+
fi
|
15
|
+
echo "Change owner to $dir ..."
|
16
|
+
sudo chown -R ${USERNAME}:${USERNAME} $dir
|
17
|
+
done
|
18
|
+
}
|
@@ -0,0 +1,562 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
#
|
3
|
+
# Startup script for jetty under *nix systems (it works under NT/cygwin too).
|
4
|
+
|
5
|
+
##################################################
|
6
|
+
# Set the name which is used by other variables.
|
7
|
+
# Defaults to the file name without extension.
|
8
|
+
##################################################
|
9
|
+
NAME=$(echo $(basename $0) | sed -e 's/^[SK][0-9]+//' -e 's/\.sh$//')
|
10
|
+
|
11
|
+
# To get the service to restart correctly on reboot, uncomment below (3 lines):
|
12
|
+
# ========================
|
13
|
+
# chkconfig: 3 99 99
|
14
|
+
# description: Jetty 9 webserver
|
15
|
+
# processname: jetty
|
16
|
+
# ========================
|
17
|
+
|
18
|
+
# Configuration files
|
19
|
+
#
|
20
|
+
# /etc/default/$NAME
|
21
|
+
# If it exists, this is read at the start of script. It may perform any
|
22
|
+
# sequence of shell commands, like setting relevant environment variables.
|
23
|
+
#
|
24
|
+
# $HOME/.$NAMErc (e.g. $HOME/.jettyrc)
|
25
|
+
# If it exists, this is read at the start of script. It may perform any
|
26
|
+
# sequence of shell commands, like setting relevant environment variables.
|
27
|
+
#
|
28
|
+
# /etc/$NAME.conf
|
29
|
+
# If found, and no configurations were given on the command line,
|
30
|
+
# the file will be used as this script's configuration.
|
31
|
+
# Each line in the file may contain:
|
32
|
+
# - A comment denoted by the pound (#) sign as first non-blank character.
|
33
|
+
# - The path to a regular file, which will be passed to jetty as a
|
34
|
+
# config.xml file.
|
35
|
+
# - The path to a directory. Each *.xml file in the directory will be
|
36
|
+
# passed to jetty as a config.xml file.
|
37
|
+
# - All other lines will be passed, as-is to the start.jar
|
38
|
+
#
|
39
|
+
# The files will be checked for existence before being passed to jetty.
|
40
|
+
#
|
41
|
+
# Configuration variables
|
42
|
+
#
|
43
|
+
# JAVA
|
44
|
+
# Command to invoke Java. If not set, java (from the PATH) will be used.
|
45
|
+
#
|
46
|
+
# JAVA_OPTIONS
|
47
|
+
# Extra options to pass to the JVM
|
48
|
+
#
|
49
|
+
# JETTY_HOME
|
50
|
+
# Where Jetty is installed. If not set, the script will try go
|
51
|
+
# guess it by first looking at the invocation path for the script,
|
52
|
+
# and then by looking in standard locations as $HOME/opt/jetty
|
53
|
+
# and /opt/jetty. The java system property "jetty.home" will be
|
54
|
+
# set to this value for use by configure.xml files, f.e.:
|
55
|
+
#
|
56
|
+
# <Arg><Property name="jetty.home" default="."/>/webapps/jetty.war</Arg>
|
57
|
+
#
|
58
|
+
# JETTY_BASE
|
59
|
+
# Where your Jetty base directory is. If not set, the value from
|
60
|
+
# $JETTY_HOME will be used.
|
61
|
+
#
|
62
|
+
# JETTY_RUN
|
63
|
+
# Where the $NAME.pid file should be stored. It defaults to the
|
64
|
+
# first available of /var/run, /usr/var/run, JETTY_BASE and /tmp
|
65
|
+
# if not set.
|
66
|
+
#
|
67
|
+
# JETTY_PID
|
68
|
+
# The Jetty PID file, defaults to $JETTY_RUN/$NAME.pid
|
69
|
+
#
|
70
|
+
# JETTY_ARGS
|
71
|
+
# The default arguments to pass to jetty.
|
72
|
+
# For example
|
73
|
+
# JETTY_ARGS=jetty.host=0.0.0.0 jetty.port=8080 jetty.spdy.port=8443 jetty.secure.port=443
|
74
|
+
#
|
75
|
+
# JETTY_USER
|
76
|
+
# if set, then used as a username to run the server as
|
77
|
+
|
78
|
+
JETTY_HOME=/opt/jetty
|
79
|
+
JETTY_USER=jetty
|
80
|
+
JETTY_PORT=8080
|
81
|
+
JETTY_LOGS=/var/log/jetty/
|
82
|
+
|
83
|
+
usage()
|
84
|
+
{
|
85
|
+
echo "Usage: ${0##*/} [-d] {start|stop|run|restart|check|supervise} [ CONFIGS ... ] "
|
86
|
+
exit 1
|
87
|
+
}
|
88
|
+
|
89
|
+
[ $# -gt 0 ] || usage
|
90
|
+
|
91
|
+
|
92
|
+
##################################################
|
93
|
+
# Some utility functions
|
94
|
+
##################################################
|
95
|
+
findDirectory()
|
96
|
+
{
|
97
|
+
local L OP=$1
|
98
|
+
shift
|
99
|
+
for L in "$@"; do
|
100
|
+
[ "$OP" "$L" ] || continue
|
101
|
+
printf %s "$L"
|
102
|
+
break
|
103
|
+
done
|
104
|
+
}
|
105
|
+
|
106
|
+
running()
|
107
|
+
{
|
108
|
+
local PID=$(cat "$1" 2>/dev/null) || return 1
|
109
|
+
kill -0 "$PID" 2>/dev/null
|
110
|
+
}
|
111
|
+
|
112
|
+
started()
|
113
|
+
{
|
114
|
+
# wait for 60s to see "STARTED" in PID file, needs jetty-started.xml as argument
|
115
|
+
for T in 1 2 3 4 5 6 7 9 10 11 12 13 14 15
|
116
|
+
do
|
117
|
+
sleep 4
|
118
|
+
[ -z "$(grep STARTED $1 2>/dev/null)" ] || return 0
|
119
|
+
[ -z "$(grep STOPPED $1 2>/dev/null)" ] || return 1
|
120
|
+
[ -z "$(grep FAILED $1 2>/dev/null)" ] || return 1
|
121
|
+
local PID=$(cat "$2" 2>/dev/null) || return 1
|
122
|
+
kill -0 "$PID" 2>/dev/null || return 1
|
123
|
+
echo -n ". "
|
124
|
+
done
|
125
|
+
|
126
|
+
return 1;
|
127
|
+
}
|
128
|
+
|
129
|
+
|
130
|
+
readConfig()
|
131
|
+
{
|
132
|
+
(( DEBUG )) && echo "Reading $1.."
|
133
|
+
source "$1"
|
134
|
+
}
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
##################################################
|
139
|
+
# Get the action & configs
|
140
|
+
##################################################
|
141
|
+
CONFIGS=()
|
142
|
+
NO_START=0
|
143
|
+
DEBUG=0
|
144
|
+
|
145
|
+
while [[ $1 = -* ]]; do
|
146
|
+
case $1 in
|
147
|
+
-d) DEBUG=1 ;;
|
148
|
+
esac
|
149
|
+
shift
|
150
|
+
done
|
151
|
+
ACTION=$1
|
152
|
+
shift
|
153
|
+
|
154
|
+
##################################################
|
155
|
+
# Read any configuration files
|
156
|
+
##################################################
|
157
|
+
ETC=/etc
|
158
|
+
if [ $UID != 0 ]
|
159
|
+
then
|
160
|
+
ETC=$HOME/etc
|
161
|
+
fi
|
162
|
+
|
163
|
+
for CONFIG in $ETC/default/${NAME}{,9} $HOME/.${NAME}rc; do
|
164
|
+
if [ -f "$CONFIG" ] ; then
|
165
|
+
readConfig "$CONFIG"
|
166
|
+
fi
|
167
|
+
done
|
168
|
+
|
169
|
+
|
170
|
+
##################################################
|
171
|
+
# Set tmp if not already set.
|
172
|
+
##################################################
|
173
|
+
TMPDIR=${TMPDIR:-/tmp}
|
174
|
+
|
175
|
+
##################################################
|
176
|
+
# Jetty's hallmark
|
177
|
+
##################################################
|
178
|
+
JETTY_INSTALL_TRACE_FILE="start.jar"
|
179
|
+
|
180
|
+
|
181
|
+
##################################################
|
182
|
+
# Try to determine JETTY_HOME if not set
|
183
|
+
##################################################
|
184
|
+
if [ -z "$JETTY_HOME" ]
|
185
|
+
then
|
186
|
+
JETTY_SH=$0
|
187
|
+
case "$JETTY_SH" in
|
188
|
+
/*) JETTY_HOME=${JETTY_SH%/*/*} ;;
|
189
|
+
./*/*) JETTY_HOME=${JETTY_SH%/*/*} ;;
|
190
|
+
./*) JETTY_HOME=.. ;;
|
191
|
+
*/*/*) JETTY_HOME=./${JETTY_SH%/*/*} ;;
|
192
|
+
*/*) JETTY_HOME=. ;;
|
193
|
+
*) JETTY_HOME=.. ;;
|
194
|
+
esac
|
195
|
+
|
196
|
+
if [ ! -f "$JETTY_HOME/$JETTY_INSTALL_TRACE_FILE" ]
|
197
|
+
then
|
198
|
+
JETTY_HOME=
|
199
|
+
fi
|
200
|
+
fi
|
201
|
+
|
202
|
+
|
203
|
+
##################################################
|
204
|
+
# No JETTY_HOME yet? We're out of luck!
|
205
|
+
##################################################
|
206
|
+
if [ -z "$JETTY_HOME" ]; then
|
207
|
+
echo "** ERROR: JETTY_HOME not set, you need to set it or install in a standard location"
|
208
|
+
exit 1
|
209
|
+
fi
|
210
|
+
|
211
|
+
cd "$JETTY_HOME"
|
212
|
+
JETTY_HOME=$PWD
|
213
|
+
|
214
|
+
|
215
|
+
##################################################
|
216
|
+
# Set JETTY_BASE
|
217
|
+
##################################################
|
218
|
+
if [ -z "$JETTY_BASE" ]; then
|
219
|
+
JETTY_BASE=$JETTY_HOME
|
220
|
+
fi
|
221
|
+
|
222
|
+
cd "$JETTY_BASE"
|
223
|
+
JETTY_BASE=$PWD
|
224
|
+
|
225
|
+
|
226
|
+
#####################################################
|
227
|
+
# Check that jetty is where we think it is
|
228
|
+
#####################################################
|
229
|
+
if [ ! -r "$JETTY_HOME/$JETTY_INSTALL_TRACE_FILE" ]
|
230
|
+
then
|
231
|
+
echo "** ERROR: Oops! Jetty doesn't appear to be installed in $JETTY_HOME"
|
232
|
+
echo "** ERROR: $JETTY_HOME/$JETTY_INSTALL_TRACE_FILE is not readable!"
|
233
|
+
exit 1
|
234
|
+
fi
|
235
|
+
|
236
|
+
##################################################
|
237
|
+
# Try to find this script's configuration file,
|
238
|
+
# but only if no configurations were given on the
|
239
|
+
# command line.
|
240
|
+
##################################################
|
241
|
+
if [ -z "$JETTY_CONF" ]
|
242
|
+
then
|
243
|
+
if [ -f $ETC/${NAME}.conf ]
|
244
|
+
then
|
245
|
+
JETTY_CONF=$ETC/${NAME}.conf
|
246
|
+
elif [ -f "$JETTY_BASE/etc/jetty.conf" ]
|
247
|
+
then
|
248
|
+
JETTY_CONF=$JETTY_BASE/etc/jetty.conf
|
249
|
+
elif [ -f "$JETTY_HOME/etc/jetty.conf" ]
|
250
|
+
then
|
251
|
+
JETTY_CONF=$JETTY_HOME/etc/jetty.conf
|
252
|
+
fi
|
253
|
+
fi
|
254
|
+
|
255
|
+
##################################################
|
256
|
+
# Get the list of config.xml files from jetty.conf
|
257
|
+
##################################################
|
258
|
+
if [ -f "$JETTY_CONF" ] && [ -r "$JETTY_CONF" ]
|
259
|
+
then
|
260
|
+
while read -r CONF
|
261
|
+
do
|
262
|
+
if expr "$CONF" : '#' >/dev/null ; then
|
263
|
+
continue
|
264
|
+
fi
|
265
|
+
|
266
|
+
if [ -d "$CONF" ]
|
267
|
+
then
|
268
|
+
# assume it's a directory with configure.xml files
|
269
|
+
# for example: /etc/jetty.d/
|
270
|
+
# sort the files before adding them to the list of JETTY_ARGS
|
271
|
+
for XMLFILE in "$CONF/"*.xml
|
272
|
+
do
|
273
|
+
if [ -r "$XMLFILE" ] && [ -f "$XMLFILE" ]
|
274
|
+
then
|
275
|
+
JETTY_ARGS+=("$XMLFILE")
|
276
|
+
else
|
277
|
+
echo "** WARNING: Cannot read '$XMLFILE' specified in '$JETTY_CONF'"
|
278
|
+
fi
|
279
|
+
done
|
280
|
+
else
|
281
|
+
# assume it's a command line parameter (let start.jar deal with its validity)
|
282
|
+
JETTY_ARGS+=("$CONF")
|
283
|
+
fi
|
284
|
+
done < "$JETTY_CONF"
|
285
|
+
fi
|
286
|
+
|
287
|
+
#####################################################
|
288
|
+
# Find a location for the pid file
|
289
|
+
#####################################################
|
290
|
+
if [ -z "$JETTY_RUN" ]
|
291
|
+
then
|
292
|
+
JETTY_RUN=$(findDirectory -w /var/run /usr/var/run $JETTY_BASE /tmp)
|
293
|
+
fi
|
294
|
+
|
295
|
+
#####################################################
|
296
|
+
# Find a pid and state file
|
297
|
+
#####################################################
|
298
|
+
if [ -z "$JETTY_PID" ]
|
299
|
+
then
|
300
|
+
JETTY_PID="$JETTY_RUN/${NAME}.pid"
|
301
|
+
fi
|
302
|
+
|
303
|
+
if [ -z "$JETTY_STATE" ]
|
304
|
+
then
|
305
|
+
JETTY_STATE=$JETTY_BASE/${NAME}.state
|
306
|
+
fi
|
307
|
+
JAVA_OPTIONS+=("-Djetty.state=$JETTY_STATE")
|
308
|
+
rm -f $JETTY_STATE
|
309
|
+
|
310
|
+
##################################################
|
311
|
+
# Setup JAVA if unset
|
312
|
+
##################################################
|
313
|
+
if [ -z "$JAVA" ]
|
314
|
+
then
|
315
|
+
JAVA=$(which java)
|
316
|
+
fi
|
317
|
+
|
318
|
+
if [ -z "$JAVA" ]
|
319
|
+
then
|
320
|
+
echo "Cannot find a Java JDK. Please set either set JAVA or put java (>=1.5) in your PATH." 2>&2
|
321
|
+
exit 1
|
322
|
+
fi
|
323
|
+
|
324
|
+
#####################################################
|
325
|
+
# See if JETTY_LOGS is defined
|
326
|
+
#####################################################
|
327
|
+
if [ -z "$JETTY_LOGS" ] && [ -d $JETTY_BASE/logs ]
|
328
|
+
then
|
329
|
+
JETTY_LOGS=$JETTY_BASE/logs
|
330
|
+
fi
|
331
|
+
if [ -z "$JETTY_LOGS" ] && [ -d $JETTY_HOME/logs ]
|
332
|
+
then
|
333
|
+
JETTY_LOGS=$JETTY_HOME/logs
|
334
|
+
fi
|
335
|
+
if [ "$JETTY_LOGS" ]
|
336
|
+
then
|
337
|
+
JAVA_OPTIONS+=("-Djetty.logs=$JETTY_LOGS")
|
338
|
+
fi
|
339
|
+
|
340
|
+
#####################################################
|
341
|
+
# Are we running on Windows? Could be, with Cygwin/NT.
|
342
|
+
#####################################################
|
343
|
+
case "`uname`" in
|
344
|
+
CYGWIN*) PATH_SEPARATOR=";";;
|
345
|
+
*) PATH_SEPARATOR=":";;
|
346
|
+
esac
|
347
|
+
|
348
|
+
|
349
|
+
#####################################################
|
350
|
+
# Add jetty properties to Java VM options.
|
351
|
+
#####################################################
|
352
|
+
JAVA_OPTIONS+=("-Djetty.home=$JETTY_HOME" "-Djetty.base=$JETTY_BASE" "-Djava.io.tmpdir=$TMPDIR")
|
353
|
+
|
354
|
+
#####################################################
|
355
|
+
# This is how the Jetty server will be started
|
356
|
+
#####################################################
|
357
|
+
|
358
|
+
JETTY_START=$JETTY_HOME/start.jar
|
359
|
+
START_INI=$JETTY_BASE/start.ini
|
360
|
+
if [ ! -f "$START_INI" ]
|
361
|
+
then
|
362
|
+
echo "Cannot find a start.ini in your JETTY_BASE directory: $JETTY_BASE" 2>&2
|
363
|
+
exit 1
|
364
|
+
fi
|
365
|
+
|
366
|
+
RUN_ARGS=(${JAVA_OPTIONS[@]} -jar "$JETTY_START" ${JETTY_ARGS[*]})
|
367
|
+
RUN_CMD=("$JAVA" ${RUN_ARGS[@]})
|
368
|
+
|
369
|
+
#####################################################
|
370
|
+
# Comment these out after you're happy with what
|
371
|
+
# the script is doing.
|
372
|
+
#####################################################
|
373
|
+
if (( DEBUG ))
|
374
|
+
then
|
375
|
+
echo "START_INI = $START_INI"
|
376
|
+
echo "JETTY_HOME = $JETTY_HOME"
|
377
|
+
echo "JETTY_BASE = $JETTY_BASE"
|
378
|
+
echo "JETTY_CONF = $JETTY_CONF"
|
379
|
+
echo "JETTY_PID = $JETTY_PID"
|
380
|
+
echo "JETTY_START = $JETTY_START"
|
381
|
+
echo "JETTY_ARGS = ${JETTY_ARGS[*]}"
|
382
|
+
echo "JAVA_OPTIONS = ${JAVA_OPTIONS[*]}"
|
383
|
+
echo "JAVA = $JAVA"
|
384
|
+
echo "RUN_CMD = ${RUN_CMD}"
|
385
|
+
fi
|
386
|
+
|
387
|
+
##################################################
|
388
|
+
# Do the action
|
389
|
+
##################################################
|
390
|
+
case "$ACTION" in
|
391
|
+
start)
|
392
|
+
echo -n "Starting Jetty: "
|
393
|
+
|
394
|
+
if (( NO_START )); then
|
395
|
+
echo "Not starting ${NAME} - NO_START=1";
|
396
|
+
exit
|
397
|
+
fi
|
398
|
+
|
399
|
+
if [ $UID -eq 0 ] && type start-stop-daemon > /dev/null 2>&1
|
400
|
+
then
|
401
|
+
unset CH_USER
|
402
|
+
if [ -n "$JETTY_USER" ]
|
403
|
+
then
|
404
|
+
CH_USER="-c$JETTY_USER"
|
405
|
+
fi
|
406
|
+
|
407
|
+
start-stop-daemon -S -p"$JETTY_PID" $CH_USER -d"$JETTY_HOME" -b -m -a "$JAVA" -- "${RUN_ARGS[@]}" --daemon
|
408
|
+
|
409
|
+
else
|
410
|
+
|
411
|
+
if [ -f "$JETTY_PID" ]
|
412
|
+
then
|
413
|
+
if running $JETTY_PID
|
414
|
+
then
|
415
|
+
echo "Already Running!"
|
416
|
+
exit 1
|
417
|
+
else
|
418
|
+
# dead pid file - remove
|
419
|
+
rm -f "$JETTY_PID"
|
420
|
+
fi
|
421
|
+
fi
|
422
|
+
|
423
|
+
if [ "$JETTY_USER" ]
|
424
|
+
then
|
425
|
+
touch "$JETTY_PID"
|
426
|
+
chown "$JETTY_USER" "$JETTY_PID"
|
427
|
+
# FIXME: Broken solution: wordsplitting, pathname expansion, arbitrary command execution, etc.
|
428
|
+
su - "$JETTY_USER" -c "
|
429
|
+
exec ${RUN_CMD[*]} --daemon &
|
430
|
+
disown \$!
|
431
|
+
echo \$! > '$JETTY_PID'"
|
432
|
+
else
|
433
|
+
"${RUN_CMD[@]}" &
|
434
|
+
disown $!
|
435
|
+
echo $! > "$JETTY_PID"
|
436
|
+
fi
|
437
|
+
|
438
|
+
fi
|
439
|
+
|
440
|
+
if expr "${JETTY_ARGS[*]}" : '.*jetty-started.xml.*' >/dev/null
|
441
|
+
then
|
442
|
+
if started "$JETTY_STATE" "$JETTY_PID"
|
443
|
+
then
|
444
|
+
echo "OK `date`"
|
445
|
+
else
|
446
|
+
echo "FAILED `date`"
|
447
|
+
fi
|
448
|
+
else
|
449
|
+
echo "ok `date`"
|
450
|
+
fi
|
451
|
+
|
452
|
+
;;
|
453
|
+
|
454
|
+
stop)
|
455
|
+
echo -n "Stopping Jetty: "
|
456
|
+
if [ $UID -eq 0 ] && type start-stop-daemon > /dev/null 2>&1; then
|
457
|
+
start-stop-daemon -K -p"$JETTY_PID" -d"$JETTY_HOME" -a "$JAVA" -s HUP
|
458
|
+
|
459
|
+
TIMEOUT=30
|
460
|
+
while running "$JETTY_PID"; do
|
461
|
+
if (( TIMEOUT-- == 0 )); then
|
462
|
+
start-stop-daemon -K -p"$JETTY_PID" -d"$JETTY_HOME" -a "$JAVA" -s KILL
|
463
|
+
fi
|
464
|
+
|
465
|
+
sleep 1
|
466
|
+
done
|
467
|
+
|
468
|
+
rm -f "$JETTY_PID"
|
469
|
+
echo OK
|
470
|
+
else
|
471
|
+
PID=$(cat "$JETTY_PID" 2>/dev/null)
|
472
|
+
kill "$PID" 2>/dev/null
|
473
|
+
|
474
|
+
TIMEOUT=30
|
475
|
+
while running $JETTY_PID; do
|
476
|
+
if (( TIMEOUT-- == 0 )); then
|
477
|
+
kill -KILL "$PID" 2>/dev/null
|
478
|
+
fi
|
479
|
+
|
480
|
+
sleep 1
|
481
|
+
done
|
482
|
+
|
483
|
+
rm -f "$JETTY_PID"
|
484
|
+
echo OK
|
485
|
+
fi
|
486
|
+
|
487
|
+
;;
|
488
|
+
|
489
|
+
restart)
|
490
|
+
JETTY_SH=$0
|
491
|
+
if [ ! -f $JETTY_SH ]; then
|
492
|
+
if [ ! -f $JETTY_HOME/bin/jetty.sh ]; then
|
493
|
+
echo "$JETTY_HOME/bin/jetty.sh does not exist."
|
494
|
+
exit 1
|
495
|
+
fi
|
496
|
+
JETTY_SH=$JETTY_HOME/bin/jetty.sh
|
497
|
+
fi
|
498
|
+
|
499
|
+
"$JETTY_SH" stop "$@"
|
500
|
+
"$JETTY_SH" start "$@"
|
501
|
+
|
502
|
+
;;
|
503
|
+
|
504
|
+
supervise)
|
505
|
+
#
|
506
|
+
# Under control of daemontools supervise monitor which
|
507
|
+
# handles restarts and shutdowns via the svc program.
|
508
|
+
#
|
509
|
+
exec "${RUN_CMD[@]}"
|
510
|
+
|
511
|
+
;;
|
512
|
+
|
513
|
+
run|demo)
|
514
|
+
echo "Running Jetty: "
|
515
|
+
|
516
|
+
if [ -f "$JETTY_PID" ]
|
517
|
+
then
|
518
|
+
if running "$JETTY_PID"
|
519
|
+
then
|
520
|
+
echo "Already Running!"
|
521
|
+
exit 1
|
522
|
+
else
|
523
|
+
# dead pid file - remove
|
524
|
+
rm -f "$JETTY_PID"
|
525
|
+
fi
|
526
|
+
fi
|
527
|
+
|
528
|
+
exec "${RUN_CMD[@]}"
|
529
|
+
;;
|
530
|
+
|
531
|
+
check|status)
|
532
|
+
echo "Checking arguments to Jetty: "
|
533
|
+
echo "START_INI = $START_INI"
|
534
|
+
echo "JETTY_HOME = $JETTY_HOME"
|
535
|
+
echo "JETTY_BASE = $JETTY_BASE"
|
536
|
+
echo "JETTY_CONF = $JETTY_CONF"
|
537
|
+
echo "JETTY_PID = $JETTY_PID"
|
538
|
+
echo "JETTY_START = $JETTY_START"
|
539
|
+
echo "JETTY_LOGS = $JETTY_LOGS"
|
540
|
+
echo "CLASSPATH = $CLASSPATH"
|
541
|
+
echo "JAVA = $JAVA"
|
542
|
+
echo "JAVA_OPTIONS = ${JAVA_OPTIONS[*]}"
|
543
|
+
echo "JETTY_ARGS = ${JETTY_ARGS[*]}"
|
544
|
+
echo "RUN_CMD = ${RUN_CMD[*]}"
|
545
|
+
echo
|
546
|
+
|
547
|
+
if [ -f "$JETTY_PID" ]
|
548
|
+
then
|
549
|
+
echo "Jetty running pid=$(< "$JETTY_PID")"
|
550
|
+
exit 0
|
551
|
+
fi
|
552
|
+
exit 1
|
553
|
+
|
554
|
+
;;
|
555
|
+
|
556
|
+
*)
|
557
|
+
usage
|
558
|
+
|
559
|
+
;;
|
560
|
+
esac
|
561
|
+
|
562
|
+
exit 0
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
source /tmp/hello/createExecUser.sh
|
3
|
+
|
4
|
+
# Install JRE 1.7
|
5
|
+
# sudo yum install java-1.7.0-openjdk.x86_64 -y
|
6
|
+
# sudo alternatives --set java /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
|
7
|
+
|
8
|
+
# Install & Run Jetty
|
9
|
+
if [ ! -d /opt/jetty ]
|
10
|
+
then
|
11
|
+
#wget http://download.eclipse.org/jetty/9.1.1.v20140108/dist/jetty-distribution-9.1.1.v20140108.tar.gz -O jetty.tar.gz
|
12
|
+
#wget http://cdn.mirror.garr.it/mirror3/mirrors/eclipse//jetty/9.1.0.v20131115/dist/jetty-distribution-9.1.0.v20131115.tar.gz -O jetty.tar.gz
|
13
|
+
wget http://eclipse.mirror.triple-it.nl/jetty/stable-9/dist/jetty-distribution-9.1.4.v20140401.tar.gz -O jetty.tar.gz
|
14
|
+
tar -xf jetty.tar.gz
|
15
|
+
rm jetty.tar.gz
|
16
|
+
mv jetty-* jetty
|
17
|
+
sudo mv jetty /opt/
|
18
|
+
sudo /usr/sbin/useradd jetty
|
19
|
+
sudo mkdir /var/log/jetty
|
20
|
+
sudo chown -R jetty:jetty /var/log/jetty /opt/jetty
|
21
|
+
fi
|
22
|
+
|
23
|
+
sudo cp /tmp/hello/jetty /etc/init.d
|
24
|
+
sudo chmod a+x /etc/init.d/jetty
|
25
|
+
sudo chkconfig --add jetty
|
26
|
+
sudo chkconfig jetty on
|
27
|
+
sudo service jetty restart
|
28
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dployr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Aparicio
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- lib/dployr/commands/stop_destroy.rb
|
140
140
|
- lib/dployr/commands/utils.rb
|
141
141
|
- lib/dployr/compute/aws.rb
|
142
|
+
- lib/dployr/compute/common.rb
|
142
143
|
- lib/dployr/compute/gce.rb
|
143
144
|
- lib/dployr/config/constants.rb
|
144
145
|
- lib/dployr/config/create.rb
|
@@ -155,14 +156,19 @@ files:
|
|
155
156
|
- lib/dployr/scripts/ssh.rb
|
156
157
|
- lib/dployr/utils.rb
|
157
158
|
- lib/dployr/version.rb
|
159
|
+
- spec/commands_config_spec.rb
|
158
160
|
- spec/commands_util_spec.rb
|
159
161
|
- spec/config_file_utils_spec.rb
|
160
162
|
- spec/config_instance_spec.rb
|
161
163
|
- spec/configuration_spec.rb
|
162
164
|
- spec/fixtures/Dployrfile
|
163
165
|
- spec/fixtures/Dployrfile.yml
|
164
|
-
- spec/fixtures/
|
165
|
-
- spec/fixtures/
|
166
|
+
- spec/fixtures/basic/Dployrfile.yml
|
167
|
+
- spec/fixtures/german/Dployrfile.yml
|
168
|
+
- spec/fixtures/hello/createExecUser.sh
|
169
|
+
- spec/fixtures/hello/hello.sh
|
170
|
+
- spec/fixtures/hello/jetty
|
171
|
+
- spec/fixtures/hello/jetty.sh
|
166
172
|
- spec/fog_spec_.rb
|
167
173
|
- spec/init_spec.rb
|
168
174
|
- spec/spec_helper.rb
|
@@ -188,19 +194,24 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
194
|
version: '0'
|
189
195
|
requirements: []
|
190
196
|
rubyforge_project: dployr
|
191
|
-
rubygems_version: 2.0.
|
197
|
+
rubygems_version: 2.0.6
|
192
198
|
signing_key:
|
193
199
|
specification_version: 4
|
194
200
|
summary: Multicloud management and deployment with asteroids made simple
|
195
201
|
test_files:
|
202
|
+
- spec/commands_config_spec.rb
|
196
203
|
- spec/commands_util_spec.rb
|
197
204
|
- spec/config_file_utils_spec.rb
|
198
205
|
- spec/config_instance_spec.rb
|
199
206
|
- spec/configuration_spec.rb
|
200
207
|
- spec/fixtures/Dployrfile
|
201
208
|
- spec/fixtures/Dployrfile.yml
|
202
|
-
- spec/fixtures/
|
203
|
-
- spec/fixtures/
|
209
|
+
- spec/fixtures/basic/Dployrfile.yml
|
210
|
+
- spec/fixtures/german/Dployrfile.yml
|
211
|
+
- spec/fixtures/hello/createExecUser.sh
|
212
|
+
- spec/fixtures/hello/hello.sh
|
213
|
+
- spec/fixtures/hello/jetty
|
214
|
+
- spec/fixtures/hello/jetty.sh
|
204
215
|
- spec/fog_spec_.rb
|
205
216
|
- spec/init_spec.rb
|
206
217
|
- spec/spec_helper.rb
|
File without changes
|