corl 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/Gemfile +5 -10
  2. data/Gemfile.lock +13 -11
  3. data/README.rdoc +1 -1
  4. data/Rakefile +3 -3
  5. data/VERSION +1 -1
  6. data/bin/corl +2 -54
  7. data/bootstrap/bootstrap.sh +91 -0
  8. data/bootstrap/lib/shell/LICENSE.txt +674 -0
  9. data/bootstrap/lib/shell/command.sh +214 -0
  10. data/bootstrap/lib/shell/filesystem.sh +139 -0
  11. data/bootstrap/lib/shell/load.sh +73 -0
  12. data/bootstrap/lib/shell/os.sh +67 -0
  13. data/bootstrap/lib/shell/script.sh +160 -0
  14. data/bootstrap/lib/shell/starter.sh +64 -0
  15. data/bootstrap/lib/shell/validators.sh +50 -0
  16. data/bootstrap/os/ubuntu/00_base.sh +5 -0
  17. data/bootstrap/os/ubuntu/01_git.sh +5 -0
  18. data/bootstrap/os/ubuntu/05_ruby.sh +7 -0
  19. data/bootstrap/os/ubuntu/06_puppet.sh +38 -0
  20. data/bootstrap/os/ubuntu/10_corl.sh +9 -0
  21. data/corl.gemspec +61 -124
  22. data/lib/{corl → CORL}/action/bootstrap.rb +13 -7
  23. data/lib/CORL/action/exec.rb +39 -0
  24. data/lib/CORL/action/image.rb +31 -0
  25. data/lib/{corl → CORL}/action/images.rb +1 -1
  26. data/lib/CORL/action/lookup.rb +34 -0
  27. data/lib/{corl → CORL}/action/machines.rb +1 -1
  28. data/lib/CORL/action/provision.rb +31 -0
  29. data/lib/{corl → CORL}/action/seed.rb +3 -3
  30. data/lib/{corl → CORL}/action/spawn.rb +2 -2
  31. data/lib/CORL/action/start.rb +31 -0
  32. data/lib/CORL/action/stop.rb +31 -0
  33. data/lib/{corl → CORL}/configuration/file.rb +1 -1
  34. data/lib/{corl → CORL}/event/puppet.rb +1 -1
  35. data/lib/{corl → CORL}/extension/puppetloader.rb +1 -1
  36. data/lib/{corl → CORL}/machine/fog.rb +3 -3
  37. data/lib/{corl → CORL}/machine/physical.rb +2 -2
  38. data/lib/{corl → CORL}/network/default.rb +1 -1
  39. data/lib/{corl → CORL}/node/aws.rb +0 -4
  40. data/lib/{corl → CORL}/node/google.rb +0 -4
  41. data/lib/{corl → CORL}/node/local.rb +1 -1
  42. data/lib/{corl → CORL}/node/rackspace.rb +0 -4
  43. data/lib/{corl → CORL}/provisioner/puppetnode.rb +1 -14
  44. data/lib/{corl → CORL}/provisioner/puppetnode/resource.rb +0 -0
  45. data/lib/{corl → CORL}/provisioner/puppetnode/resource_group.rb +0 -0
  46. data/lib/{corl → CORL}/template/environment.rb +1 -1
  47. data/lib/core/facade.rb +49 -0
  48. data/lib/{corl_core → core}/mixin/action/keypair.rb +10 -10
  49. data/lib/{corl_core → core}/mixin/lookup.rb +0 -0
  50. data/lib/{corl_core → core}/mod/hiera_backend.rb +0 -0
  51. data/lib/{corl_core/mixin/action/node.rb → core/plugin/action.rb} +66 -33
  52. data/lib/{corl_core → core}/plugin/configuration.rb +2 -2
  53. data/lib/{corl/node → core/plugin}/fog.rb +5 -1
  54. data/lib/{corl_core → core}/plugin/machine.rb +2 -2
  55. data/lib/{corl_core → core}/plugin/network.rb +4 -4
  56. data/lib/{corl_core → core}/plugin/node.rb +11 -9
  57. data/lib/{corl_core → core}/plugin/provisioner.rb +2 -2
  58. data/lib/{corl_core → core}/util/ssh.rb +1 -1
  59. data/lib/corl.rb +53 -112
  60. data/lib/puppet/parser/functions/ensure.rb +0 -4
  61. data/locales/en.yml +55 -148
  62. metadata +84 -222
  63. data/lib/corl/action/add.rb +0 -69
  64. data/lib/corl/action/clone.rb +0 -40
  65. data/lib/corl/action/create.rb +0 -55
  66. data/lib/corl/action/exec.rb +0 -41
  67. data/lib/corl/action/extract.rb +0 -49
  68. data/lib/corl/action/image.rb +0 -30
  69. data/lib/corl/action/lookup.rb +0 -35
  70. data/lib/corl/action/provision.rb +0 -37
  71. data/lib/corl/action/remove.rb +0 -51
  72. data/lib/corl/action/save.rb +0 -53
  73. data/lib/corl/action/start.rb +0 -37
  74. data/lib/corl/action/stop.rb +0 -30
  75. data/lib/corl/action/update.rb +0 -37
  76. data/lib/corl/command/shell.rb +0 -164
  77. data/lib/corl/event/regex.rb +0 -52
  78. data/lib/corl/project/git.rb +0 -465
  79. data/lib/corl/project/github.rb +0 -108
  80. data/lib/corl/template/json.rb +0 -16
  81. data/lib/corl/template/wrapper.rb +0 -16
  82. data/lib/corl/template/yaml.rb +0 -16
  83. data/lib/corl/translator/json.rb +0 -27
  84. data/lib/corl/translator/yaml.rb +0 -27
  85. data/lib/corl_core/codes.rb +0 -107
  86. data/lib/corl_core/config.rb +0 -337
  87. data/lib/corl_core/config/collection.rb +0 -57
  88. data/lib/corl_core/config/options.rb +0 -70
  89. data/lib/corl_core/core.rb +0 -59
  90. data/lib/corl_core/corl.rb +0 -254
  91. data/lib/corl_core/errors.rb +0 -84
  92. data/lib/corl_core/facade.rb +0 -126
  93. data/lib/corl_core/gems.rb +0 -72
  94. data/lib/corl_core/manager.rb +0 -425
  95. data/lib/corl_core/mixin/action/commit.rb +0 -58
  96. data/lib/corl_core/mixin/action/project.rb +0 -53
  97. data/lib/corl_core/mixin/action/push.rb +0 -52
  98. data/lib/corl_core/mixin/config/collection.rb +0 -53
  99. data/lib/corl_core/mixin/config/ops.rb +0 -53
  100. data/lib/corl_core/mixin/config/options.rb +0 -39
  101. data/lib/corl_core/mixin/macro/object_interface.rb +0 -361
  102. data/lib/corl_core/mixin/macro/plugin_interface.rb +0 -380
  103. data/lib/corl_core/mixin/settings.rb +0 -46
  104. data/lib/corl_core/mixin/sub_config.rb +0 -148
  105. data/lib/corl_core/mod/hash.rb +0 -29
  106. data/lib/corl_core/plugin/action.rb +0 -381
  107. data/lib/corl_core/plugin/base.rb +0 -374
  108. data/lib/corl_core/plugin/command.rb +0 -98
  109. data/lib/corl_core/plugin/event.rb +0 -53
  110. data/lib/corl_core/plugin/extension.rb +0 -12
  111. data/lib/corl_core/plugin/project.rb +0 -927
  112. data/lib/corl_core/plugin/template.rb +0 -80
  113. data/lib/corl_core/plugin/translator.rb +0 -38
  114. data/lib/corl_core/util/cli.rb +0 -352
  115. data/lib/corl_core/util/data.rb +0 -404
  116. data/lib/corl_core/util/disk.rb +0 -114
  117. data/lib/corl_core/util/git.rb +0 -47
  118. data/lib/corl_core/util/interface.rb +0 -319
  119. data/lib/corl_core/util/liquid.rb +0 -17
  120. data/lib/corl_core/util/package.rb +0 -93
  121. data/lib/corl_core/util/shell.rb +0 -239
  122. data/spec/corl_core/interface_spec.rb +0 -489
