corl 0.5.11 → 0.5.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/corl.gemspec +12 -12
- data/lib/CORL/builder/identity.rb +7 -6
- data/lib/CORL/builder/project.rb +1 -1
- data/lib/core/mixin/machine/ssh.rb +17 -1
- data/lib/core/plugin/cloud_action.rb +1 -1
- data/lib/core/plugin/node.rb +3 -2
- data/lib/nucleon/action/{cloud → network}/config.rb +86 -86
- data/lib/nucleon/action/{cloud → network}/create.rb +15 -15
- data/lib/nucleon/action/{cloud → network}/images.rb +14 -14
- data/lib/nucleon/action/{cloud → network}/inspect.rb +12 -12
- data/lib/nucleon/action/{cloud → network}/machines.rb +12 -12
- data/lib/nucleon/action/{cloud → network}/regions.rb +15 -15
- data/lib/nucleon/action/{cloud → network}/remote.rb +17 -17
- data/lib/nucleon/action/{cloud → network}/settings.rb +54 -54
- data/lib/nucleon/action/{cloud → network}/vagrantfile.rb +18 -18
- data/lib/nucleon/action/node/identity.rb +75 -29
- data/lib/nucleon/action/node/keypair.rb +29 -27
- data/lib/nucleon/action/node/revoke.rb +13 -13
- data/locales/en.yml +15 -2
- metadata +11 -11
@@ -3,64 +3,110 @@ module Nucleon
|
|
3
3
|
module Action
|
4
4
|
module Node
|
5
5
|
class Identity < Nucleon.plugin_class(:nucleon, :cloud_action)
|
6
|
-
|
6
|
+
|
7
7
|
#-----------------------------------------------------------------------------
|
8
8
|
# Info
|
9
|
-
|
9
|
+
|
10
10
|
def self.describe
|
11
11
|
super(:node, :identity, 700)
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
#-----------------------------------------------------------------------------
|
15
15
|
# Settings
|
16
|
-
|
16
|
+
|
17
17
|
def configure
|
18
18
|
super do
|
19
|
-
codes :identity_upload_failure
|
20
|
-
|
21
|
-
register_str :name
|
19
|
+
codes :identity_required, :identity_upload_failure
|
20
|
+
|
21
|
+
register_str :name, nil
|
22
22
|
register_project :identity
|
23
|
-
register_nodes :identity_nodes
|
23
|
+
register_nodes :identity_nodes
|
24
|
+
|
25
|
+
register_bool :delete, false
|
24
26
|
end
|
25
27
|
end
|
26
|
-
|
28
|
+
|
27
29
|
#---
|
28
|
-
|
30
|
+
|
29
31
|
def ignore
|
30
32
|
[ :nodes ]
|
31
33
|
end
|
32
|
-
|
34
|
+
|
33
35
|
def arguments
|
34
36
|
[ :name, :identity_nodes ]
|
35
37
|
end
|
36
38
|
|
37
39
|
#-----------------------------------------------------------------------------
|
38
40
|
# Operations
|
39
|
-
|
41
|
+
|
40
42
|
def execute
|
41
43
|
super do |local_node|
|
42
44
|
ensure_network do
|
43
|
-
|
44
|
-
|
45
|
-
|
45
|
+
if settings[:identity]
|
46
|
+
# Get identity builder
|
47
|
+
builder = network.identity_builder({ settings[:name] => settings[:identity] })
|
48
|
+
else
|
49
|
+
# Search for identity
|
50
|
+
builder = network.identity_builder
|
46
51
|
identity_directory = File.join(builder.build_directory, settings[:name])
|
47
|
-
|
52
|
+
|
53
|
+
if File.directory?(identity_directory)
|
54
|
+
identity_nucleon_file = File.join(identity_directory, '.nucleon')
|
55
|
+
|
56
|
+
if File.exists?(identity_nucleon_file)
|
57
|
+
json_data = Util::Disk.read(identity_nucleon_file)
|
58
|
+
project_info = symbol_map(Util::Data.parse_json(json_data))
|
59
|
+
settings[:identity] = "#{project_info[:provider]}:::#{project_info[:edit]}[#{project_info[:revision]}]"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
if settings[:identity]
|
64
|
+
# Get identity builder
|
65
|
+
info('using_identity', { :identity => settings[:identity], :directory => identity_directory })
|
66
|
+
builder = network.identity_builder({ settings[:name] => settings[:identity] })
|
67
|
+
else
|
68
|
+
warn('identity_required')
|
69
|
+
myself.status = code.identity_required
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Build identity into local network project
|
74
|
+
if myself.status == code.success && ( settings[:delete] || builder.build(local_node) )
|
75
|
+
identity_directory = File.join(builder.build_directory, settings[:name])
|
76
|
+
|
77
|
+
# Loop over all nodes to assign identity to (or delete)
|
48
78
|
success = network.batch(settings[:identity_nodes], settings[:node_provider], settings[:parallel]) do |node|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
79
|
+
if settings[:delete]
|
80
|
+
info('start_delete', { :provider => node.plugin_provider, :name => node.plugin_name })
|
81
|
+
else
|
82
|
+
info('start_add', { :provider => node.plugin_provider, :name => node.plugin_name })
|
83
|
+
end
|
84
|
+
|
85
|
+
# Lookup remote network path
|
86
|
+
success = true
|
87
|
+
remote_network_directory = node.lookup(:corl_network)
|
88
|
+
remote_config_directory = File.join(remote_network_directory, network.config_directory.sub(/#{network.directory}#{File::SEPARATOR}/, ''))
|
54
89
|
remote_identity_base_directory = File.join(remote_network_directory, builder.build_directory.sub(/#{network.directory}#{File::SEPARATOR}/, ''))
|
55
90
|
remote_identity_directory = File.join(remote_identity_base_directory, settings[:name])
|
56
|
-
|
57
|
-
|
58
|
-
node.cli.
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
91
|
+
|
92
|
+
# Ensure proper remote directories are ready for identity
|
93
|
+
result = node.cli.mkdir('-p', remote_identity_base_directory)
|
94
|
+
success = false unless result.status == code.success
|
95
|
+
|
96
|
+
if success
|
97
|
+
result = node.cli.rm('-Rf', remote_identity_directory)
|
98
|
+
success = false unless result.status == code.success
|
99
|
+
|
100
|
+
# Send identity through SCP to remote machine
|
101
|
+
success = node.send_files(identity_directory, remote_identity_directory, nil, '0700') if success && ! settings[:delete]
|
102
|
+
end
|
103
|
+
success
|
104
|
+
end
|
105
|
+
|
106
|
+
if success && settings[:delete]
|
107
|
+
# Remove local identity last
|
108
|
+
info('local_delete', { :directory => identity_directory })
|
109
|
+
FileUtils.rm_rf(identity_directory)
|
64
110
|
end
|
65
111
|
end
|
66
112
|
myself.status = code.batch_error unless success
|
@@ -3,79 +3,81 @@ module Nucleon
|
|
3
3
|
module Action
|
4
4
|
module Node
|
5
5
|
class Keypair < Nucleon.plugin_class(:nucleon, :cloud_action)
|
6
|
-
|
6
|
+
|
7
7
|
include Mixin::Action::Keypair
|
8
|
-
|
8
|
+
|
9
9
|
#-----------------------------------------------------------------------------
|
10
10
|
# Info
|
11
|
-
|
11
|
+
|
12
12
|
def self.describe
|
13
13
|
super(:node, :keypair, 545)
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
#----------------------------------------------------------------------------
|
17
17
|
# Settings
|
18
|
-
|
18
|
+
|
19
19
|
def configure
|
20
20
|
super do
|
21
21
|
codes :key_failure
|
22
|
-
|
22
|
+
|
23
23
|
register :json, :bool, true
|
24
24
|
register :both, :bool, false
|
25
25
|
keypair_config
|
26
26
|
end
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
#---
|
30
|
-
|
30
|
+
|
31
31
|
def ignore
|
32
32
|
node_ignore
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
#-----------------------------------------------------------------------------
|
36
36
|
# Operations
|
37
|
-
|
37
|
+
|
38
38
|
def execute
|
39
39
|
super do |node|
|
40
40
|
if keys = keypair
|
41
41
|
ui.info("\n", { :prefix => false })
|
42
|
-
ui_group(Util::Console.cyan("#{keys.type.upcase} SSH keypair")) do |ui|
|
43
|
-
render_json = lambda do
|
42
|
+
ui_group(Util::Console.cyan("#{keys.type.upcase} SSH keypair")) do |ui|
|
43
|
+
render_json = lambda do
|
44
44
|
private_key = Util::Console.blue(Util::Data.to_json(keys.encrypted_key, true))
|
45
|
-
ssh_key = keys.ssh_key.gsub(/^ssh\-[a-z]+\s+/, '')
|
45
|
+
ssh_key = keys.ssh_key.gsub(/^ssh\-[a-z]+\s+/, '')
|
46
46
|
ssh_key = Util::Console.green(Util::Data.to_json(ssh_key, true))
|
47
|
-
|
47
|
+
|
48
48
|
ui.info("-----------------------------------------------------")
|
49
49
|
ui.info(yellow("SSH JSON string"))
|
50
|
-
ui.info("
|
51
|
-
ui.info("SSH
|
52
|
-
ui.info("
|
50
|
+
ui.info("\n", { :prefix => false })
|
51
|
+
ui.info("SSH private key:\n#{private_key}", { :prefix => false })
|
52
|
+
ui.info("SSH public key:\n#{ssh_key}", { :prefix => false })
|
53
|
+
ui.info("\n", { :prefix => false })
|
53
54
|
end
|
54
|
-
|
55
|
+
|
55
56
|
render_file = lambda do
|
56
57
|
private_key = Util::Console.blue(keys.encrypted_key)
|
57
58
|
ssh_key = Util::Console.green(keys.ssh_key)
|
58
|
-
|
59
|
+
|
59
60
|
ui.info("-----------------------------------------------------")
|
60
61
|
ui.info(yellow("SSH file rendering"))
|
61
|
-
ui.info("
|
62
|
-
ui.info("SSH
|
63
|
-
ui.info("
|
62
|
+
ui.info("\n", { :prefix => false })
|
63
|
+
ui.info("SSH private key:\n#{private_key}", { :prefix => false })
|
64
|
+
ui.info("SSH public key:\n#{ssh_key}", { :prefix => false })
|
65
|
+
ui.info("\n", { :prefix => false })
|
64
66
|
end
|
65
|
-
|
67
|
+
|
66
68
|
if settings[:both]
|
67
69
|
render_json.call
|
68
|
-
render_file.call
|
70
|
+
render_file.call
|
69
71
|
else
|
70
72
|
if settings[:json]
|
71
73
|
render_json.call
|
72
74
|
else
|
73
|
-
render_file.call
|
75
|
+
render_file.call
|
74
76
|
end
|
75
77
|
end
|
76
|
-
end
|
78
|
+
end
|
77
79
|
else
|
78
|
-
myself.status = code.key_failure
|
80
|
+
myself.status = code.key_failure
|
79
81
|
end
|
80
82
|
end
|
81
83
|
end
|
@@ -3,51 +3,51 @@ module Nucleon
|
|
3
3
|
module Action
|
4
4
|
module Node
|
5
5
|
class Revoke < Nucleon.plugin_class(:nucleon, :cloud_action)
|
6
|
-
|
6
|
+
|
7
7
|
#-----------------------------------------------------------------------------
|
8
8
|
# Info
|
9
|
-
|
9
|
+
|
10
10
|
def self.describe
|
11
11
|
super(:node, :revoke, 550)
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
#-----------------------------------------------------------------------------
|
15
15
|
# Settings
|
16
|
-
|
16
|
+
|
17
17
|
def configure
|
18
18
|
super do
|
19
19
|
codes :key_remove_failure
|
20
|
-
|
20
|
+
|
21
21
|
register :public_key, :str, nil
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
#---
|
26
|
-
|
26
|
+
|
27
27
|
def arguments
|
28
28
|
[ :public_key ]
|
29
29
|
end
|
30
30
|
|
31
31
|
#-----------------------------------------------------------------------------
|
32
32
|
# Operations
|
33
|
-
|
33
|
+
|
34
34
|
def execute
|
35
35
|
super do |node|
|
36
36
|
info('corl.actions.revoke.start')
|
37
|
-
|
37
|
+
|
38
38
|
ensure_node(node) do
|
39
39
|
ssh_path = Util::SSH.key_path
|
40
|
-
authorized_keys = File.join(ssh_path, 'authorized_keys')
|
40
|
+
authorized_keys = File.join(ssh_path, 'authorized_keys')
|
41
41
|
public_key = settings[:public_key].strip
|
42
42
|
output_keys = []
|
43
|
-
|
43
|
+
|
44
44
|
if File.exists?(authorized_keys)
|
45
45
|
Util::Disk.read(authorized_keys).split("\n").each do |line|
|
46
46
|
if line.strip.include?(public_key)
|
47
47
|
key_found = true
|
48
48
|
else
|
49
|
-
output_keys <<
|
50
|
-
end
|
49
|
+
output_keys << line
|
50
|
+
end
|
51
51
|
end
|
52
52
|
end
|
53
53
|
unless key_found
|
data/locales/en.yml
CHANGED
@@ -121,7 +121,7 @@ en:
|
|
121
121
|
success:
|
122
122
|
saved: |-
|
123
123
|
Plugin successfully saved to %{file}
|
124
|
-
|
124
|
+
network:
|
125
125
|
create:
|
126
126
|
description: |-
|
127
127
|
Create a new network project
|
@@ -159,7 +159,7 @@ en:
|
|
159
159
|
help: |-
|
160
160
|
Inspect any defined network configuration. It is not intended to access or
|
161
161
|
set the node configurations defined in the config directory, which you can use the `node lookup` and
|
162
|
-
`
|
162
|
+
`network config` actions.
|
163
163
|
|
164
164
|
Nested configurations can be accessed by specifying the nested keys in sequence in the arguments.
|
165
165
|
|
@@ -537,6 +537,19 @@ en:
|
|
537
537
|
Reinitializing network
|
538
538
|
updating: |-
|
539
539
|
Updating node network configurations
|
540
|
+
identity:
|
541
|
+
warn:
|
542
|
+
identity_required: |-
|
543
|
+
Identity option `--identity` required or identity needs to exist locally when adding identities to the network
|
544
|
+
info:
|
545
|
+
using_identity: |-
|
546
|
+
Using local identity %{identity} at %{directory}
|
547
|
+
start_add: |-
|
548
|
+
Setting identity on %{provider} machine %{name}
|
549
|
+
start_delete: |-
|
550
|
+
Removing identity from %{provider} machine %{name}
|
551
|
+
local_delete: |-
|
552
|
+
Removing the local identity from %{directory}
|
540
553
|
build:
|
541
554
|
description: |-
|
542
555
|
Build projects into the network project or global filesystem
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: corl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Webb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nucleon
|
@@ -266,15 +266,15 @@ files:
|
|
266
266
|
- lib/facter/custom_facts.rb
|
267
267
|
- lib/facter/vagrant_exists.rb
|
268
268
|
- lib/hiera/corl_logger.rb
|
269
|
-
- lib/nucleon/action/
|
270
|
-
- lib/nucleon/action/
|
271
|
-
- lib/nucleon/action/
|
272
|
-
- lib/nucleon/action/
|
273
|
-
- lib/nucleon/action/
|
274
|
-
- lib/nucleon/action/
|
275
|
-
- lib/nucleon/action/
|
276
|
-
- lib/nucleon/action/
|
277
|
-
- lib/nucleon/action/
|
269
|
+
- lib/nucleon/action/network/config.rb
|
270
|
+
- lib/nucleon/action/network/create.rb
|
271
|
+
- lib/nucleon/action/network/images.rb
|
272
|
+
- lib/nucleon/action/network/inspect.rb
|
273
|
+
- lib/nucleon/action/network/machines.rb
|
274
|
+
- lib/nucleon/action/network/regions.rb
|
275
|
+
- lib/nucleon/action/network/remote.rb
|
276
|
+
- lib/nucleon/action/network/settings.rb
|
277
|
+
- lib/nucleon/action/network/vagrantfile.rb
|
278
278
|
- lib/nucleon/action/node/IP.rb
|
279
279
|
- lib/nucleon/action/node/SSH.rb
|
280
280
|
- lib/nucleon/action/node/authorize.rb
|