rundock 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/Rakefile +42 -30
- data/lib/rundock.rb +4 -0
- data/lib/rundock/builder/backend_builder.rb +71 -0
- data/lib/rundock/builder/base.rb +15 -0
- data/lib/rundock/builder/default_ssh_builder.rb +33 -0
- data/lib/rundock/builder/scenario_builder.rb +95 -0
- data/lib/rundock/cli.rb +5 -2
- data/lib/rundock/runner.rb +10 -137
- data/lib/rundock/version.rb +1 -1
- data/spec/integration/platforms/centos6/setup.sh +1 -1
- data/spec/integration/scenarios/simple_host_group.yml +11 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0491b048401872650ce67684e7e23556866b43e3
|
4
|
+
data.tar.gz: 6bd121b04391da55428ba012f7ed550427a7d0cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b218e32fb3145065062a7d8c7d869e948898361c38a0b63af2c692d6987d2373a20d8fd04187c3f58700b87f6d4cd63411a2292e41311c429570f9bdbb953308
|
7
|
+
data.tar.gz: 1e327e599076b186c71d67e260b2195d3f19c1b5103b01d5940ad90641b29db8974e726b507895d6eebc0a9dcba0723c919ed4313471fc024d8ff182cd39f35d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## v0.2.0
|
2
|
+
|
3
|
+
Refactoring
|
4
|
+
|
5
|
+
- Refactoring Rundoc::Runner for build scnenario and options
|
6
|
+
- Refactoring parse options and yaml files
|
7
|
+
|
8
|
+
Improvements
|
9
|
+
|
10
|
+
- Implement multi host execute for rundock ssh
|
11
|
+
- Enable hostgroup file executing for rundock-ssh
|
12
|
+
|
1
13
|
## v0.1.0
|
2
14
|
|
3
15
|
- The first public version.
|
data/Rakefile
CHANGED
@@ -11,37 +11,54 @@ run_scenarios = %w(
|
|
11
11
|
simple_echo_scenario
|
12
12
|
)
|
13
13
|
|
14
|
-
|
14
|
+
run_groups = %w(
|
15
|
+
simple_host_group
|
16
|
+
)
|
17
|
+
|
18
|
+
def execute(command, clean_env)
|
15
19
|
puts "[EXECUTE:] #{command}"
|
16
|
-
|
20
|
+
|
21
|
+
if clean_env
|
22
|
+
Bundler.with_clean_env do
|
23
|
+
system command
|
24
|
+
end
|
25
|
+
else
|
26
|
+
system command
|
27
|
+
end
|
28
|
+
raise 'Execute Error.' unless $?.to_i == 0
|
17
29
|
end
|
18
30
|
|
19
31
|
def setup_docker(platform, timeout, interval)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
break
|
28
|
-
end
|
29
|
-
sleep interval
|
32
|
+
execute("./spec/integration/platforms/#{platform}/setup.sh &", false)
|
33
|
+
found = false
|
34
|
+
(timeout / interval).times do
|
35
|
+
system 'sudo docker ps | grep rundock'
|
36
|
+
if $?.to_i == 0
|
37
|
+
found = true
|
38
|
+
break
|
30
39
|
end
|
31
|
-
|
40
|
+
sleep interval
|
32
41
|
end
|
42
|
+
raise 'Docker Error.' unless found
|
33
43
|
end
|
34
44
|
|
35
|
-
def do_rundock_ssh(commands, platform)
|
45
|
+
def do_rundock_ssh(commands, platform, groups)
|
46
|
+
base_dir = "#{ENV['HOME']}/.rundock/#{platform}"
|
47
|
+
|
36
48
|
if platform == 'localhost'
|
37
49
|
commands.each do |cmd|
|
38
|
-
execute
|
50
|
+
execute("bundle exec exe/rundock ssh -c \"#{cmd}\" -h localhost -l debug", true)
|
39
51
|
end
|
40
52
|
else
|
41
53
|
commands.each do |cmd|
|
42
|
-
execute
|
54
|
+
execute('bundle exec exe/rundock' \
|
43
55
|
" ssh -c \"#{cmd}\" -h 127.0.0.1 -p 22222 -u tester" \
|
44
|
-
" -i #{ENV['HOME']}/.ssh/id_rsa_rundock_spec_#{platform}_tmp -l debug"
|
56
|
+
" -i #{ENV['HOME']}/.ssh/id_rsa_rundock_spec_#{platform}_tmp -l debug", true)
|
57
|
+
groups.each do |g|
|
58
|
+
execute('bundle exec exe/rundock' \
|
59
|
+
" ssh -c \"#{cmd}\" -g #{base_dir}/scenarios/#{g}.yml -p 22222 -u tester" \
|
60
|
+
" -i #{ENV['HOME']}/.ssh/id_rsa_rundock_spec_#{platform}_tmp -l debug", true)
|
61
|
+
end
|
45
62
|
end
|
46
63
|
end
|
47
64
|
end
|
@@ -59,26 +76,23 @@ def do_rundock_scenarios(scenarios, platform)
|
|
59
76
|
default_ssh_opt = " -d #{base_dir}/integration_default_ssh.yml"
|
60
77
|
end
|
61
78
|
|
62
|
-
execute
|
63
|
-
" do -s #{base_dir}/scenarios/#{scenario}.yml#{default_ssh_opt} -l debug"
|
79
|
+
execute('bundle exec exe/rundock' \
|
80
|
+
" do -s #{base_dir}/scenarios/#{scenario}.yml#{default_ssh_opt} -l debug", true)
|
64
81
|
end
|
65
82
|
end
|
66
83
|
|
67
84
|
desc 'Cleaning environments'
|
68
85
|
|
69
86
|
task :clean do
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
87
|
+
Dir.glob('./spec/integration/platforms/*').each do |platform|
|
88
|
+
next if platform =~ /localhost$/
|
89
|
+
execute("#{platform}/setup.sh --clean", false)
|
74
90
|
end
|
75
91
|
end
|
76
92
|
|
77
93
|
desc 'execute rubocop'
|
78
94
|
task :rubocop do
|
79
|
-
|
80
|
-
execute 'rubocop'
|
81
|
-
end
|
95
|
+
execute('rubocop', false)
|
82
96
|
end
|
83
97
|
|
84
98
|
desc 'Run all tests.'
|
@@ -118,10 +132,8 @@ namespace :spec do
|
|
118
132
|
desc "Run rundock for #{target}"
|
119
133
|
|
120
134
|
task :rundock do
|
121
|
-
|
122
|
-
|
123
|
-
do_rundock_scenarios(run_scenarios, target)
|
124
|
-
end
|
135
|
+
do_rundock_ssh(run_commands, target, run_groups)
|
136
|
+
do_rundock_scenarios(run_scenarios, target)
|
125
137
|
end
|
126
138
|
|
127
139
|
desc "Run serverspec tests for #{target}"
|
data/lib/rundock.rb
CHANGED
@@ -9,6 +9,10 @@ require 'rundock/operation_factory'
|
|
9
9
|
require 'rundock/node'
|
10
10
|
require 'rundock/scenario'
|
11
11
|
require 'rundock/backend'
|
12
|
+
require 'rundock/builder/base'
|
13
|
+
require 'rundock/builder/default_ssh_builder'
|
14
|
+
require 'rundock/builder/backend_builder'
|
15
|
+
require 'rundock/builder/scenario_builder'
|
12
16
|
require 'rundock/runner'
|
13
17
|
require 'rundock/cli'
|
14
18
|
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Rundock
|
2
|
+
module Builder
|
3
|
+
class BackendBuilder < Base
|
4
|
+
def initialize(options, nodename, node_info)
|
5
|
+
super(options)
|
6
|
+
@nodename = nodename
|
7
|
+
@node_info = node_info
|
8
|
+
end
|
9
|
+
|
10
|
+
def build
|
11
|
+
opts = build_options
|
12
|
+
|
13
|
+
backend_type = parse_backend_type
|
14
|
+
|
15
|
+
opts.merge!(@options)
|
16
|
+
|
17
|
+
# update ssh options for node from node_info
|
18
|
+
opts.merge!(@node_info[@nodename]['ssh_opts'])
|
19
|
+
# delete trash ssh_options(node[host::ssh_options])
|
20
|
+
@node_info[@nodename].delete('ssh_opts')
|
21
|
+
|
22
|
+
# add any attributes for host from node_info
|
23
|
+
opts.merge!(@node_info[@nodename])
|
24
|
+
Backend.create(backend_type, opts)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def build_options
|
30
|
+
opts = {}
|
31
|
+
|
32
|
+
if !@node_info ||
|
33
|
+
!@node_info[@nodename]
|
34
|
+
@node_info = { @nodename => {} }
|
35
|
+
end
|
36
|
+
@node_info[@nodename]['ssh_opts'] = {} unless @node_info[@nodename]['ssh_opts']
|
37
|
+
is_local = @nodename =~ /localhost|127\.0\.0\.1/
|
38
|
+
|
39
|
+
# replace default ssh options if exists
|
40
|
+
@options.keys.select { |o| o =~ /(\w+)_ssh_default$/ }.each do |oo|
|
41
|
+
opt = oo.gsub(/_ssh_default/, '')
|
42
|
+
# no use default ssh options if local
|
43
|
+
# (like docker or localhost with port access host should not use default ssh options)
|
44
|
+
@node_info[@nodename]['ssh_opts'][opt] = @options[oo] if !is_local && !@node_info[@nodename]['ssh_opts'][opt]
|
45
|
+
end
|
46
|
+
|
47
|
+
# replace cli ssh options if exists
|
48
|
+
%w(user key port ssh_config ask_password sudo).each { |o| @node_info[@nodename]['ssh_opts'][o] = @options[o] if @options[o] }
|
49
|
+
|
50
|
+
opts['host'] = @nodename
|
51
|
+
|
52
|
+
opts
|
53
|
+
end
|
54
|
+
|
55
|
+
def parse_backend_type
|
56
|
+
is_local = @nodename =~ /localhost|127\.0\.0\.1/
|
57
|
+
|
58
|
+
if is_local &&
|
59
|
+
!@node_info[@nodename]['ssh_opts']['port'] &&
|
60
|
+
!@node_info[@nodename]['ssh_opts']['user'] &&
|
61
|
+
!@node_info[@nodename]['ssh_opts']['ssh_config']
|
62
|
+
backend_type = :local
|
63
|
+
else
|
64
|
+
backend_type = :ssh
|
65
|
+
end
|
66
|
+
|
67
|
+
backend_type
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Rundock
|
4
|
+
module Builder
|
5
|
+
class DefaultSshBuilder < Base
|
6
|
+
PRESET_SSH_OPTIONS_DEFAULT_FILE_PATH = "#{Gem::Specification.find_by_path('rundock').full_gem_path}/default_ssh.yml"
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
super(options)
|
10
|
+
end
|
11
|
+
|
12
|
+
def build
|
13
|
+
opts = {}
|
14
|
+
|
15
|
+
if @options['default_ssh_opts_yaml'] && FileTest.exist?(@options['default_ssh_opts_yaml'])
|
16
|
+
def_ssh_file = @options['default_ssh_opts_yaml']
|
17
|
+
else
|
18
|
+
def_ssh_file = PRESET_SSH_OPTIONS_DEFAULT_FILE_PATH
|
19
|
+
end
|
20
|
+
|
21
|
+
File.open(def_ssh_file) do |f|
|
22
|
+
YAML.load_documents(f) do |y|
|
23
|
+
y.each do |k, v|
|
24
|
+
opts["#{k}_ssh_default"] = v
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
opts
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Rundock
|
4
|
+
module Builder
|
5
|
+
class ScenarioBuilder < Base
|
6
|
+
CommandArgNotFoundError = Class.new(StandardError)
|
7
|
+
|
8
|
+
def initialize(options, scenario_file_data)
|
9
|
+
super(options)
|
10
|
+
@scenario_file = scenario_file_data
|
11
|
+
@default_ssh_builder = DefaultSshBuilder.new(@options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def build
|
15
|
+
# parse default ssh file
|
16
|
+
opts = @default_ssh_builder.build
|
17
|
+
opts.merge!(@options)
|
18
|
+
|
19
|
+
# use host specified
|
20
|
+
return build_scenario_with_host(opts) if opts['host']
|
21
|
+
|
22
|
+
# use scenario file
|
23
|
+
build_scenario(opts)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def build_scenario_with_host(options)
|
29
|
+
raise CommandArgNotFoundError, %("--command or -c" option is not specified.) unless options['command']
|
30
|
+
|
31
|
+
scen = Scenario.new
|
32
|
+
|
33
|
+
options['host'].split(',').each do |host|
|
34
|
+
backend = BackendBuilder.new(options, host, nil).build
|
35
|
+
node = Node.new(host, backend)
|
36
|
+
node.add_operation(Rundock::OperationFactory.instance(:command).create(Array(options['command']), nil))
|
37
|
+
scen << node
|
38
|
+
end
|
39
|
+
|
40
|
+
scen
|
41
|
+
end
|
42
|
+
|
43
|
+
def build_scenario(options)
|
44
|
+
if options['hostgroup_yaml'] && !options['command']
|
45
|
+
raise CommandArgNotFoundError, %("--command or -c" option is required if hostgroup specified.)
|
46
|
+
end
|
47
|
+
|
48
|
+
type = [:main, :node_info, :tasks]
|
49
|
+
scenario_data = {}
|
50
|
+
|
51
|
+
if @scenario_file
|
52
|
+
YAML.load_documents(@scenario_file).each_with_index do |data, idx|
|
53
|
+
scenario_data[type[idx]] = data
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
node = nil
|
58
|
+
scen = Scenario.new
|
59
|
+
|
60
|
+
# use scenario file
|
61
|
+
scenario_data[:main].each do |n|
|
62
|
+
scen << node if node
|
63
|
+
|
64
|
+
n.each do |k, v|
|
65
|
+
if k == 'node'
|
66
|
+
backend = BackendBuilder.new(options, v, scenario_data[:node_info]).build
|
67
|
+
node = Node.new(v, backend)
|
68
|
+
|
69
|
+
if options['command']
|
70
|
+
node.add_operation(
|
71
|
+
Rundock::OperationFactory.instance(:command).create(Array(options['command']), nil))
|
72
|
+
end
|
73
|
+
else
|
74
|
+
|
75
|
+
if options['command'] && (k == 'command' || k == 'task')
|
76
|
+
Logger.debug(%("--command or -c" option is specified and ignore scenario file.))
|
77
|
+
next
|
78
|
+
end
|
79
|
+
|
80
|
+
ope = build_operations(k, v, scenario_data[:tasks], options)
|
81
|
+
node.add_operation(ope) if node
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
scen << node if node
|
87
|
+
scen
|
88
|
+
end
|
89
|
+
|
90
|
+
def build_operations(ope_type, ope_content, tasks, options)
|
91
|
+
Rundock::OperationFactory.instance(ope_type.to_sym).create(Array(ope_content), tasks)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
data/lib/rundock/cli.rb
CHANGED
@@ -5,6 +5,7 @@ module Rundock
|
|
5
5
|
class CLI < Thor
|
6
6
|
DEFAULT_SCENARIO_FILE_PATH = './scenario.yml'
|
7
7
|
DEFAULT_SSH_OPTIONS_DEFAULT_FILE_PATH = './default_ssh.yml'
|
8
|
+
DEFAULT_HOSTGROUP_FILE_PATH = './hostgroup.yml'
|
8
9
|
|
9
10
|
class_option :log_level, type: :string, aliases: ['-l'], default: 'info'
|
10
11
|
class_option :color, type: :boolean, default: true
|
@@ -33,9 +34,10 @@ module Rundock
|
|
33
34
|
end
|
34
35
|
|
35
36
|
desc 'ssh [options]', 'Run rundock ssh with various options'
|
36
|
-
option :command, type: :string, aliases: ['-c']
|
37
|
+
option :command, type: :string, aliases: ['-c']
|
37
38
|
option :default_ssh_opts_yaml, type: :string, aliases: ['-d'], default: DEFAULT_SSH_OPTIONS_DEFAULT_FILE_PATH
|
38
|
-
option :host, type: :string, aliases: ['-h']
|
39
|
+
option :host, type: :string, aliases: ['-h'], banner: 'You can specify comma separated hosts.[ex: host1,host2,..]'
|
40
|
+
option :hostgroup_yaml, type: :string, aliases: ['-g']
|
39
41
|
option :user, type: :string, aliases: ['-u']
|
40
42
|
option :key, type: :string, aliases: ['-i']
|
41
43
|
option :port, type: :numeric, aliases: ['-p']
|
@@ -44,6 +46,7 @@ module Rundock
|
|
44
46
|
option :sudo, type: :boolean, default: false
|
45
47
|
def ssh
|
46
48
|
opts = {}
|
49
|
+
|
47
50
|
Runner.run(opts.merge(options))
|
48
51
|
end
|
49
52
|
end
|
data/lib/rundock/runner.rb
CHANGED
@@ -1,13 +1,9 @@
|
|
1
1
|
require 'rundock'
|
2
|
-
require 'yaml'
|
3
|
-
require 'tempfile'
|
4
2
|
require 'open-uri'
|
5
3
|
|
6
4
|
module Rundock
|
7
5
|
class Runner
|
8
|
-
PRESET_SSH_OPTIONS_DEFAULT_FILE_PATH = "#{Gem::Specification.find_by_path('rundock').full_gem_path}/default_ssh.yml"
|
9
6
|
ScenarioNotFoundError = Class.new(StandardError)
|
10
|
-
CommandArgNotFoundError = Class.new(StandardError)
|
11
7
|
|
12
8
|
class << self
|
13
9
|
def run(options)
|
@@ -19,7 +15,6 @@ module Rundock
|
|
19
15
|
end
|
20
16
|
end
|
21
17
|
|
22
|
-
attr_reader :backend
|
23
18
|
attr_reader :scenario
|
24
19
|
|
25
20
|
def initialize(options)
|
@@ -31,152 +26,30 @@ module Rundock
|
|
31
26
|
end
|
32
27
|
|
33
28
|
def build(options)
|
34
|
-
if options['scenario_yaml']
|
35
|
-
|
29
|
+
if options['scenario_yaml'] || options['hostgroup_yaml']
|
30
|
+
if options['scenario_yaml'] && !FileTest.exist?(options['scenario_yaml'])
|
36
31
|
raise ScenarioNotFoundError, "'#{options['scenario_yaml']}' scenario file is not found."
|
32
|
+
elsif options['hostgroup_yaml'] && !FileTest.exist?(options['hostgroup_yaml'])
|
33
|
+
raise ScenarioNotFoundError, "'#{options['hostgroup_yaml']}' hostgroup file is not found."
|
37
34
|
end
|
38
35
|
|
36
|
+
options['scenario_yaml'] = options['hostgroup_yaml'] if options['hostgroup_yaml']
|
37
|
+
|
39
38
|
# parse scenario
|
40
39
|
if options['scenario_yaml'] =~ %r{^(http|https)://}
|
41
40
|
# read from http/https
|
42
41
|
open(options['scenario_yaml']) do |f|
|
43
|
-
@scenario =
|
42
|
+
@scenario = Rundock::Builder::ScenarioBuilder.new(options, f).build
|
44
43
|
end
|
45
44
|
else
|
46
45
|
File.open(options['scenario_yaml']) do |f|
|
47
|
-
@scenario =
|
46
|
+
@scenario = Rundock::Builder::ScenarioBuilder.new(options, f).build
|
48
47
|
end
|
49
48
|
end
|
50
49
|
else
|
51
|
-
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
def parse_default_ssh(options)
|
58
|
-
opts = {}
|
59
|
-
|
60
|
-
if options['default_ssh_opts_yaml'] && FileTest.exist?(options['default_ssh_opts_yaml'])
|
61
|
-
def_ssh_file = options['default_ssh_opts_yaml']
|
62
|
-
else
|
63
|
-
def_ssh_file = PRESET_SSH_OPTIONS_DEFAULT_FILE_PATH
|
50
|
+
# do rundock ssh
|
51
|
+
@scenario = Rundock::Builder::ScenarioBuilder.new(options, nil).build
|
64
52
|
end
|
65
|
-
|
66
|
-
File.open(def_ssh_file) do |f|
|
67
|
-
YAML.load_documents(f) do |y|
|
68
|
-
y.each do |k, v|
|
69
|
-
opts["#{k}_ssh_default"] = v
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
opts
|
75
|
-
end
|
76
|
-
|
77
|
-
def parse_scenario(scen_file, options)
|
78
|
-
# parse default ssh file
|
79
|
-
opts = parse_default_ssh(options)
|
80
|
-
opts.merge!(options)
|
81
|
-
|
82
|
-
scen = Scenario.new
|
83
|
-
|
84
|
-
# no use scenario file
|
85
|
-
if opts['host']
|
86
|
-
scen << build_no_scenario_node_operation(opts)
|
87
|
-
return scen
|
88
|
-
end
|
89
|
-
|
90
|
-
type = [:main, :node_info, :tasks]
|
91
|
-
scenario_data = {}
|
92
|
-
|
93
|
-
if scen_file
|
94
|
-
YAML.load_documents(scen_file).each_with_index do |data, idx|
|
95
|
-
scenario_data[type[idx]] = data
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
node = nil
|
100
|
-
|
101
|
-
# use scenario file
|
102
|
-
scenario_data[:main].each do |n|
|
103
|
-
scen << node if node
|
104
|
-
|
105
|
-
n.each do |k, v|
|
106
|
-
if k == 'node'
|
107
|
-
node = Node.new(
|
108
|
-
v,
|
109
|
-
build_backend(v, scenario_data[:node_info], opts))
|
110
|
-
else
|
111
|
-
ope = build_operations(k, v, scenario_data[:tasks], opts)
|
112
|
-
node.add_operation(ope) if node
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
scen << node if node
|
118
|
-
scen
|
119
|
-
end
|
120
|
-
|
121
|
-
def build_no_scenario_node_operation(options)
|
122
|
-
raise CommandArgNotFoundError, %("--command or -c" option is not specified.) unless options['command']
|
123
|
-
|
124
|
-
node_info = { options['host'] => { 'ssh_opts' => {} } }
|
125
|
-
|
126
|
-
%w(user key port ssh_config ask_password sudo).each { |o| node_info[options['host']]['ssh_opts'][o] = options[o] if options[o] }
|
127
|
-
|
128
|
-
node = Node.new(options['host'], build_backend(options['host'], node_info, options))
|
129
|
-
node.add_operation(Rundock::OperationFactory.instance(:command).create(Array(options['command']), nil))
|
130
|
-
node
|
131
|
-
end
|
132
|
-
|
133
|
-
def build_operations(ope_type, ope_content, tasks, options)
|
134
|
-
if options['command']
|
135
|
-
Logger.debug(%("--command or -c" option is specified and ignore scenario file.))
|
136
|
-
return Rundock::OperationFactory.instance(:command).create(Array(options['command']), nil)
|
137
|
-
end
|
138
|
-
|
139
|
-
Rundock::OperationFactory.instance(ope_type.to_sym).create(Array(ope_content), tasks)
|
140
|
-
end
|
141
|
-
|
142
|
-
def build_backend(host, node_info, options)
|
143
|
-
opts = {}
|
144
|
-
|
145
|
-
if !node_info ||
|
146
|
-
!node_info[host]
|
147
|
-
node_info = { host => {} }
|
148
|
-
end
|
149
|
-
node_info[host]['ssh_opts'] = {} unless node_info[host]['ssh_opts']
|
150
|
-
is_local = host =~ /localhost|127\.0\.0\.1/
|
151
|
-
|
152
|
-
# replace default ssh options if exists
|
153
|
-
options.keys.select { |o| o =~ /(\w+)_ssh_default$/ }.each do |oo|
|
154
|
-
opt = oo.gsub(/_ssh_default/, '')
|
155
|
-
# no use default ssh options if local
|
156
|
-
# (like docker or localhost with port access host should not use default ssh options)
|
157
|
-
node_info[host]['ssh_opts'][opt] = options[oo] if !is_local && !node_info[host]['ssh_opts'][opt]
|
158
|
-
end
|
159
|
-
|
160
|
-
if is_local &&
|
161
|
-
!node_info[host]['ssh_opts']['port'] &&
|
162
|
-
!node_info[host]['ssh_opts']['user'] &&
|
163
|
-
!node_info[host]['ssh_opts']['ssh_config']
|
164
|
-
backend_type = :local
|
165
|
-
else
|
166
|
-
backend_type = :ssh
|
167
|
-
opts['host'] = host
|
168
|
-
end
|
169
|
-
|
170
|
-
opts.merge!(options)
|
171
|
-
|
172
|
-
# update ssh options for node from node_info
|
173
|
-
opts.merge!(node_info[host]['ssh_opts'])
|
174
|
-
# delete trash ssh_options(node[host::ssh_options])
|
175
|
-
node_info[host].delete('ssh_opts')
|
176
|
-
|
177
|
-
# add any attributes for host from node_info
|
178
|
-
opts.merge!(node_info[host])
|
179
|
-
Backend.create(backend_type, opts)
|
180
53
|
end
|
181
54
|
end
|
182
55
|
end
|
data/lib/rundock/version.rb
CHANGED
@@ -48,7 +48,7 @@ fi
|
|
48
48
|
|
49
49
|
cp ${RUNDOCK_SCENARIO_DIR}/* ${RUNDOCK_SCENARIO_CACHE_DIR}
|
50
50
|
|
51
|
-
find ${RUNDOCK_SCENARIO_CACHE_DIR} -type f -name "*_scenario.yml" | \
|
51
|
+
find ${RUNDOCK_SCENARIO_CACHE_DIR} -type f -name "*_scenario.yml" -or -name "*_group.yml" | \
|
52
52
|
xargs sed -i -e "s#<replaced_by_platforms>#${DOCKER_SSH_KEY_PRIVATE}#g"
|
53
53
|
|
54
54
|
sudo docker ps | grep "${DOCKER_IMAGE_NAME}" && { echo "docker image is already standing."; exit 0; }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rundock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hiracy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -152,6 +152,10 @@ files:
|
|
152
152
|
- exe/rundock
|
153
153
|
- lib/rundock.rb
|
154
154
|
- lib/rundock/backend.rb
|
155
|
+
- lib/rundock/builder/backend_builder.rb
|
156
|
+
- lib/rundock/builder/base.rb
|
157
|
+
- lib/rundock/builder/default_ssh_builder.rb
|
158
|
+
- lib/rundock/builder/scenario_builder.rb
|
155
159
|
- lib/rundock/cli.rb
|
156
160
|
- lib/rundock/ext/hash.rb
|
157
161
|
- lib/rundock/ext/object/blank.rb
|
@@ -173,6 +177,7 @@ files:
|
|
173
177
|
- spec/integration/recipes/simple_echo_scenario_spec.rb
|
174
178
|
- spec/integration/recipes/simple_echo_spec.rb
|
175
179
|
- spec/integration/scenarios/simple_echo_scenario.yml
|
180
|
+
- spec/integration/scenarios/simple_host_group.yml
|
176
181
|
- spec/integration/scenarios/use_default_ssh_scenario.yml
|
177
182
|
- spec/integration/spec_helper.rb
|
178
183
|
homepage: https://github.com/hiracy/rundock
|