stackfu 0.1.1 → 0.1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/Manifest +36 -4
- data/Rakefile +1 -1
- data/autotest/discover.rb +1 -0
- data/firewall/config/01-controls.yml +5 -0
- data/firewall/config/02-requirements.yml +4 -0
- data/firewall/config/03-executions.yml +6 -0
- data/firewall/config/03-scripts.yml +6 -0
- data/firewall/config/04-validations.yml +4 -0
- data/firewall/executables/configure_ufw.sh.erb +9 -0
- data/firewall/executables/install_ufw.sh.erb +7 -0
- data/firewall/script/configure_ufw.sh.erb +9 -0
- data/firewall/script/install_ufw.sh.erb +7 -0
- data/firewall/script.yml +8 -0
- data/lib/stackfu/api_hooks.rb +2 -2
- data/lib/stackfu/app.rb +5 -5
- data/lib/stackfu/commands/command.rb +7 -3
- data/lib/stackfu/commands/config_command.rb +1 -1
- data/lib/stackfu/commands/deploy_command.rb +53 -61
- data/lib/stackfu/commands/dump_command.rb +46 -40
- data/lib/stackfu/commands/generate_command.rb +10 -12
- data/lib/stackfu/commands/help_command.rb +1 -1
- data/lib/stackfu/commands/list_command.rb +76 -22
- data/lib/stackfu/commands/publish_command.rb +35 -18
- data/lib/stackfu/commands/server_command.rb +124 -124
- data/lib/stackfu/date_helper.rb +111 -0
- data/lib/stackfu.rb +4 -2
- data/spec/fixtures/scripts/all.json +11 -0
- data/spec/fixtures/scripts/create.json +10 -0
- data/spec/fixtures/scripts/delete.json +10 -0
- data/spec/fixtures/scripts/firewall.json +12 -0
- data/spec/fixtures/scripts/none.json +12 -0
- data/spec/fixtures/scripts/not_found.json +11 -0
- data/spec/fixtures/scripts/script_not_found.json +11 -0
- data/spec/fixtures/servers/all.json +12 -0
- data/spec/fixtures/servers/cannot_deploy.json +0 -0
- data/spec/fixtures/servers/deploy.json +290 -0
- data/spec/fixtures/servers/none.json +12 -0
- data/spec/fixtures/servers/not_found.json +11 -0
- data/spec/fixtures/servers/webbynode/deploy.json +12 -0
- data/spec/fixtures/servers/webbynode.json +12 -0
- data/spec/spec_helper.rb +191 -0
- data/spec/stackfu/api_hooks_spec.rb +7 -0
- data/spec/stackfu/commands/deploy_command_spec.rb +65 -0
- data/spec/stackfu/commands/dump_command_spec.rb +47 -0
- data/spec/stackfu/commands/generate_command_spec.rb +90 -0
- data/spec/stackfu/commands/list_command_spec.rb +53 -0
- data/spec/stackfu/commands/publish_command_spec.rb +67 -0
- data/stackfu.gemspec +4 -4
- data/templates/02-requirements.yml.erb +8 -10
- data/templates/{03-scripts.yml.erb → 03-executions.yml.erb} +3 -3
- data/templates/04-validations.yml.erb +1 -2
- data/templates/stack.yml.erb +4 -13
- data/test/support/fixtures.rb +1 -1
- data/test/unit/commands/test_server_command.rb +259 -259
- metadata +42 -7
- data/test/stack.yml +0 -26
- /data/stackfu-installer/config/{03-scripts.yml → 03-executions.yml} +0 -0
@@ -7,20 +7,18 @@
|
|
7
7
|
#
|
8
8
|
# Types of dependencies:
|
9
9
|
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
10
|
+
# FileExists - a given file exists
|
11
|
+
# SymlinkExists - a given symlink exists
|
12
|
+
# DirExists - a given directory exits
|
13
|
+
# ProcessExists - a process is runnning
|
14
|
+
# RubyCanLoad - if ruby can load a given lib
|
15
|
+
# RubyGem - if a given ruby gem is installed
|
16
16
|
#
|
17
17
|
# Example of expected contents for this file:
|
18
18
|
#
|
19
19
|
# requirements:
|
20
|
-
# - type:
|
20
|
+
# - type: DirExists
|
21
21
|
# data: "/var"
|
22
|
-
#
|
23
|
-
# - type: file
|
22
|
+
# - type: FireExists
|
24
23
|
# data: "/etc/init.d/mysql"
|
25
|
-
# error: MySQL start script was not found
|
26
24
|
#
|
@@ -25,9 +25,9 @@
|
|
25
25
|
# install_apache.sh.erb, isntall_mysql.sh.erb and
|
26
26
|
# install_php.sh.erb
|
27
27
|
#
|
28
|
-
<% if
|
29
|
-
|
30
|
-
<%
|
28
|
+
<% if executions %>
|
29
|
+
executions:
|
30
|
+
<% executions.each do |s| %>
|
31
31
|
- description: <%= s.first.titleize %>
|
32
32
|
file: <%= s.first %>
|
33
33
|
<% end %>
|
data/templates/stack.yml.erb
CHANGED
@@ -1,17 +1,8 @@
|
|
1
1
|
---
|
2
|
-
type:
|
2
|
+
type: script
|
3
3
|
name: "<%= name %>"
|
4
|
+
description: "Add your description here"
|
4
5
|
#
|
5
|
-
# TODO: Before submitting this
|
6
|
-
#
|
7
|
-
#
|
8
|
-
# Available operating systems
|
9
|
-
#
|
10
|
-
# <%= "For OS".ljust(20) %> <%= "Use" %>
|
11
|
-
# <%= "-"*20 %> <%= "-"*20 %>
|
12
|
-
<% FriendlyNames.each_pair do |key, value| %># <%= key.ljust(20) %> <%= value %>
|
13
|
-
<% end %>#
|
14
|
-
# operating_system:
|
15
|
-
# description: "<%= description %>"
|
16
|
-
# tags: [add, some, tags]
|
6
|
+
# TODO: Before submitting this script, double check the
|
7
|
+
# attributes above.
|
17
8
|
#
|
data/test/support/fixtures.rb
CHANGED
@@ -81,7 +81,7 @@ module Fixtures
|
|
81
81
|
fixture = options[:fixture] || options[:path]
|
82
82
|
params = options[:params] ? "?#{options[:params]}" : ""
|
83
83
|
|
84
|
-
|
84
|
+
d "Registering: #{method} #{ApiUrlPrefix}/#{path}.json#{params} => #{fixture}#{kind}"
|
85
85
|
FakeWeb.register_uri(method, "#{ApiUrlPrefix}/#{path}.json#{params}",
|
86
86
|
:response => fixture("#{fixture}#{kind}"))
|
87
87
|
end
|
@@ -1,259 +1,259 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
2
|
-
|
3
|
-
class TestServerCommand < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
end
|
1
|
+
# require File.dirname(__FILE__) + '/../../test_helper.rb'
|
2
|
+
#
|
3
|
+
# class TestServerCommand < Test::Unit::TestCase
|
4
|
+
# should "map 'servers' to ServerCommand" do
|
5
|
+
# Command.create("servers").class.should == ServerCommand
|
6
|
+
# end
|
7
|
+
#
|
8
|
+
# should "map 'server' to ServerCommand" do
|
9
|
+
# Command.create("server").class.should == ServerCommand
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# context "list servers with invalid user" do
|
13
|
+
# should "return an user friendly error" do
|
14
|
+
# with_server_list("unauthorized")
|
15
|
+
# command "server list"
|
16
|
+
# stdout.should =~ /Access denied for user 'flipper'/
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# context "list servers with 404" do
|
21
|
+
# should "return an user friendly error" do
|
22
|
+
# with_server_list("not_found")
|
23
|
+
# command "server list"
|
24
|
+
# stdout.should =~ /There was an internal error contacting StackFu backend./
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# should "indicate user have no servers" do
|
29
|
+
# with_server_list "empty"
|
30
|
+
# command "server list"
|
31
|
+
# stdout.should =~ /You have no servers under your account. Try adding some with 'server add' command.\n/
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# context "add command" do
|
35
|
+
# should "require two parameters" do
|
36
|
+
# command "server add Slicehost"
|
37
|
+
# stdout.should =~ /requires 2 parameters/
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# context "adding a server" do
|
42
|
+
# should "fail when adding to add the same server twice" do
|
43
|
+
# with_users
|
44
|
+
# with_server_add("dupe")
|
45
|
+
#
|
46
|
+
# command "server add Slicehost slicey"
|
47
|
+
# stdout.should =~ /already exists in your account./
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# should "ask for credentials before the walkthrough if user have no credentials" do
|
51
|
+
# with_users "no_credentials"
|
52
|
+
# with_users_add
|
53
|
+
# with_providers
|
54
|
+
# with_provider("slicehost", "servers")
|
55
|
+
# with_server_add
|
56
|
+
#
|
57
|
+
# when_asked_to_choose "\nSelect the provider:",
|
58
|
+
# :with_options => ["Webbynode", "Slicehost", "Linode"],
|
59
|
+
# :answer => 1
|
60
|
+
#
|
61
|
+
# when_asked "", :answer => "abc123"
|
62
|
+
#
|
63
|
+
# when_asked_to_choose "\nSelect the server:",
|
64
|
+
# :with_options => ["slicey", "peeps"],
|
65
|
+
# :answer => 1
|
66
|
+
#
|
67
|
+
# command "server add"
|
68
|
+
#
|
69
|
+
# stdout.should =~ /Slicehost credentials saved/
|
70
|
+
# stdout.should =~ /Server peeps added successfully/
|
71
|
+
# end
|
72
|
+
#
|
73
|
+
# should "fail when adding to add the same server twice and using the walkthrough" do
|
74
|
+
# with_users
|
75
|
+
# with_providers
|
76
|
+
# with_provider("slicehost", "servers")
|
77
|
+
# with_server_add("dupe")
|
78
|
+
#
|
79
|
+
# when_asked_to_choose "\nSelect the provider:",
|
80
|
+
# :with_options => ["Webbynode", "Slicehost", "Linode"],
|
81
|
+
# :answer => 1
|
82
|
+
#
|
83
|
+
# when_asked_to_choose "\nSelect the server:",
|
84
|
+
# :with_options => ["slicey", "peeps"],
|
85
|
+
# :answer => 1
|
86
|
+
#
|
87
|
+
# command "server add"
|
88
|
+
#
|
89
|
+
# stdout.should =~ /already exists in your account./
|
90
|
+
# end
|
91
|
+
#
|
92
|
+
# should "guide the user to add a server when no params are given" do
|
93
|
+
# with_users
|
94
|
+
# with_providers
|
95
|
+
# with_provider("slicehost", "servers")
|
96
|
+
# with_server_add
|
97
|
+
#
|
98
|
+
# when_asked_to_choose "\nSelect the provider:",
|
99
|
+
# :with_options => ["Webbynode", "Slicehost", "Linode"],
|
100
|
+
# :answer => 1
|
101
|
+
#
|
102
|
+
# when_asked_to_choose "\nSelect the server:",
|
103
|
+
# :with_options => ["slicey", "peeps"],
|
104
|
+
# :answer => 1
|
105
|
+
#
|
106
|
+
# command "server add"
|
107
|
+
# end
|
108
|
+
# end
|
109
|
+
#
|
110
|
+
# context "adding a webbynode server" do
|
111
|
+
# should "abort when user enters 'abort' into the API login field" do
|
112
|
+
# with_users "no_credentials"
|
113
|
+
#
|
114
|
+
# when_asked "Webbynode Login:", :answer => 'abort'
|
115
|
+
# command "server add webbynode sandbox"
|
116
|
+
#
|
117
|
+
# stdout.should =~ /Aborted adding server./
|
118
|
+
# stdout.should =~ /Enter your Webbynode API credentials/
|
119
|
+
# end
|
120
|
+
#
|
121
|
+
# should "abort when user enters 'abort' into the API token field" do
|
122
|
+
# with_users "no_credentials"
|
123
|
+
#
|
124
|
+
# when_asked "Webbynode Login:", :answer => 'fcoury@me.com'
|
125
|
+
# when_asked "Webbynode Token:", :answer => 'abort'
|
126
|
+
#
|
127
|
+
# command "server add webbynode sandbox"
|
128
|
+
#
|
129
|
+
# stdout.should =~ /Aborted adding server./
|
130
|
+
# stdout.should =~ /Enter your Webbynode API credentials/
|
131
|
+
# end
|
132
|
+
#
|
133
|
+
# should "show the help message when user enters 'help' into the API login field" do
|
134
|
+
# with_users "no_credentials"
|
135
|
+
#
|
136
|
+
# when_asked "Webbynode Login:", :answer => 'help'
|
137
|
+
# when_asked "Webbynode Login:", :answer => 'abort'
|
138
|
+
# command "server add webbynode sandbox"
|
139
|
+
#
|
140
|
+
# stdout.should =~ /== Webbynode StackFu integration ==/
|
141
|
+
# end
|
142
|
+
#
|
143
|
+
# should "ask for credentials when none were given before" do
|
144
|
+
# with_users "no_credentials"
|
145
|
+
# with_users_add
|
146
|
+
# with_server_add
|
147
|
+
#
|
148
|
+
# when_asked "Webbynode Login:", :answer => 'fcoury@me.com'
|
149
|
+
# when_asked "Webbynode Token:", :answer => 'abc123456'
|
150
|
+
#
|
151
|
+
# command "server add webbynode sandbox"
|
152
|
+
# stdout.should =~ /Webbynode credentials saved./
|
153
|
+
# stdout.should =~ /Server sandbox added successfully/
|
154
|
+
# end
|
155
|
+
#
|
156
|
+
# should "add the server if proper credentials given" do
|
157
|
+
# with_users
|
158
|
+
# with_users_add
|
159
|
+
# with_server_add
|
160
|
+
#
|
161
|
+
# command "server add webbynode sandbox"
|
162
|
+
# stdout.should =~ /Server sandbox added successfully/
|
163
|
+
# end
|
164
|
+
#
|
165
|
+
# should "delete the server if proper credentials given and server exists" do
|
166
|
+
# with_users
|
167
|
+
# with_server_list("webbynode")
|
168
|
+
# with_server_delete
|
169
|
+
#
|
170
|
+
# command "server delete sandbox"
|
171
|
+
# stdout.should =~ /Server sandbox deleted successfully/
|
172
|
+
# end
|
173
|
+
#
|
174
|
+
# should "show the webbynode server when listing servers" do
|
175
|
+
# with_users
|
176
|
+
# with_server_list("webbynode")
|
177
|
+
#
|
178
|
+
# command "server"
|
179
|
+
# stdout.should =~ /Name/
|
180
|
+
# stdout.should =~ /Provider/
|
181
|
+
# stdout.should =~ /IP/
|
182
|
+
# stdout.should =~ /Status/
|
183
|
+
#
|
184
|
+
# stdout.should =~ /sandbox/
|
185
|
+
# stdout.should =~ /Webbynode/
|
186
|
+
# stdout.should =~ /208\.88\.125\.207/
|
187
|
+
# stdout.should =~ /running/
|
188
|
+
# end
|
189
|
+
# end
|
190
|
+
#
|
191
|
+
# context "adding a slicehost server" do
|
192
|
+
# should "abort when user enters 'abort' into the API password field" do
|
193
|
+
# with_users "no_credentials"
|
194
|
+
#
|
195
|
+
# when_asked "", :answer => 'abort'
|
196
|
+
# command "server add slicehost slicey"
|
197
|
+
#
|
198
|
+
# stdout.should =~ /Aborted adding server./
|
199
|
+
# stdout.should =~ /Enter your Slicehost API password/
|
200
|
+
# end
|
201
|
+
#
|
202
|
+
# should "show the help message when user enters 'help' into the API password field" do
|
203
|
+
# with_users "no_credentials"
|
204
|
+
#
|
205
|
+
# when_asked "", :answer => 'help'
|
206
|
+
# when_asked "", :answer => 'abort'
|
207
|
+
# command "server add slicehost slicey"
|
208
|
+
#
|
209
|
+
# stdout.should =~ /== Slicehost StackFu integration ==/
|
210
|
+
# end
|
211
|
+
#
|
212
|
+
# should "ask for credentials when none were given before" do
|
213
|
+
# with_users "no_credentials"
|
214
|
+
# with_users_add
|
215
|
+
# with_server_add
|
216
|
+
#
|
217
|
+
# when_asked "", :answer => "abc123"
|
218
|
+
#
|
219
|
+
# command "server add slicehost slicey"
|
220
|
+
# stdout.should =~ /Server slicey added successfully/
|
221
|
+
# end
|
222
|
+
#
|
223
|
+
# should "add the server if proper credentials given" do
|
224
|
+
# with_users
|
225
|
+
# with_users_add
|
226
|
+
# with_server_add
|
227
|
+
#
|
228
|
+
# command "server add slicehost slicey"
|
229
|
+
# stdout.should =~ /Server slicey added successfully/
|
230
|
+
# end
|
231
|
+
#
|
232
|
+
# should "delete the server if proper credentials given and server exists" do
|
233
|
+
# with_users
|
234
|
+
# with_server_list
|
235
|
+
# with_server_delete
|
236
|
+
#
|
237
|
+
# command "server delete slicey"
|
238
|
+
# stdout.should =~ /Server slicey deleted successfully/
|
239
|
+
# end
|
240
|
+
#
|
241
|
+
# should "show a selection when same server hostname repeats in more than one provider"
|
242
|
+
#
|
243
|
+
# should "show the slicehost server when listing servers" do
|
244
|
+
# with_users
|
245
|
+
# with_server_list
|
246
|
+
#
|
247
|
+
# command "server"
|
248
|
+
# stdout.should =~ /Name/
|
249
|
+
# stdout.should =~ /Provider/
|
250
|
+
# stdout.should =~ /IP/
|
251
|
+
# stdout.should =~ /Status/
|
252
|
+
#
|
253
|
+
# stdout.should =~ /slicey/
|
254
|
+
# stdout.should =~ /Slicehost/
|
255
|
+
# stdout.should =~ /174\.143\.145\.37/
|
256
|
+
# stdout.should =~ /running/
|
257
|
+
# end
|
258
|
+
# end
|
259
|
+
# end
|