@@ -1,7 +1,7 @@
1
1
 
2
2
  module CORL
3
3
  module Provisioner
4
- class Puppetnode < Plugin::Provisioner
4
+ class Puppetnode < CORL.plugin_class(:provisioner)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Provisioner plugin interface
@@ -25,19 +25,6 @@ class Puppetnode < Plugin::Provisioner
25
25
  register
26
26
  end
27
27
 
28
- #---
29
-
30
- def register
31
- # Register Puppet CORL extensions
32
- env.modules.each do |mod|
33
- lib_dir = File.join(mod.path, 'lib', 'corl')
34
- if File.directory?(lib_dir)
35
- logger.debug("Registering Puppet module at #{lib_dir}")
36
- Manager.connection.register(lib_dir)
37
- end
38
- end
39
- end
40
-
41
28
  #-----------------------------------------------------------------------------
42
29
  # Property accessor / modifiers
43
30
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  module CORL
3
3
  module Template
4
- class Environment < Plugin::Template
4
+ class Environment < CORL.plugin_class(:template)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Renderers
@@ -0,0 +1,49 @@
1
+
2
+ module CORL
3
+ module Facade
4
+
5
+ #-----------------------------------------------------------------------------
6
+ # Core plugin type facade
7
+
8
+ def configuration(options, provider = nil)
9
+ plugin(:configuration, provider, options)
10
+ end
11
+
12
+ def configurations(data, build_hash = false, keep_array = false)
13
+ plugins(:configuration, data, build_hash, keep_array)
14
+ end
15
+
16
+ #-----------------------------------------------------------------------------
17
+ # Cluster plugin type facade
18
+
19
+ def network(name, options = {}, provider = nil)
20
+ plugin(:network, provider, Config.ensure(options).import({ :name => name }))
21
+ end
22
+
23
+ def networks(data, build_hash = false, keep_array = false)
24
+ plugins(:network, data, build_hash, keep_array)
25
+ end
26
+
27
+ #---
28
+
29
+ def node(name, options = {}, provider = nil)
30
+ plugin(:node, provider, Config.ensure(options).import({ :name => name }))
31
+ end
32
+
33
+ def nodes(data, build_hash = false, keep_array = false)
34
+ plugins(:node, data, build_hash, keep_array)
35
+ end
36
+
37
+ #---
38
+
39
+ def provisioner(options, provider = nil)
40
+ plugin(:provisioner, provider, options)
41
+ end
42
+
43
+ #---
44
+
45
+ def provisioners(data, build_hash = false, keep_array = false)
46
+ plugins(:provisioner, data, build_hash, keep_array)
47
+ end
48
+ end
49
+ end
@@ -8,41 +8,41 @@ module Keypair
8
8
  # Options
