infrataster 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/{example/.rspec → .rspec} +0 -0
  3. data/CHANGELOG.md +10 -0
  4. data/README.md +27 -1
  5. data/Rakefile +52 -0
  6. data/infrataster.gemspec +5 -1
  7. data/lib/infrataster/contexts/base_context.rb +3 -3
  8. data/lib/infrataster/contexts/capybara_context.rb +2 -2
  9. data/lib/infrataster/contexts/http_context.rb +18 -6
  10. data/lib/infrataster/contexts/mysql_query_context.rb +1 -1
  11. data/lib/infrataster/contexts.rb +7 -7
  12. data/lib/infrataster/helpers/resource_helper.rb +24 -0
  13. data/lib/infrataster/helpers.rb +1 -1
  14. data/lib/infrataster/{types/base_type.rb → resources/base_resource.rb} +3 -3
  15. data/lib/infrataster/{types/capybara_type.rb → resources/capybara_resource.rb} +3 -3
  16. data/lib/infrataster/resources/http_resource.rb +42 -0
  17. data/lib/infrataster/{types/mysql_query_type.rb → resources/mysql_query_resource.rb} +3 -3
  18. data/lib/infrataster/{types/server_type.rb → resources/server_resource.rb} +2 -2
  19. data/lib/infrataster/resources.rb +5 -0
  20. data/lib/infrataster/rspec.rb +1 -1
  21. data/lib/infrataster/server.rb +26 -15
  22. data/lib/infrataster/version.rb +1 -1
  23. data/lib/infrataster.rb +6 -2
  24. data/spec/integration/http_spec.rb +44 -0
  25. data/{example/spec → spec/integration}/spec_helper.rb +3 -10
  26. data/spec/integration/vm/.gitignore +3 -0
  27. data/spec/integration/vm/Berksfile +2 -0
  28. data/spec/integration/vm/Vagrantfile +38 -0
  29. data/{example/sinatra_app → spec/integration/vm/app}/Gemfile +0 -1
  30. data/spec/integration/vm/app/app.rb +39 -0
  31. data/{example/sinatra_app → spec/integration/vm/app}/config.ru +0 -0
  32. data/spec/integration/vm/cookbooks/app/files/default/rackup.conf +3 -0
  33. data/spec/integration/vm/cookbooks/app/recipes/default.rb +35 -0
  34. data/spec/integration/vm/cookbooks/apt-mirror/recipes/default.rb +4 -0
  35. data/spec/integration/vm/cookbooks/proxy/files/default/index.html +1 -0
  36. data/spec/integration/vm/cookbooks/proxy/recipes/default.rb +22 -0
  37. data/spec/integration/vm/cookbooks/proxy/templates/default/integration-test.erb +65 -0
  38. data/spec/unit/lib/infrataster/server_spec.rb +49 -0
  39. data/spec/unit/spec_helper.rb +23 -0
  40. metadata +72 -29
  41. data/example/.gitignore +0 -4
  42. data/example/Berksfile +0 -2
  43. data/example/Gemfile +0 -8
  44. data/example/README.md +0 -13
  45. data/example/Vagrantfile +0 -81
  46. data/example/cookbooks/app/recipes/default.rb +0 -36
  47. data/example/cookbooks/db/files/default/my.cnf +0 -127
  48. data/example/cookbooks/db/recipes/default.rb +0 -14
  49. data/example/cookbooks/proxy/metadata.rb +0 -1
  50. data/example/cookbooks/proxy/recipes/default.rb +0 -26
  51. data/example/cookbooks/proxy/templates/default/app.erb +0 -13
  52. data/example/cookbooks/proxy/templates/default/static.erb +0 -14
  53. data/example/sinatra_app/.gitignore +0 -1
  54. data/example/sinatra_app/app.rb +0 -6
  55. data/example/spec/web_spec.rb +0 -64
  56. data/lib/infrataster/helpers/type_helper.rb +0 -24
  57. data/lib/infrataster/types/http_type.rb +0 -24
  58. 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,13 +0,0 @@
1
- server {
2
- listen 80;
3
-
4
- root /usr/share/nginx/www;
5
- index index.html index.htm;
6
-
7
- server_name app;
8
-
9
- location / {
10
- proxy_pass http://<%= node['app_ip'] %>;
11
- }
12
- }
13
-
@@ -1,14 +0,0 @@
1
- server {
2
- listen 80;
3
-
4
- root /usr/share/nginx/www;
5
- index index.html index.htm;
6
-
7
- server_name static;
8
-
9
- location / {
10
- try_files $uri $uri/ /index.html;
11
- }
12
- }
13
-
14
-
@@ -1 +0,0 @@
1
- log
@@ -1,6 +0,0 @@
1
- require 'sinatra'
2
-
3
- get '/' do
4
- "Hello Sinatra!"
5
- end
6
-
@@ -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
-
@@ -1,5 +0,0 @@
1
- require 'infrataster/types/base_type'
2
- require 'infrataster/types/server_type'
3
- require 'infrataster/types/http_type'
4
- require 'infrataster/types/mysql_query_type'
5
- require 'infrataster/types/capybara_type'