infrataster 0.1.0 → 0.1.1
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 +4 -4
- data/{example/.rspec → .rspec} +0 -0
- data/CHANGELOG.md +10 -0
- data/README.md +27 -1
- data/Rakefile +52 -0
- data/infrataster.gemspec +5 -1
- data/lib/infrataster/contexts/base_context.rb +3 -3
- data/lib/infrataster/contexts/capybara_context.rb +2 -2
- data/lib/infrataster/contexts/http_context.rb +18 -6
- data/lib/infrataster/contexts/mysql_query_context.rb +1 -1
- data/lib/infrataster/contexts.rb +7 -7
- data/lib/infrataster/helpers/resource_helper.rb +24 -0
- data/lib/infrataster/helpers.rb +1 -1
- data/lib/infrataster/{types/base_type.rb → resources/base_resource.rb} +3 -3
- data/lib/infrataster/{types/capybara_type.rb → resources/capybara_resource.rb} +3 -3
- data/lib/infrataster/resources/http_resource.rb +42 -0
- data/lib/infrataster/{types/mysql_query_type.rb → resources/mysql_query_resource.rb} +3 -3
- data/lib/infrataster/{types/server_type.rb → resources/server_resource.rb} +2 -2
- data/lib/infrataster/resources.rb +5 -0
- data/lib/infrataster/rspec.rb +1 -1
- data/lib/infrataster/server.rb +26 -15
- data/lib/infrataster/version.rb +1 -1
- data/lib/infrataster.rb +6 -2
- data/spec/integration/http_spec.rb +44 -0
- data/{example/spec → spec/integration}/spec_helper.rb +3 -10
- data/spec/integration/vm/.gitignore +3 -0
- data/spec/integration/vm/Berksfile +2 -0
- data/spec/integration/vm/Vagrantfile +38 -0
- data/{example/sinatra_app → spec/integration/vm/app}/Gemfile +0 -1
- data/spec/integration/vm/app/app.rb +39 -0
- data/{example/sinatra_app → spec/integration/vm/app}/config.ru +0 -0
- data/spec/integration/vm/cookbooks/app/files/default/rackup.conf +3 -0
- data/spec/integration/vm/cookbooks/app/recipes/default.rb +35 -0
- data/spec/integration/vm/cookbooks/apt-mirror/recipes/default.rb +4 -0
- data/spec/integration/vm/cookbooks/proxy/files/default/index.html +1 -0
- data/spec/integration/vm/cookbooks/proxy/recipes/default.rb +22 -0
- data/spec/integration/vm/cookbooks/proxy/templates/default/integration-test.erb +65 -0
- data/spec/unit/lib/infrataster/server_spec.rb +49 -0
- data/spec/unit/spec_helper.rb +23 -0
- metadata +72 -29
- data/example/.gitignore +0 -4
- data/example/Berksfile +0 -2
- data/example/Gemfile +0 -8
- data/example/README.md +0 -13
- data/example/Vagrantfile +0 -81
- data/example/cookbooks/app/recipes/default.rb +0 -36
- data/example/cookbooks/db/files/default/my.cnf +0 -127
- data/example/cookbooks/db/recipes/default.rb +0 -14
- data/example/cookbooks/proxy/metadata.rb +0 -1
- data/example/cookbooks/proxy/recipes/default.rb +0 -26
- data/example/cookbooks/proxy/templates/default/app.erb +0 -13
- data/example/cookbooks/proxy/templates/default/static.erb +0 -14
- data/example/sinatra_app/.gitignore +0 -1
- data/example/sinatra_app/app.rb +0 -6
- data/example/spec/web_spec.rb +0 -64
- data/lib/infrataster/helpers/type_helper.rb +0 -24
- data/lib/infrataster/types/http_type.rb +0 -24
- data/lib/infrataster/types.rb +0 -5
@@ -1,14 +0,0 @@
|
|
1
|
-
include_recipe 'apt'
|
2
|
-
|
3
|
-
package 'mysql-server'
|
4
|
-
|
5
|
-
service 'mysql' do
|
6
|
-
supports(:restart => true)
|
7
|
-
end
|
8
|
-
|
9
|
-
cookbook_file '/etc/mysql/my.cnf' do
|
10
|
-
notifies :restart, 'service[mysql]'
|
11
|
-
end
|
12
|
-
|
13
|
-
execute "mysql -uroot -e \"GRANT ALL PRIVILEGES ON *.* TO 'app'@'#{node['app_ip']}' IDENTIFIED BY 'app';\""
|
14
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
depends 'apt'
|
@@ -1,26 +0,0 @@
|
|
1
|
-
include_recipe 'apt'
|
2
|
-
|
3
|
-
package "nginx" do
|
4
|
-
action :install
|
5
|
-
end
|
6
|
-
|
7
|
-
service "nginx" do
|
8
|
-
action :start
|
9
|
-
supports(:reload => true)
|
10
|
-
end
|
11
|
-
|
12
|
-
file "/etc/nginx/sites-enabled/default" do
|
13
|
-
action :delete
|
14
|
-
notifies :reload, 'service[nginx]'
|
15
|
-
end
|
16
|
-
|
17
|
-
%w!app static!.each do |app|
|
18
|
-
template "/etc/nginx/sites-available/#{app}" do
|
19
|
-
notifies :reload, 'service[nginx]'
|
20
|
-
end
|
21
|
-
|
22
|
-
link "/etc/nginx/sites-enabled/#{app}" do
|
23
|
-
to "/etc/nginx/sites-available/#{app}"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
log
|
data/example/sinatra_app/app.rb
DELETED
data/example/spec/web_spec.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe server(:app) do
|
4
|
-
describe http('http://app') do
|
5
|
-
it "responds content including 'Hello Sinatra'" do
|
6
|
-
expect(response.body).to include('Hello Sinatra')
|
7
|
-
end
|
8
|
-
it "responds as 'text/html'" do
|
9
|
-
expect(response.content_type).to eq('text/html')
|
10
|
-
end
|
11
|
-
it "responds OK 200" do
|
12
|
-
expect(response.code).to eq('200')
|
13
|
-
end
|
14
|
-
end
|
15
|
-
describe capybara('http://app') do
|
16
|
-
it "responds content including 'Hello Sinatra'" do
|
17
|
-
visit '/'
|
18
|
-
expect(page).to have_content('Hello Sinatra')
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe server(:db) do
|
24
|
-
describe mysql_query('SHOW STATUS') do
|
25
|
-
it 'responds uptime' do
|
26
|
-
row = results.find {|r| r['Variable_name'] == 'Uptime' }
|
27
|
-
expect(row['Value'].to_i).to be > 0
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe server(:proxy) do
|
33
|
-
describe http('http://app') do
|
34
|
-
it "responds content including 'Hello Sinatra'" do
|
35
|
-
expect(response.body).to include('Hello Sinatra')
|
36
|
-
end
|
37
|
-
it "responds as 'text/html'" do
|
38
|
-
expect(response.content_type).to eq('text/html')
|
39
|
-
end
|
40
|
-
end
|
41
|
-
describe http('http://static') do
|
42
|
-
it "responds content including 'Welcome to nginx!'" do
|
43
|
-
expect(response.body).to include('Welcome to nginx!')
|
44
|
-
end
|
45
|
-
it "responds as 'text/html'" do
|
46
|
-
expect(response.content_type).to eq('text/html')
|
47
|
-
end
|
48
|
-
end
|
49
|
-
describe capybara('http://app') do
|
50
|
-
it "responds content including 'Hello Sinatra'" do
|
51
|
-
visit '/'
|
52
|
-
expect(page).to have_content('Hello Sinatra')
|
53
|
-
end
|
54
|
-
end
|
55
|
-
describe capybara('http://static') do
|
56
|
-
it "responds content including 'Welcome to nginx!'" do
|
57
|
-
visit '/'
|
58
|
-
expect(page).to have_content('Welcome to nginx!')
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
|
64
|
-
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'infrataster/types'
|
2
|
-
|
3
|
-
module Infrataster
|
4
|
-
module Helpers
|
5
|
-
module TypeHelper
|
6
|
-
def server(*args)
|
7
|
-
Types::ServerType.new(*args)
|
8
|
-
end
|
9
|
-
|
10
|
-
def http(*args)
|
11
|
-
Types::HttpType.new(*args)
|
12
|
-
end
|
13
|
-
|
14
|
-
def mysql_query(*args)
|
15
|
-
Types::MysqlQueryType.new(*args)
|
16
|
-
end
|
17
|
-
|
18
|
-
def capybara(*args)
|
19
|
-
Types::CapybaraType.new(*args)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'infrataster/types/base_type'
|
2
|
-
require 'uri'
|
3
|
-
|
4
|
-
module Infrataster
|
5
|
-
module Types
|
6
|
-
class HttpType < BaseType
|
7
|
-
Error = Class.new(StandardError)
|
8
|
-
|
9
|
-
attr_reader :uri
|
10
|
-
|
11
|
-
def initialize(url_str)
|
12
|
-
@uri = URI.parse(url_str)
|
13
|
-
unless %w!http https!.include?(@uri.scheme)
|
14
|
-
raise Error, "The provided url, '#{@uri}', is not http or https."
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def to_s
|
19
|
-
"http '#{@uri}'"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|