9
9
 
10
10
  def keypair_config
11
- register :private_key, :str, nil, 'corl.core.mixins.keypair.options.private_key' do |value|
11
+ register :private_key, :str, nil, 'corl.core.mixin.action.keypair.options.private_key' do |value|
12
12
  success = true
13
13
  if value
14
14
  file = File.expand_path(value)
15
15
  if File.exists?(file)
16
16
  unless Util::SSH.generate({ :private_key => file })
17
- warn('corl.core.mixins.keypair.errors.private_key_parse_error', { :value => file })
17
+ warn('corl.core.mixin.action.keypair.errors.private_key_parse_error', { :value => file })
18
18
  success = false
19
19
  end
20
20
  else
21
- warn('corl.core.mixins.keypair.errors.private_key_not_found', { :value => file })
21
+ warn('corl.core.mixin.action.keypair.errors.private_key_not_found', { :value => file })
22
22
  success = false
23
23
  end
24
24
  end
25
25
  success
26
26
  end
27
27
 
28
- register :require_password, :bool, false, 'corl.core.mixins.keypair.options.require_password'
28
+ register :require_password, :bool, false, 'corl.core.mixin.action.keypair.options.require_password'
29
29
 
30
- register :key_type, :str, 'RSA', 'corl.core.mixins.keypair.options.key_type' do |value|
30
+ register :key_type, :str, 'RSA', 'corl.core.mixin.action.keypair.options.key_type' do |value|
31
31
  key_type_choices = [ 'RSA', 'DSA' ]
32
32
  unless key_type_choices.include?(value.to_s.upcase)
