logical-construct 0.0.5 → 0.1.0

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.
Files changed (77) hide show
  1. data/bin/flight-deck +3 -0
  2. data/doc/DESIGN +48 -0
  3. data/doc/EC2-baking-notes +70 -0
  4. data/doc/ExampleStartupRakefile +152 -0
  5. data/doc/ExampleTargetRakefile +4 -0
  6. data/doc/TODO +148 -0
  7. data/doc/Vb-EC2-translation-notes +96 -0
  8. data/doc/hating-chef +32 -0
  9. data/lib/logical-construct/archive-tasks.rb +307 -0
  10. data/lib/logical-construct/ground-control.rb +4 -1
  11. data/lib/logical-construct/ground-control/build-plan.rb +95 -0
  12. data/lib/logical-construct/ground-control/core.rb +1 -1
  13. data/lib/logical-construct/ground-control/generate-manifest.rb +67 -0
  14. data/lib/logical-construct/ground-control/provision.rb +73 -168
  15. data/lib/logical-construct/ground-control/run-on-target.rb +1 -1
  16. data/lib/logical-construct/ground-control/setup.rb +1 -4
  17. data/lib/logical-construct/ground-control/setup/copy-files.rb +2 -2
  18. data/lib/logical-construct/ground-control/tools.rb +66 -0
  19. data/lib/logical-construct/node-client.rb +112 -0
  20. data/lib/logical-construct/plan.rb +2 -0
  21. data/lib/logical-construct/plan/core.rb +45 -0
  22. data/lib/logical-construct/plan/standalone-bundle.rb +80 -0
  23. data/lib/logical-construct/port-open-check.rb +41 -0
  24. data/lib/logical-construct/protocol.rb +2 -0
  25. data/lib/logical-construct/protocol/plan-validation.rb +46 -0
  26. data/lib/logical-construct/protocol/ssh-tunnel.rb +127 -0
  27. data/lib/logical-construct/protocol/vocabulary.rb +8 -0
  28. data/lib/logical-construct/target/Implement.rake +8 -0
  29. data/lib/logical-construct/target/command-line.rb +90 -0
  30. data/lib/logical-construct/target/flight-deck.rb +341 -0
  31. data/lib/logical-construct/target/implementation.rb +33 -0
  32. data/lib/logical-construct/target/plan-records.rb +317 -0
  33. data/lib/logical-construct/target/resolution-server.rb +153 -0
  34. data/lib/logical-construct/target/{unpack-cookbook.rb → unpack-plan.rb} +8 -4
  35. data/lib/logical-construct/template-file.rb +41 -0
  36. data/lib/templates/Rakefile.erb +8 -0
  37. data/spec/ground-control/smoke-test.rb +8 -7
  38. data/spec/node_resolution.rb +62 -0
  39. data/spec/target/plan-records.rb +142 -0
  40. data/spec/target/provisioning.rb +21 -0
  41. data/spec_help/file-sandbox.rb +12 -6
  42. data/spec_help/fixtures/Manifest +1 -0
  43. data/spec_help/fixtures/source/one.tbz +1 -0
  44. data/spec_help/fixtures/source/three.tbz +1 -0
  45. data/spec_help/fixtures/source/two.tbz +1 -0
  46. data/spec_help/spec_helper.rb +5 -7
  47. metadata +165 -72
  48. data/lib/logical-construct/ground-control/setup/build-files.rb +0 -93
  49. data/lib/logical-construct/ground-control/setup/create-construct-directory.rb +0 -22
  50. data/lib/logical-construct/ground-control/setup/install-init.rb +0 -32
  51. data/lib/logical-construct/resolving-task.rb +0 -141
  52. data/lib/logical-construct/satisfiable-task.rb +0 -87
  53. data/lib/logical-construct/target.rb +0 -4
  54. data/lib/logical-construct/target/chef-solo.rb +0 -37
  55. data/lib/logical-construct/target/platforms.rb +0 -51
  56. data/lib/logical-construct/target/platforms/aws.rb +0 -8
  57. data/lib/logical-construct/target/platforms/default/chef-config.rb +0 -134
  58. data/lib/logical-construct/target/platforms/default/resolve-configuration.rb +0 -44
  59. data/lib/logical-construct/target/platforms/default/volume.rb +0 -11
  60. data/lib/logical-construct/target/platforms/virtualbox.rb +0 -8
  61. data/lib/logical-construct/target/platforms/virtualbox/volume.rb +0 -15
  62. data/lib/logical-construct/target/provision.rb +0 -36
  63. data/lib/logical-construct/target/sinatra-resolver.rb +0 -99
  64. data/lib/logical-construct/testing/resolve-configuration.rb +0 -32
  65. data/lib/logical-construct/testing/resolving-task.rb +0 -15
  66. data/lib/templates/chef.rb.erb +0 -9
  67. data/lib/templates/construct.init.d.erb +0 -18
  68. data/lib/templates/resolver/finished.html.erb +0 -1
  69. data/lib/templates/resolver/index.html.erb +0 -17
  70. data/lib/templates/resolver/task-file-form.html.erb +0 -6
  71. data/lib/templates/resolver/task-form.html.erb +0 -6
  72. data/spec/resolution.rb +0 -147
  73. data/spec/target/chef-config.rb +0 -67
  74. data/spec/target/chef-solo.rb +0 -55
  75. data/spec/target/platforms.rb +0 -36
  76. data/spec/target/smoke-test.rb +0 -45
  77. data/spec_help/ungemmer.rb +0 -36
