corl 0.4.26 → 0.4.27
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/Gemfile.lock +1 -1
- data/LICENSE.txt +201 -674
- data/README.rdoc +2 -2
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/bootstrap/os/ubuntu/00_base.sh +1 -1
- data/corl.gemspec +10 -9
- data/lib/CORL/action/authorize.rb +3 -0
- data/lib/CORL/action/facts.rb +24 -0
- data/lib/CORL/action/lookup.rb +3 -2
- data/lib/CORL/action/revoke.rb +55 -0
- data/lib/core/facade.rb +0 -1
- data/lib/core/mixin/lookup.rb +74 -30
- data/lib/core/mixin/macro/network_settings.rb +5 -4
- data/lib/core/plugin/network.rb +9 -3
- data/lib/core/plugin/node.rb +82 -12
- data/lib/core/vagrant/actions/{create_shares.rb → link_network.rb} +2 -2
- data/lib/core/vagrant/config.rb +22 -3
- data/lib/core/vagrant/plugins.rb +4 -3
- data/lib/facter/custom_facts.rb +10 -11
- data/locales/en.yml +2 -2
- metadata +44 -42
data/README.rdoc
CHANGED
|
@@ -21,7 +21,7 @@ Note: This library is still very early in development!
|
|
|
21
21
|
|
|
22
22
|
==== Copyright
|
|
23
23
|
|
|
24
|
-
Licensed under
|
|
24
|
+
Licensed under Apache License 2.0. See LICENSE.txt for further details.
|
|
25
25
|
|
|
26
|
-
Copyright (c) 2013 Adrian Webb <adrian.webb@coralnexus.com>
|
|
26
|
+
Copyright (c) 2013-2014 Adrian Webb <adrian.webb@coralnexus.com>
|
|
27
27
|
Coral Technology Group LLC
|
data/Rakefile
CHANGED
|
@@ -29,14 +29,14 @@ Jeweler::Tasks.new do |gem|
|
|
|
29
29
|
gem.name = "corl"
|
|
30
30
|
gem.homepage = "http://github.com/coralnexus/corl"
|
|
31
31
|
gem.rubyforge_project = 'corl'
|
|
32
|
-
gem.license = "
|
|
32
|
+
gem.license = "Apache License, Version 2.0"
|
|
33
33
|
gem.email = "adrian.webb@coralnexus.com"
|
|
34
34
|
gem.authors = ["Adrian Webb"]
|
|
35
|
-
gem.summary = %Q{
|
|
35
|
+
gem.summary = %Q{Coral Orchestration and Research Library}
|
|
36
36
|
gem.description = %Q{Framework that provides a simple foundation for growing organically in the cloud}
|
|
37
37
|
gem.required_ruby_version = '>= 1.9.1'
|
|
38
38
|
gem.has_rdoc = true
|
|
39
|
-
gem.rdoc_options << '--title' << '
|
|
39
|
+
gem.rdoc_options << '--title' << 'Coral Orchestration and Research Library' <<
|
|
40
40
|
'--main' << 'README.rdoc' <<
|
|
41
41
|
'--line-numbers'
|
|
42
42
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.4.
|
|
1
|
+
0.4.27
|
|
@@ -15,5 +15,5 @@ apt-get update || exit 4
|
|
|
15
15
|
apt-get -y dist-upgrade || exit 5
|
|
16
16
|
|
|
17
17
|
# Install basic build packages.
|
|
18
|
-
apt-get -y install build-essential libnl-dev libpopt-dev libssl-dev libcurl4-openssl-dev libxslt-dev libxml2-dev || exit 6
|
|
18
|
+
apt-get -y install build-essential bindfs libnl-dev libpopt-dev libssl-dev libcurl4-openssl-dev libxslt-dev libxml2-dev || exit 6
|
|
19
19
|
apt-get -y install python-software-properties unzip curl || exit 7
|
data/corl.gemspec
CHANGED
|
@@ -2,16 +2,14 @@
|
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
|
5
|
-
# stub: corl 0.4.26 ruby lib
|
|
6
5
|
|
|
7
6
|
Gem::Specification.new do |s|
|
|
8
7
|
s.name = "corl"
|
|
9
|
-
s.version = "0.4.
|
|
8
|
+
s.version = "0.4.27"
|
|
10
9
|
|
|
11
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
12
|
-
s.require_paths = ["lib"]
|
|
13
11
|
s.authors = ["Adrian Webb"]
|
|
14
|
-
s.date = "2014-05-
|
|
12
|
+
s.date = "2014-05-16"
|
|
15
13
|
s.description = "Framework that provides a simple foundation for growing organically in the cloud"
|
|
16
14
|
s.email = "adrian.webb@coralnexus.com"
|
|
17
15
|
s.executables = ["corl"]
|
|
@@ -51,6 +49,7 @@ Gem::Specification.new do |s|
|
|
|
51
49
|
"lib/CORL/action/build.rb",
|
|
52
50
|
"lib/CORL/action/destroy.rb",
|
|
53
51
|
"lib/CORL/action/exec.rb",
|
|
52
|
+
"lib/CORL/action/facts.rb",
|
|
54
53
|
"lib/CORL/action/image.rb",
|
|
55
54
|
"lib/CORL/action/images.rb",
|
|
56
55
|
"lib/CORL/action/ip.rb",
|
|
@@ -60,6 +59,7 @@ Gem::Specification.new do |s|
|
|
|
60
59
|
"lib/CORL/action/provision.rb",
|
|
61
60
|
"lib/CORL/action/reboot.rb",
|
|
62
61
|
"lib/CORL/action/regions.rb",
|
|
62
|
+
"lib/CORL/action/revoke.rb",
|
|
63
63
|
"lib/CORL/action/seed.rb",
|
|
64
64
|
"lib/CORL/action/spawn.rb",
|
|
65
65
|
"lib/CORL/action/ssh.rb",
|
|
@@ -102,9 +102,9 @@ Gem::Specification.new do |s|
|
|
|
102
102
|
"lib/core/util/puppet/resource_group.rb",
|
|
103
103
|
"lib/core/vagrant/Vagrantfile",
|
|
104
104
|
"lib/core/vagrant/action.rb",
|
|
105
|
-
"lib/core/vagrant/actions/create_shares.rb",
|
|
106
105
|
"lib/core/vagrant/actions/delete_cache.rb",
|
|
107
106
|
"lib/core/vagrant/actions/init_keys.rb",
|
|
107
|
+
"lib/core/vagrant/actions/link_network.rb",
|
|
108
108
|
"lib/core/vagrant/commands/launcher.rb",
|
|
109
109
|
"lib/core/vagrant/config.rb",
|
|
110
110
|
"lib/core/vagrant/plugins.rb",
|
|
@@ -145,12 +145,13 @@ Gem::Specification.new do |s|
|
|
|
145
145
|
"spec/spec_helper.rb"
|
|
146
146
|
]
|
|
147
147
|
s.homepage = "http://github.com/coralnexus/corl"
|
|
148
|
-
s.licenses = ["
|
|
149
|
-
s.rdoc_options = ["--title", "
|
|
148
|
+
s.licenses = ["Apache License, Version 2.0"]
|
|
149
|
+
s.rdoc_options = ["--title", "Coral Orchestration and Research Library", "--main", "README.rdoc", "--line-numbers"]
|
|
150
|
+
s.require_paths = ["lib"]
|
|
150
151
|
s.required_ruby_version = Gem::Requirement.new(">= 1.9.1")
|
|
151
152
|
s.rubyforge_project = "corl"
|
|
152
|
-
s.rubygems_version = "2.
|
|
153
|
-
s.summary = "
|
|
153
|
+
s.rubygems_version = "2.0.14"
|
|
154
|
+
s.summary = "Coral Orchestration and Research Library"
|
|
154
155
|
|
|
155
156
|
if s.respond_to? :specification_version then
|
|
156
157
|
s.specification_version = 4
|
|
@@ -10,6 +10,7 @@ class Authorize < Plugin::CloudAction
|
|
|
10
10
|
super do
|
|
11
11
|
codes :key_store_failure
|
|
12
12
|
|
|
13
|
+
register :reset, :bool, false
|
|
13
14
|
register :public_key, :str, nil
|
|
14
15
|
end
|
|
15
16
|
end
|
|
@@ -33,6 +34,8 @@ class Authorize < Plugin::CloudAction
|
|
|
33
34
|
public_key = settings[:public_key].strip
|
|
34
35
|
key_found = false
|
|
35
36
|
|
|
37
|
+
File.delete(authorized_keys) if settings[:reset]
|
|
38
|
+
|
|
36
39
|
if File.exists?(authorized_keys)
|
|
37
40
|
Util::Disk.read(authorized_keys).split("\n").each do |line|
|
|
38
41
|
if line.strip.include?(public_key)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
module CORL
|
|
3
|
+
module Action
|
|
4
|
+
class Facts < Plugin::CloudAction
|
|
5
|
+
|
|
6
|
+
#-----------------------------------------------------------------------------
|
|
7
|
+
# Settings
|
|
8
|
+
|
|
9
|
+
#-----------------------------------------------------------------------------
|
|
10
|
+
# Operations
|
|
11
|
+
|
|
12
|
+
def execute
|
|
13
|
+
super do |node, network|
|
|
14
|
+
ensure_node(node) do
|
|
15
|
+
facter_facts = Config.facts
|
|
16
|
+
|
|
17
|
+
ui.info(Util::Data.to_json(facter_facts, true))
|
|
18
|
+
myself.result = facter_facts
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
data/lib/CORL/action/lookup.rb
CHANGED
|
@@ -34,9 +34,10 @@ class Lookup < Plugin::CloudAction
|
|
|
34
34
|
super do |node, network|
|
|
35
35
|
ensure_node(node) do
|
|
36
36
|
property = settings.delete(:property)
|
|
37
|
-
value =
|
|
37
|
+
value = lookup(property, nil, settings)
|
|
38
38
|
|
|
39
|
-
ui.info(
|
|
39
|
+
ui.info(Util::Data.to_json(value, true))
|
|
40
|
+
myself.result = value
|
|
40
41
|
end
|
|
41
42
|
end
|
|
42
43
|
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
module CORL
|
|
3
|
+
module Action
|
|
4
|
+
class Revoke < Plugin::CloudAction
|
|
5
|
+
|
|
6
|
+
#-----------------------------------------------------------------------------
|
|
7
|
+
# Settings
|
|
8
|
+
|
|
9
|
+
def configure
|
|
10
|
+
super do
|
|
11
|
+
codes :key_remove_failure
|
|
12
|
+
|
|
13
|
+
register :public_key, :str, nil
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
#---
|
|
18
|
+
|
|
19
|
+
def arguments
|
|
20
|
+
[ :public_key ]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
#-----------------------------------------------------------------------------
|
|
24
|
+
# Operations
|
|
25
|
+
|
|
26
|
+
def execute
|
|
27
|
+
super do |node, network|
|
|
28
|
+
info('corl.actions.revoke.start')
|
|
29
|
+
|
|
30
|
+
ensure_node(node) do
|
|
31
|
+
ssh_path = Util::SSH.key_path
|
|
32
|
+
authorized_keys = File.join(ssh_path, 'authorized_keys')
|
|
33
|
+
public_key = settings[:public_key].strip
|
|
34
|
+
output_keys = []
|
|
35
|
+
|
|
36
|
+
if File.exists?(authorized_keys)
|
|
37
|
+
Util::Disk.read(authorized_keys).split("\n").each do |line|
|
|
38
|
+
if line.strip.include?(public_key)
|
|
39
|
+
key_found = true
|
|
40
|
+
else
|
|
41
|
+
output_keys << public_key
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
unless key_found
|
|
46
|
+
unless Util::Disk.write(authorized_keys, output_keys.join("\n"))
|
|
47
|
+
myself.status = code.key_revoke_failure
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
data/lib/core/facade.rb
CHANGED
data/lib/core/mixin/lookup.rb
CHANGED
|
@@ -9,19 +9,17 @@ module Lookup
|
|
|
9
9
|
def facts
|
|
10
10
|
fact_map = {}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
Facter.
|
|
14
|
-
fact_map[name] = Facter.value(name)
|
|
15
|
-
end
|
|
12
|
+
Facter.list.each do |name|
|
|
13
|
+
fact_map[name] = Facter.value(name)
|
|
16
14
|
end
|
|
17
|
-
|
|
15
|
+
|
|
18
16
|
fact_map
|
|
19
17
|
end
|
|
20
18
|
|
|
19
|
+
#---
|
|
20
|
+
|
|
21
21
|
def fact(name)
|
|
22
|
-
|
|
23
|
-
Facter.value(name)
|
|
24
|
-
end
|
|
22
|
+
Facter.value(name)
|
|
25
23
|
end
|
|
26
24
|
|
|
27
25
|
#-----------------------------------------------------------------------------
|
|
@@ -31,25 +29,67 @@ module Lookup
|
|
|
31
29
|
|
|
32
30
|
#---
|
|
33
31
|
|
|
34
|
-
def
|
|
32
|
+
def hiera_override_dir
|
|
33
|
+
nil # Override if needed. (See network and node plugins)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
#---
|
|
37
|
+
|
|
38
|
+
def hiera_facts
|
|
39
|
+
facts # Override if needed. (See node plugin)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
#---
|
|
43
|
+
|
|
44
|
+
def hiera_configuration
|
|
35
45
|
Kernel.load File.join(File.dirname(__FILE__), '..', 'mod', 'hiera_backend.rb')
|
|
36
46
|
|
|
47
|
+
backends = CORL.value(:hiera_backends, [ "json", "yaml" ])
|
|
37
48
|
config_file = CORL.value(:hiera_config_file, File.join(Hiera::Util.config_dir, 'hiera.yaml'))
|
|
38
49
|
config = {}
|
|
39
50
|
|
|
40
|
-
if config_file && File.exist?(config_file)
|
|
51
|
+
if CORL.admin? && config_file && File.exist?(config_file)
|
|
41
52
|
config = Hiera::Config.load(config_file)
|
|
42
53
|
end
|
|
43
54
|
config[:logger] = :corl
|
|
44
55
|
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
unless config[:merge_behavior]
|
|
57
|
+
config[:merge_behavior] = "deeper"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
unless config[:backends]
|
|
61
|
+
config[:backends] = backends
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
if override_dir = hiera_override_dir
|
|
65
|
+
backends.each do |backend|
|
|
66
|
+
if config[:backends].include?(backend)
|
|
67
|
+
backend = backend.to_sym
|
|
68
|
+
config[backend] = {} unless config[backend]
|
|
69
|
+
config[backend][:datadir] = override_dir
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
hiera_config = CORL.config(:hiera, config)
|
|
75
|
+
loaded_facts = Util::Data.prefix('::', hiera_facts, '')
|
|
76
|
+
|
|
77
|
+
unless loaded_facts.empty?
|
|
78
|
+
hiera_config[:hierarchy].collect! do |search|
|
|
79
|
+
Hiera::Interpolate.interpolate(search, loaded_facts, {})
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
unless config[:hierarchy]
|
|
84
|
+
config[:hierarchy] = [ "common" ]
|
|
85
|
+
end
|
|
86
|
+
hiera_config.export
|
|
47
87
|
end
|
|
48
88
|
|
|
49
89
|
#---
|
|
50
90
|
|
|
51
|
-
def hiera
|
|
52
|
-
@@hiera = Hiera.new(:config =>
|
|
91
|
+
def hiera(reset = false)
|
|
92
|
+
@@hiera = Hiera.new(:config => hiera_configuration) if reset || @@hiera.nil?
|
|
53
93
|
@@hiera
|
|
54
94
|
end
|
|
55
95
|
|
|
@@ -58,8 +98,14 @@ module Lookup
|
|
|
58
98
|
|
|
59
99
|
def config_initialized?
|
|
60
100
|
ready = false
|
|
61
|
-
if
|
|
62
|
-
|
|
101
|
+
if hiera
|
|
102
|
+
if CORL.admin?
|
|
103
|
+
if network_path = fact(:corl_network)
|
|
104
|
+
ready = File.directory?(File.join(network_path, 'config'))
|
|
105
|
+
end
|
|
106
|
+
else
|
|
107
|
+
ready = hiera_override_dir && File.directory?(hiera_override_dir)
|
|
108
|
+
end
|
|
63
109
|
end
|
|
64
110
|
ready
|
|
65
111
|
end
|
|
@@ -100,21 +146,19 @@ module Lookup
|
|
|
100
146
|
debug_lookup(config, property, value, "Fact lookup")
|
|
101
147
|
|
|
102
148
|
unless value
|
|
103
|
-
if
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
hiera_scope = Hiera::Scope.new(hiera_scope)
|
|
108
|
-
end
|
|
109
|
-
value = hiera.lookup(property.to_s, nil, hiera_scope, override, context)
|
|
110
|
-
debug_lookup(config, property, value, "Hiera lookup")
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
if provisioner && value.nil?
|
|
114
|
-
# Search the provisioner scope (only admins can provision a machine)
|
|
115
|
-
value = CORL.provisioner({ :name => :lookup }, provisioner).lookup(property, default, config)
|
|
116
|
-
debug_lookup(config, property, value, "Provisioner lookup")
|
|
149
|
+
if config_initialized?
|
|
150
|
+
# Try to find in Hiera data store
|
|
151
|
+
unless hiera_scope.respond_to?('[]')
|
|
152
|
+
hiera_scope = Hiera::Scope.new(hiera_scope)
|
|
117
153
|
end
|
|
154
|
+
value = hiera.lookup(property.to_s, nil, hiera_scope, override, context)
|
|
155
|
+
debug_lookup(config, property, value, "Hiera lookup")
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
if CORL.admin? && provisioner && value.nil?
|
|
159
|
+
# Search the provisioner scope (only admins can provision a machine)
|
|
160
|
+
value = CORL.provisioner({ :name => :lookup }, provisioner).lookup(property, default, config)
|
|
161
|
+
debug_lookup(config, property, value, "Provisioner lookup")
|
|
118
162
|
end
|
|
119
163
|
end
|
|
120
164
|
end
|
|
@@ -22,8 +22,9 @@ module NetworkSettings
|
|
|
22
22
|
network.send("#{_type}_setting", plugin_provider, plugin_name, property, default, format)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
define_method :search do |property, default = nil, format = false|
|
|
26
|
-
|
|
25
|
+
define_method :search do |property, default = nil, format = false, lookup_settings = true|
|
|
26
|
+
extra_groups = ( lookup_settings ? lookup_array(:settings) : [] )
|
|
27
|
+
network.send("search_#{_type}", plugin_provider, plugin_name, property, default, format, extra_groups)
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
define_method :set_setting do |property, value = nil|
|
|
@@ -77,13 +78,13 @@ module NetworkSettings
|
|
|
77
78
|
#---
|
|
78
79
|
|
|
79
80
|
define_method :add_groups do |groups|
|
|
80
|
-
myself[:settings] = array(
|
|
81
|
+
myself[:settings] = array(setting(:settings)) | array(groups)
|
|
81
82
|
end
|
|
82
83
|
|
|
83
84
|
#---
|
|
84
85
|
|
|
85
86
|
define_method :remove_groups do |groups|
|
|
86
|
-
myself[:settings] = array(
|
|
87
|
+
myself[:settings] = array(setting(:settings)) - array(groups)
|
|
87
88
|
end
|
|
88
89
|
end
|
|
89
90
|
end
|
data/lib/core/plugin/network.rb
CHANGED
|
@@ -44,6 +44,12 @@ class Network < CORL.plugin_class(:base)
|
|
|
44
44
|
|
|
45
45
|
#---
|
|
46
46
|
|
|
47
|
+
def hiera_override_dir
|
|
48
|
+
File.join(directory, 'config')
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
#---
|
|
52
|
+
|
|
47
53
|
def home
|
|
48
54
|
extension_set(:home, ( ENV['USER'] == 'root' ? '/root' : ENV['HOME'] ))
|
|
49
55
|
end
|
|
@@ -157,15 +163,15 @@ class Network < CORL.plugin_class(:base)
|
|
|
157
163
|
def local_node(require_new = false)
|
|
158
164
|
ip_address = CORL.public_ip
|
|
159
165
|
local_node = node_by_ip(ip_address, require_new)
|
|
160
|
-
|
|
166
|
+
|
|
161
167
|
if local_node.nil?
|
|
162
|
-
name = Util::Data.ensure_value(lookup(:fqdn), ip_address)
|
|
168
|
+
name = Util::Data.ensure_value(lookup(:fqdn), ip_address)
|
|
163
169
|
local_node = CORL.node(name, extended_config(:local_node).import({ :meta => { :parent => myself }}), :local)
|
|
164
170
|
else
|
|
165
171
|
local_node.network = myself
|
|
166
172
|
local_node.normalize(true)
|
|
167
173
|
local_node.localize
|
|
168
|
-
end
|
|
174
|
+
end
|
|
169
175
|
local_node
|
|
170
176
|
end
|
|
171
177
|
|
data/lib/core/plugin/node.rb
CHANGED
|
@@ -85,6 +85,23 @@ class Node < CORL.plugin_class(:base)
|
|
|
85
85
|
|
|
86
86
|
#---
|
|
87
87
|
|
|
88
|
+
def hiera_override_dir
|
|
89
|
+
network.hiera_override_dir
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
#---
|
|
93
|
+
|
|
94
|
+
def hiera_facts
|
|
95
|
+
default_configs = extended_config(:hiera_default_facts, {
|
|
96
|
+
:fqdn => hostname,
|
|
97
|
+
:hostname => hostname.gsub(/\..*$/, ''),
|
|
98
|
+
:corl_provider => plugin_provider.to_s
|
|
99
|
+
})
|
|
100
|
+
Config.new(lookup_facts).defaults(default_configs).export
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
#---
|
|
104
|
+
|
|
88
105
|
def machine
|
|
89
106
|
@machine
|
|
90
107
|
end
|
|
@@ -106,26 +123,26 @@ class Node < CORL.plugin_class(:base)
|
|
|
106
123
|
#---
|
|
107
124
|
|
|
108
125
|
def id(reset = false)
|
|
109
|
-
myself[:id] = machine.plugin_name if machine && ( reset ||
|
|
110
|
-
|
|
126
|
+
myself[:id] = machine.plugin_name if machine && ( reset || setting(:id).nil? )
|
|
127
|
+
setting(:id)
|
|
111
128
|
end
|
|
112
129
|
|
|
113
130
|
#---
|
|
114
131
|
|
|
115
132
|
def public_ip(reset = false)
|
|
116
|
-
myself[:public_ip] = machine.public_ip if machine && ( reset ||
|
|
117
|
-
|
|
133
|
+
myself[:public_ip] = machine.public_ip if machine && ( reset || setting(:public_ip).nil? )
|
|
134
|
+
setting(:public_ip)
|
|
118
135
|
end
|
|
119
136
|
|
|
120
137
|
def private_ip(reset = false)
|
|
121
|
-
myself[:private_ip] = machine.private_ip if machine && ( reset ||
|
|
122
|
-
|
|
138
|
+
myself[:private_ip] = machine.private_ip if machine && ( reset || setting(:private_ip).nil? )
|
|
139
|
+
setting(:private_ip)
|
|
123
140
|
end
|
|
124
141
|
|
|
125
142
|
#---
|
|
126
143
|
|
|
127
144
|
def hostname
|
|
128
|
-
hostname =
|
|
145
|
+
hostname = setting(:hostname)
|
|
129
146
|
|
|
130
147
|
if hostname.to_s != ui.resource.to_s
|
|
131
148
|
ui.resource = Util::Console.colorize(hostname, @class_color)
|
|
@@ -137,8 +154,8 @@ class Node < CORL.plugin_class(:base)
|
|
|
137
154
|
#---
|
|
138
155
|
|
|
139
156
|
def state(reset = false)
|
|
140
|
-
myself[:state] = machine.state if machine && ( reset ||
|
|
141
|
-
|
|
157
|
+
myself[:state] = machine.state if machine && ( reset || setting(:state).nil? )
|
|
158
|
+
setting(:state)
|
|
142
159
|
end
|
|
143
160
|
|
|
144
161
|
#---
|
|
@@ -276,12 +293,22 @@ class Node < CORL.plugin_class(:base)
|
|
|
276
293
|
|
|
277
294
|
#---
|
|
278
295
|
|
|
296
|
+
def custom_facts=facts
|
|
297
|
+
myself[:facts] = hash(facts)
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
def custom_facts
|
|
301
|
+
search(:facts, {}, :hash, false)
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
#---
|
|
305
|
+
|
|
279
306
|
def profiles=profiles
|
|
280
307
|
myself[:profiles] = array(profiles)
|
|
281
308
|
end
|
|
282
309
|
|
|
283
310
|
def profiles
|
|
284
|
-
array(myself[:profiles])
|
|
311
|
+
[ array(myself[:profiles]), lookup_array(:profiles).reverse ].flatten
|
|
285
312
|
end
|
|
286
313
|
|
|
287
314
|
#---
|
|
@@ -335,8 +362,8 @@ class Node < CORL.plugin_class(:base)
|
|
|
335
362
|
# Settings groups
|
|
336
363
|
|
|
337
364
|
def machine_config
|
|
338
|
-
name =
|
|
339
|
-
name =
|
|
365
|
+
name = setting(:id)
|
|
366
|
+
name = setting(:hostname) if name.nil? || name.empty?
|
|
340
367
|
config = Config.new({ :name => name })
|
|
341
368
|
|
|
342
369
|
yield(config) if block_given?
|
|
@@ -755,6 +782,49 @@ class Node < CORL.plugin_class(:base)
|
|
|
755
782
|
status == code.success
|
|
756
783
|
end
|
|
757
784
|
|
|
785
|
+
#---
|
|
786
|
+
|
|
787
|
+
def lookup_facts
|
|
788
|
+
if ! local? && bootstrap_script
|
|
789
|
+
result = run.facts
|
|
790
|
+
|
|
791
|
+
if result.status == code.success
|
|
792
|
+
return Util::Data.symbol_map(Util::Data.parse_json(result.output))
|
|
793
|
+
end
|
|
794
|
+
end
|
|
795
|
+
local? ? facts : custom_facts
|
|
796
|
+
end
|
|
797
|
+
|
|
798
|
+
#---
|
|
799
|
+
|
|
800
|
+
def lookup_config(property, default = nil, options = {})
|
|
801
|
+
if ! local? && bootstrap_script
|
|
802
|
+
config = Config.ensure(options).import({ :property => property })
|
|
803
|
+
result = run.lookup(config)
|
|
804
|
+
|
|
805
|
+
if result.status == code.success
|
|
806
|
+
return Util::Data.value(Util::Data.parse_json(result.output), default)
|
|
807
|
+
end
|
|
808
|
+
return default
|
|
809
|
+
end
|
|
810
|
+
options[:hiera_scope] = Util::Data.prefix('::', lookup_facts, '')
|
|
811
|
+
lookup(property, default, options)
|
|
812
|
+
end
|
|
813
|
+
|
|
814
|
+
#---
|
|
815
|
+
|
|
816
|
+
def lookup_array(property, default = [], options = {})
|
|
817
|
+
config = Config.ensure(options).import({ :context => :array })
|
|
818
|
+
lookup_config(property, default, config)
|
|
819
|
+
end
|
|
820
|
+
|
|
821
|
+
#---
|
|
822
|
+
|
|
823
|
+
def lookup_hash(property, default = {}, options = {})
|
|
824
|
+
config = Config.ensure(options).import({ :context => :hash })
|
|
825
|
+
lookup_config(property, default, config)
|
|
826
|
+
end
|
|
827
|
+
|
|
758
828
|
#---
|
|
759
829
|
|
|
760
830
|
def bootstrap(local_path, options = {})
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
module VagrantPlugins
|
|
3
3
|
module CORL
|
|
4
4
|
module Action
|
|
5
|
-
class
|
|
5
|
+
class LinkNetwork < BaseAction
|
|
6
6
|
|
|
7
7
|
def call(env)
|
|
8
8
|
super do
|
|
9
|
-
env[:ui].info I18n.t("corl.vagrant.actions.
|
|
9
|
+
env[:ui].info I18n.t("corl.vagrant.actions.link_network.start")
|
|
10
10
|
|
|
11
11
|
vm.communicate.tap do |comm|
|
|
12
12
|
# TODO: Figure out a better solution for remote network path.
|
data/lib/core/vagrant/config.rb
CHANGED
|
@@ -240,20 +240,39 @@ module Config
|
|
|
240
240
|
#---
|
|
241
241
|
|
|
242
242
|
def self.configure_shares(node, machine)
|
|
243
|
-
|
|
243
|
+
bindfs_installed = Gems.exist?('vagrant-bindfs')
|
|
244
|
+
success = true
|
|
245
|
+
|
|
246
|
+
if bindfs_installed
|
|
247
|
+
machine.vm.synced_folder ".", "/vagrant", disabled: true
|
|
248
|
+
machine.vm.synced_folder ".", "/tmp/vagrant", :type => "nfs"
|
|
249
|
+
machine.bindfs.bind_folder "/tmp/vagrant", "/vagrant"
|
|
250
|
+
end
|
|
244
251
|
|
|
245
252
|
Util::Data.hash(node.shares).each do |name, options|
|
|
246
|
-
config = CORL::Config.ensure(options)
|
|
253
|
+
config = CORL::Config.ensure(options)
|
|
254
|
+
share_type = config.get(:type, nil)
|
|
247
255
|
local_dir = config.delete(:local, '')
|
|
248
256
|
remote_dir = config.delete(:remote, '')
|
|
249
257
|
|
|
250
258
|
config.init(:create, true)
|
|
251
259
|
|
|
252
260
|
unless local_dir.empty? || remote_dir.empty?
|
|
253
|
-
|
|
261
|
+
bindfs_options = config.delete(:bindfs, {})
|
|
262
|
+
share_options = {}
|
|
254
263
|
|
|
255
264
|
config.keys.each do |key|
|
|
256
265
|
share_options[key] = Util::Data.value(config[key])
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
if share_type && share_type.to_sym == :nfs && bindfs_installed
|
|
269
|
+
final_dir = remote_dir
|
|
270
|
+
remote_dir = [ '/tmp', remote_dir.sub(/^\//, '') ].join('/')
|
|
271
|
+
|
|
272
|
+
#dbg(remote_dir, 'vm bindfs local')
|
|
273
|
+
#dbg(final_dir, 'vm bindfs remote')
|
|
274
|
+
#dbg(bindfs_options, 'vm bindfs options')
|
|
275
|
+
machine.bindfs.bind_folder remote_dir, final_dir, bindfs_options
|
|
257
276
|
end
|
|
258
277
|
|
|
259
278
|
#dbg(local_dir, 'vm share local')
|
data/lib/core/vagrant/plugins.rb
CHANGED
|
@@ -17,6 +17,7 @@ class Plugin < ::Vagrant.plugin('2')
|
|
|
17
17
|
|
|
18
18
|
#---
|
|
19
19
|
|
|
20
|
+
nucleon_require(@@directory, :config)
|
|
20
21
|
nucleon_require(@@directory, :action)
|
|
21
22
|
nucleon_require(@@command_dir, :launcher)
|
|
22
23
|
|
|
@@ -41,9 +42,9 @@ class Plugin < ::Vagrant.plugin('2')
|
|
|
41
42
|
hook.after Vagrant::Action::Builtin::WaitForCommunicator, Action::InitKeys
|
|
42
43
|
end
|
|
43
44
|
|
|
44
|
-
action_hook '
|
|
45
|
-
nucleon_require(@@action_dir, :
|
|
46
|
-
hook.after Action::InitKeys, Action::
|
|
45
|
+
action_hook 'link-network', :machine_action_up do |hook|
|
|
46
|
+
nucleon_require(@@action_dir, :link_network)
|
|
47
|
+
hook.after Action::InitKeys, Action::LinkNetwork
|
|
47
48
|
end
|
|
48
49
|
|
|
49
50
|
action_hook 'delete-cache', :machine_action_destroy do |hook|
|