33
- warn('corl.core.mixins.keypair.errors.key_type', { :value => value, :choices => key_type_choices })
33
+ warn('corl.core.mixin.action.keypair.errors.key_type', { :value => value, :choices => key_type_choices })
34
34
  next false
35
35
  end
36
36
  true
37
37
  end
38
- register :key_bits, :int, 2048, 'corl.core.mixins.keypair.options.key_bits' do |value|
38
+ register :key_bits, :int, 2048, 'corl.core.mixin.action.keypair.options.key_bits' do |value|
39
39
  unless value >= 2048
40
- warn('corl.core.mixins.keypair.errors.key_bits', { :value => value, :required => 2048 })
40
+ warn('corl.core.mixin.action.keypair.errors.key_bits', { :value => value, :required => 2048 })
41
41
  next false
42
42
  end
43
43
  true
44
44
  end
45
- register :key_comment, :str, '', 'corl.core.mixins.keypair.options.key_comment'
45
+ register :key_comment, :str, '', 'corl.core.mixin.action.keypair.options.key_comment'
46
46
 
47
47
  config_subset(keypair_ignore)
48
48
  end
@@ -89,7 +89,7 @@ module Keypair
89
89
  if password
90
90
  key_options[:passphrase] = password
91
91
  else
92
- warn('corl.core.mixins.keypair.errors.no_password')
92
+ warn('corl.core.mixin.action.keypair.errors.no_password')
93
93
  return nil
94
94
  end
95
95
  end
File without changes
File without changes
@@ -1,41 +1,56 @@
1
1
 
2
2
  module CORL
3
- module Mixin
4
- module Action
5
- module Node
6
-
3
+ module Plugin
4
+ class CloudAction < CORL.plugin_class(:action)
5
+
6
+ #-----------------------------------------------------------------------------
7
+ # Property accessor / modifiers
8
+
9
+ def namespace
10
+ :corl
11
+ end
12
+
13
+ #---
14
+
15
+ def configure
16
+ super do
17
+ node_config
18
+ yield if block_given?
19
+ end
20
+ end
21
+
7
22
  #-----------------------------------------------------------------------------
8
23
  # Settings
9
24
 
10
25
  def node_config
11
- node_plugins = Manager.connection.loaded_plugins(:node)
26
+ node_plugins = CORL.loaded_plugins(:node)
12
27
 
13
- register :parallel, :bool, true, 'corl.core.mixins.node.options.parallel'
14
- register :net_provider, :str, :default, 'corl.core.mixins.node.options.net_provider' do |value|
28
+ register :parallel, :bool, true, 'corl.core.action.options.parallel'
29
+ register :net_provider, :str, :default, 'corl.core.action.options.net_provider' do |value|
15
30
  value = value.to_sym
16
- network_plugins = Manager.connection.loaded_plugins(:network)
31
+ network_plugins = CORL.loaded_plugins(:network)
17
32
 
18
33
  unless network_plugins.keys.include?(value)
19
- warn('corl.core.mixins.node.errors.network_provider', { :value => value, :choices => network_plugins.keys.join(", ") })
34
+ warn('corl.core.action.errors.network_provider', { :value => value, :choices => network_plugins.keys.join(", ") })
20
35
  next false
21
36
  end
22
37
  true
23
38
  end
24
- register :node_provider, :str, :local, 'corl.core.mixins.node.options.node_provider' do |value|
39
+ register :node_provider, :str, :local, 'corl.core.action.options.node_provider' do |value|
25
40
  value = value.to_sym
26
41
 
27
42
  unless node_plugins.keys.include?(value)
28
- warn('corl.core.mixins.node.errors.node_provider', { :value => value, :choices => node_plugins.keys.join(", ") })
43
+ warn('corl.core.action.errors.node_provider', { :value => value, :choices => node_plugins.keys.join(", ") })
29
44
  next false
30
45
  end
31
46
  true
32
47
  end
33
- register :nodes, :array, [], 'corl.core.mixins.node.options.nodes' do |values|
48
+ register :nodes, :array, [], 'corl.core.action.options.nodes' do |values|
34
49
  success = true
35
50
  values.each do |value|