@@ -1,8 +0,0 @@
1
- require 'logical-construct/target/platforms'
2
-
3
- module LogicalConstruct
4
- module AWS
5
- extend PlatformSpecific
6
- register_platform('aws')
7
- end
8
- end
@@ -1,134 +0,0 @@
1
- require 'mattock/tasklib'
2
- require 'mattock/template-host'
3
- require 'mattock/command-line'
4
- require 'logical-construct/satisfiable-task'
5
-
6
- module LogicalConstruct
7
- module Default
8
- #XXX Should get broken into at least 2 smaller tasklibs
9
- class ChefConfig < Mattock::Tasklib
10
- include Mattock::TemplateHost
11
- default_namespace :chef_config
12
-
13
- required_field :construct_dir
14
- required_fields :cookbook_path, :data_bags_path, :json_attribs,
15
- :cookbook_tarball_path, :file_cache_path, :secret_data_tarball_path, :normal_data_tarball_path
16
- required_field :valise
17
- settings :solo_rb => "/etc/chef/solo.rb",
18
- :etc_chef => "/etc/chef",
19
- :data_bags_relpath => "data-bags",
20
- :cookbook_relpath => "cookbooks",
21
- :cookbook_tarball_relpath => "cookbooks.tgz",
22
- :secret_data_tarball_relpath => "secret_data.tgz",
23
- :normal_data_tarball_relpath => "normal_data.tgz",
24
- :json_attribs_relpath => "node.json"
25
-
26
- setting :resolution
27
-
28
- nil_fields :recipe_url, :role_path, :role_relpath
29
-
30
- def default_configuration(provision, resolution)
31
- super
32
- self.construct_dir = provision.construct_dir
33
- self.valise = provision.valise
34
- self.resolution = resolution
35
- end
36
-
37
- #XXX Hints about decomposing this Tasklib: there are settings for
38
- #chef/solo.rb, which are only incidentally related to the tarball
39
- #unpacking tasks - which are themselves closely related
40
- def resolve_configuration
41
- if unset?(file_cache_path)
42
- self.file_cache_path = File::expand_path('chef', construct_dir)
43
- end
44
- self.file_cache_path = File::expand_path(file_cache_path)
45
-
46
- if unset?(cookbook_path) and !cookbook_relpath.nil?
47
- self.cookbook_path = File::expand_path(cookbook_relpath, file_cache_path)
48
- end
49
-
50
- if unset?(data_bags_path) and !data_bags_relpath.nil?
51
- self.data_bags_path = File::expand_path(data_bags_relpath, file_cache_path)
52
- end
53
-
54
- if unset?(cookbook_tarball_path) and !cookbook_tarball_relpath.nil?
55
- self.cookbook_tarball_path = File::expand_path(cookbook_tarball_relpath, file_cache_path)
56
- end
57
-
58
- if unset?(secret_data_tarball_path) and !secret_data_tarball_relpath.nil?
59
- self.secret_data_tarball_path = File::expand_path(secret_data_tarball_relpath, file_cache_path)
60
- end
61
-
62
- if unset?(normal_data_tarball_path) and !normal_data_tarball_relpath.nil?
63
- self.normal_data_tarball_path = File::expand_path(normal_data_tarball_relpath, file_cache_path)
64
- end
65
-
66
- self.solo_rb = File::expand_path(solo_rb, file_cache_path)
67
-
68
- if unset?(json_attribs) and !json_attribs_relpath.nil?
69
- self.json_attribs = File::expand_path(json_attribs_relpath, file_cache_path)
70
- end
71
-
72
- if role_path.nil? and !role_relpath.nil?
73
- self.role_path = File::expand_path(role_relpath, file_cache_path)
74
- end
75
- super
76
- end
77
-
78
- include Mattock::CommandLineDSL
79
- def define
80
- in_namespace do
81
- directory etc_chef
82
- directory file_cache_path
83
-
84
- Mattock::CommandTask.new(:unpack_cookbooks => :cookbook_tarball) do |task|
85
- task.command = cmd("cd", file_cache_path) & cmd("tar", "-xzf", cookbook_tarball_path)
86
- end
87
-
88
- Mattock::CommandTask.new(:unpack_secret_data => :secret_data_tarball) do |task|
89
- task.command = cmd("cd", file_cache_path) & cmd("tar", "-xzf", secret_data_tarball_path)
90
- end
91
-
92
- Mattock::CommandTask.new(:unpack_normal_data => :normal_data_tarball) do |task|
93
- task.command = cmd("cd", file_cache_path) & cmd("tar", "-xzf", normal_data_tarball_path)
94
- end
95
-
96
- file solo_rb => [etc_chef, :json_attribs, :unpack_cookbooks, :unpack_secret_data, :unpack_normal_data] do
97
- File::open(solo_rb, "w") do |file|
98
- file.write(render("chef.rb.erb"))
99
- end
100
- end
101
-
102
- resolution.add_file(SatisfiableFileTask.new(:json_attribs => file_cache_path) do |task|
103
- task.target_path = json_attribs
104
- end)
105
-
106
- resolution.add_file(SatisfiableFileTask.new(:cookbook_tarball => file_cache_path) do |task|
107
- task.target_path = cookbook_tarball_path
108
- end)
109
-
110
- resolution.add_file(SatisfiableFileTask.new(:secret_data_tarball => file_cache_path) do |task|
111
- task.target_path = secret_data_tarball_path
112
- end)
113
-
114
- resolution.add_file(SatisfiableFileTask.new(:normal_data_tarball => file_cache_path) do |task|
115
- task.target_path = normal_data_tarball_path
116
- end)
117
-
118
- unless role_path.nil?
119
- directory role_path
120
- file solo_rb => role_path
121
- end
122
-
123
- desc "Delete all the chef config files (to re-provision)"
124
- task :clobber do
125
- cmd("rm", "-rf", file_cache_path)
126
- end
127
- end
128
-
129
- file solo_rb => resolution[:Manifest]
130
- task :build_configs => solo_rb
131
- end
132
- end
133
- end
134
- end
@@ -1,44 +0,0 @@
1
- require 'logical-construct/target/sinatra-resolver'
2
- module LogicalConstruct
3
- module Default
4
- class ResolveConfiguration < Mattock::Tasklib
5
- default_namespace 'configuration'
6
-
7
- setting :bind, '0.0.0.0'
8
- setting :port, 51076
9
- setting :valise
10
-
11
- def initialize(*args, &block)
12
- @pending_satisfiables = []
13
- @resolver = nil
14
- @manifest = nil
15
- super
16
- end
17
-
18
- def default_configuration(provision)
19
- super
20
- self.valise = provision.valise
21
- end
22
-
23
- def add_file(file_satisfiable)
24
- if @resolver.nil?
25
- @pending_satifiables << file_satisfiable
26
- else
27
- @resolver.add_satisfiable(file_satisfiable)
28
- @manifest.add_satisfiable(file_satisfiable)
29
- end
30
- end
31
-
32
- def define
33
- in_namespace do
34
- @manifest = LogicalConstruct::Manifest.new(*@pending_satisfiables)
35
-
36
- @resolver = LogicalConstruct::SinatraResolver.new(*([@manifest] + @pending_satisfiables)) do |task|
37
- copy_settings_to(task)
38
- end
39
- @pending_satisfiables.clear
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,11 +0,0 @@
1
- require 'mattock/tasklib'
2
-
3
- module LogicalConstruct
4
- module Default
5
- class Volume < Mattock::Tasklib
6
- def define
7
-
8
- end
9
- end
10
- end
11
- end
@@ -1,8 +0,0 @@
1
- require 'logical-construct/target/platforms'
2
-
3
- module LogicalConstruct
4
- module VirtualBox
5
- extend PlatformSpecific
6
- register_platform('virtualbox')
7
- end
8
- end
@@ -1,15 +0,0 @@
1
- require 'logical-construct/target/platforms/virtualbox'
2
-
3
- module LogicalConstruct
4
- module VirtualBox
5
- class Volume < Default::Volume
6
- def define
7
- Mattock::CommandTask.new(self) do |task|
8
- task.command = Mattock::CommandLine.new("mount") do |mount|
9
- mount.options = [device, mountpoint]
10
- end
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,36 +0,0 @@
1
- require 'mattock'
2
- require 'mattock/template-host'
3
-
4
- module LogicalConstruct
5
- class Provision < Mattock::Tasklib
6
- include Mattock::ValiseManager
7
- extend Mattock::ValiseManager
8
-
9
- settings(
10
- :construct_dir => "/var/logical-construct",
11
- :attr_source => nil,
12
- :config_path => nil
13
- )
14
- setting :valise
15
- setting :construct_bin_path
16
- setting :search_paths, [rel_dir(__FILE__)]
17
-
18
- def resolve_configuration
19
- self.valise = default_valise(search_paths)
20
- self.construct_bin_path ||= File::expand_path("bin", construct_dir)
21
- self.construct_bin_path = File::absolute_path(construct_bin_path)
22
- super
23
- end
24
-
25
- def define
26
- task_spine(:preflight, :approve_host, :build_configs, :provision)
27
-
28
- task :bundled_path do
29
- unless ENV['PATH'] =~ /(?:^|:)#{construct_bin_path}(?::|$)/
30
- ENV['PATH'] = "#{construct_bin_path}:#{ENV['PATH']}"
31
- end
32
- end
33
- task :preflight => :bundled_path
34
- end
35
- end
36
- end
@@ -1,99 +0,0 @@
1
- require 'logical-construct/resolving-task'
2
- require 'mattock/task'
3
- require 'mattock/template-host'
4
- require 'sinatra'
5
-
6
- module LogicalConstruct
7
- class SinatraResolver < ResolvingTask
8
- include Mattock::TemplateHost
9
-
10
- include ResolutionProtocol
11
-
12
- def build_collector(resolver, prereqs)
13
- klass = Class.new(Sinatra::Application) do
14
- class << self
15
- attr_accessor :running_server
16
- end
17
-
18
- set :show_exceptions => true
19
-
20
- get '/' do
21
- resolver.render('resolver/index.html.erb')
22
- end
23
-
24
- prereqs.each do |task|
25
- path = resolver.web_path(task.name)
26
-
27
- get path do
28
- if task.prefer_file?
29
- resolver.render('resolver/task-file-form.html.erb') do |locals|
30
- locals[:task_path] = path
31
- end
32
- else
33
- resolver.render('resolver/task-form.html.erb') do |locals|
34
- locals[:task_path] = path
35
- end
36
- end
37
- end
38
-
39
- post path do
40
- if request.content_type =~ %r{multipart/form-data}
41
- task.receive(request.params["data"][:tempfile])
42
- else
43
- task.receive(request.params["data"])
44
- end
45
- if resolver.needed?
46
- redirect to("/")
47
- else
48
- resolver.render('resolver/finished.html.erb')
49
- quit!
50
- end
51
- end
52
- end
53
-
54
- def self.rack_handler
55
- handler = detect_rack_handler
56
- end
57
-
58
- def quit!
59
- self.class.quit!(self.class.running_server, "A server")
60
- end
61
- end
62
- return klass
63
- end
64
-
65
- setting :bind, "0.0.0.0"
66
- setting :port, 51076 #JDL's birthday
67
- setting :valise
68
-
69
- def action
70
- puts
71
- puts "STARTING WEB LISTENER TO RESOLVE PREREQUISITES"
72
- puts
73
-
74
- collector = build_collector(self, satisfiables)
75
- handler = collector.rack_handler
76
- handler_name = handler.name
77
-
78
- old_handlers = nil
79
- handler.run collector, :Host => bind, :Port => port do |server|
80
- old_handlers = Hash[
81
- [:INT, :TERM].map { |sig| [sig, trap(sig) { collector.quit!(server, handler_name) }] }
82
- ]
83
- collector.running_server = server
84
- if server.respond_to? :threaded=
85
- server.threaded = settings.threaded
86
- end
87
- puts "Listening on #{port} with #{handler.name}"
88
- end
89
-
90
- old_handlers.each_pair do |signal, handler|
91
- trap(signal, handler)
92
- end
93
-
94
- rescue Errno::EADDRINUSE => e
95
- puts "Port #{port} in use!"
96
- raise
97
- end
98
- end
99
- end
@@ -1,32 +0,0 @@
1
- require 'mattock/tasklib'
2
- require 'logical-construct/testing/resolving-task'
3
- require 'logical-construct/resolving-task'
4
-
5
- module LogicalConstruct
6
- module Testing
7
- class ResolveConfiguration < Mattock::Tasklib
8
- default_namespace 'configuration'
9
-
10
- setting :resolutions, {}
11
-
12
- def default_configuration(provision)
13
- super
14
- end
15
-
16
- def add_file(path)
17
- #that's nice, dear
18
- end
19
-
20
- def define
21
- in_namespace do
22
- LogicalConstruct::Testing::ResolvingTask.new do |task|
23
- task.task_name = "resolve"
24
- copy_settings_to(task)
25
- end
26
-
27
- LogicalConstruct::Manifest.new()
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,15 +0,0 @@
1
- require 'logical-construct/resolving-task'
2
-
3
- module LogicalConstruct
4
- module Testing
5
- class ResolvingTask < ::LogicalConstruct::ResolvingTask
6
- setting :resolutions, {}
7
-
8
- def action
9
- unsatisfied_prerequisites.each do |task|
10
- task.fulfill(resolutions.fetch(task.name))
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,9 +0,0 @@
1
- file_cache_path "<%= file_cache_path %>"
2
- cookbook_path "<%= cookbook_path %>"
3
- json_attribs "<%= json_attribs %>"
4
- <% unless role_path.nil? %>
5
- role_path "<%= role_path %>"
6
- <% end %>
7
- <% unless data_bags_path.nil? %>
8
- data_bag_path "<%= data_bags_path %>"
9
- <% end %>
@@ -1,18 +0,0 @@
1
- #!/sbin/runscript
2
-
3
- DIR='<%= extra[:construct_dir] %>'
4
-
5
- depend() {
6
- need net
7
- }
8
-
9
- start() {
10
- cd $DIR
11
- ebegin "Starting to provision using Logical Construct"
12
- LOGCON_DEPLOYMENT_PLATFORM=<%= extra[:platform] %> bin/rake
13
- eend $?
14
- }
15
-
16
- stop() {
17
- einfo "Stopping Logical Construct [noop]"
18
- }
@@ -1 +0,0 @@
1
- <p>Congratulations! That was all we needed, and we should be finishing up.</p>