36
- if info = Plugin::Node.translate_reference(value)
51
+ if info = CORL.plugin_class(:node).translate_reference(value)
37
52
  if ! node_plugins.keys.include?(info[:provider].to_sym) || info[:name].empty?
38
- warn('corl.core.mixins.node.errors.nodes', { :value => value, :provider => info[:provider], :name => info[:name] })
53
+ warn('corl.core.action.errors.nodes', { :value => value, :provider => info[:provider], :name => info[:name] })
39
54
  success = false
40
55
  end
41
56
  end
@@ -49,28 +64,25 @@ module Node
49
64
  def node_ignore
50
65
  [ :parallel, :net_provider, :node_provider, :nodes ]
51
66
  end
52
-
67
+
53
68
  #-----------------------------------------------------------------------------
54
69
  # Operations
55
70
 
56
- def init_network(path = nil)
57
- # Get network configuration path
58
- if CORL.admin?
59
- network_path = lookup(:corl_network)
60
- Dir.mkdir(network_path) unless File.directory?(network_path)
61
- else
62
- network_path = ( path.nil? ? Dir.pwd : File.expand_path(path) )
71
+ def validate(node, network)
72
+ super(node, network)
73
+ end
74
+
75
+ #---
76
+
77
+ def execute
78
+ super(true, true) do
79
+ node_exec do |node, network|
80
+ hook_config = { :node => node, :network => network }
81
+
82
+ yield(node, network) if block_given? && extension_check(:exec_init, hook_config)
83
+ myself.status = extension_set(:exec_exit, status, hook_config)
84
+ end
63
85
  end
64
-
65
- # Load network if it exists
66
- network_config = extended_config(:network, { :directory => network_path })
67
-
68
- network = CORL.network(
69
- CORL.sha1(network_config),
70
- network_config,
71
- settings[:net_provider]
72
- )
73
- network
74
86
  end
75
87
 
76
88
  #---
@@ -119,6 +131,28 @@ module Node
119
131
 
120
132
  #---
121
133
 
134
+ def init_network(path = nil)
135
+ # Get network configuration path
136
+ if CORL.admin?
137
+ network_path = lookup(:corl_network)
138
+ Dir.mkdir(network_path) unless File.directory?(network_path)
139
+ else
140
+ network_path = ( path.nil? ? Dir.pwd : File.expand_path(path) )
141
+ end
142
+
143
+ # Load network if it exists
144
+ network_config = extended_config(:network, { :directory => network_path })
145
+
146
+ network = CORL.network(
147
+ CORL.sha1(network_config),
148
+ network_config,
149
+ settings[:net_provider]
150
+ )
151
+ network
152
+ end
153
+
154
+ #---
155
+
122
156
  def execute_remote(node, network, op, data)
123
157
  # Implement in sub classes if needed
124
158
  data
@@ -126,4 +160,3 @@ module Node
126
160
  end
127
161
  end
128
162
  end
129
- end
@@ -1,7 +1,7 @@
1
1
 
2
- module CORL
2
+ module Nucleon
3
3
  module Plugin
4
- class Configuration < Base
4
+ class Configuration < CORL.plugin_class(:base)
5
5
 
6
6
  include Mixin::SubConfig
7
7
 
@@ -1,7 +1,11 @@
1
1
 
2
+ nucleon_require(File.dirname(__FILE__), :node)
3
+
4
+ #---
5
+
2
6
  module CORL
3
7
  module Node
4
- class Fog < Plugin::Node
8
+ class Fog < CORL.plugin_class(:node)
5
9
 
6
10
  #-----------------------------------------------------------------------------
7
11
  # Node plugin interface
@@ -1,7 +1,7 @@
1
1
 
2
- module CORL
2
+ module Nucleon
3
3
  module Plugin
4
- class Machine < Base
4
+ class Machine < CORL.plugin_class(:base)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Machine plugin interface
@@ -1,7 +1,7 @@
1
1
 
2
- module CORL
2
+ module Nucleon
3
3
  module Plugin
4
- class Network < Base
4
+ class Network < CORL.plugin_class(:base)
5
5
 
6
6
  init_plugin_collection
7
7
 
@@ -48,7 +48,7 @@ class Network < Base
48
48
  def node_groups
49
49
  groups = {}
50
50
 
51
- each_node_config! do |provider, name, info|
51
+ each_node_config do |provider, name, info|
52
52
  search_node(provider, name, :groups, [], :array).each do |group|
53
53
  group = group.to_sym
54
54
  groups[group] = [] unless groups.has_key?(group)
@@ -107,7 +107,7 @@ class Network < Base
107
107
  #---
108
108
 
109
109
  def node_by_ip(public_ip)
110
- each_node_config! do |provider, name, info|
110
+ each_node_config do |provider, name, info|
111
111
  return node(provider, name) if info[:public_ip] == public_ip
112
112
  end
113
113
  nil
@@ -1,7 +1,7 @@
1
1
 
2
- module CORL
2
+ module Nucleon
3
3
  module Plugin
4
- class Node < Base
4
+ class Node < CORL.plugin_class(:base)
5
5
 
6
6
  include Celluloid
7
7
 
@@ -12,7 +12,7 @@ class Node < Base
12
12
  super
13
13
 
14
14
  ui.resource = hostname
15
- ui.logger = hostname
15
+ logger = hostname
16
16
 
17
17
  @cli_interface = Util::Liquid.new do |method, args, &code|
18
18
  result = exec({ :commands => [ [ method, args ].flatten.join(' ') ] }) do |op, data|
@@ -28,7 +28,7 @@ class Node < Base
28
28
  action(method, *args) do |op, data|
29
29
  code.call(op, data) if code
30
30
  end
31
- end
31
+ end
32
32
  end
33
33
 
34
34
  #---
@@ -304,7 +304,7 @@ class Node < Base
304
304
  # Machine operations
305
305
 
306
306
  def create_machine(name, provider, options = {})
307
- CORL.plugin_load(:machine, provider, extended_config(name, options).import({ :meta => { :parent => myself }}))
307
+ CORL.create_plugin(:machine, provider, extended_config(name, options).import({ :meta => { :parent => myself }}))
308
308
  end
309
309
 
310
310
  #---
@@ -461,7 +461,7 @@ class Node < Base
461
461
  active_machine = local? ? local_machine : machine
462
462
 
463
463
  if commands = config.get(:commands, nil)
464
- logger.info("Starting command execution: #{commands.join('; ')}")
464
+ render("Starting command execution: #{commands.join('; ')}")
465
465
  results = active_machine.exec(commands, config.export) do |type, command, data|
466
466
  if type == :error
467
467
  alert(data)
@@ -498,7 +498,7 @@ class Node < Base
498
498
 
499
499
  def command(command, options = {})
500
500
  unless command.is_a?(CORL::Plugin::Command)
501
- command = CORL.command(Config.new({ :command => command }).import(options), :shell)
501
+ command = CORL.command(Config.new({ :command => command }).import(options), :bash)
502
502
  end
503
503
  results = exec({ :commands => [ command.to_s ] }) do |op, data|
504
504
  yield(op, data) if block_given?
@@ -536,7 +536,7 @@ class Node < Base
536
536
  myself.status = code.unknown_status
537
537
 
538
538
  bootstrap_name = 'bootstrap'
539
- bootstrap_path = config.get(:bootstrap_path, File.join(Gems.core.full_gem_path, bootstrap_name))
539
+ bootstrap_path = config.get(:bootstrap_path, File.join(CORL.lib_path, '..', bootstrap_name))
540
540
  bootstrap_glob = config.get(:bootstrap_glob, '**/*.sh')
541
541
  bootstrap_init = config.get(:bootstrap_init, 'bootstrap.sh')
542
542
 
@@ -581,13 +581,15 @@ class Node < Base
581
581
 
582
582
  # Execute bootstrap process
583
583
  if status == code.success
584
- remote_script = File.join(remote_bootstrap_path, bootstrap_init)
584
+ remote_script = File.join(remote_bootstrap_path, bootstrap_init)
585
+
585
586
  result = command(remote_script) do |op, data|
586
587
  yield("exec_#{op}".to_sym, data) if block_given?
587
588
  data
588
589
  end
589
590
 
590
591
  if result.status != code.success
592
+ warn('corl.core.node.bootstrap.status', { :script => remote_script, :status => result.status })
591
593
  myself.status = code.bootstrap_exec_failure
592
594
  end
593
595
  end