rundock 0.4.16 → 0.5.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 +6 -0
- data/README.md +12 -12
- data/lib/rundock.rb +1 -0
- data/lib/rundock/attribute/node_attribute.rb +1 -1
- data/lib/rundock/builder/operation_builder.rb +24 -19
- data/lib/rundock/builder/scenario_builder.rb +4 -4
- data/lib/rundock/builder/target_builder.rb +25 -0
- data/lib/rundock/cli.rb +2 -2
- data/lib/rundock/runner.rb +5 -5
- data/lib/rundock/scenario.rb +1 -0
- data/lib/rundock/version.rb +1 -1
- data/scenario_sample.yml +28 -17
- data/spec/integration/groups/simple_host_group.yml +3 -2
- data/spec/integration/platforms/centos6/Dockerfile +1 -1
- data/spec/integration/platforms/localhost/scenarios/all_file_hooks_by_option_scenario.yml +1 -1
- data/spec/integration/platforms/localhost/scenarios/deploy_scenario.yml +1 -1
- data/spec/integration/platforms/localhost/scenarios/file_hooks_by_option_scenario.yml +2 -2
- data/spec/integration/platforms/localhost/scenarios/file_hooks_scenario.yml +2 -2
- data/spec/integration/platforms/localhost/scenarios/run_anyway_scenario.yml +1 -1
- data/spec/integration/platforms/localhost/scenarios/simple_echo_scenario.yml +1 -1
- data/spec/integration/platforms/localhost/scenarios/simple_plugin_scenario.yml +2 -1
- data/spec/integration/platforms/localhost/scenarios/use_default_ssh_scenario.yml +1 -1
- data/spec/integration/scenarios/all_file_hooks_by_option_scenario.yml +1 -1
- data/spec/integration/scenarios/deploy_scenario.yml +2 -2
- data/spec/integration/scenarios/file_hooks_by_option_scenario.yml +1 -1
- data/spec/integration/scenarios/file_hooks_scenario.yml +1 -1
- data/spec/integration/scenarios/simple_echo_scenario.yml +5 -3
- data/spec/integration/scenarios/simple_plugin_scenario.yml +1 -1
- data/spec/integration/scenarios/use_default_ssh_scenario.yml +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2edc8af21fef25b6da99b4b109b52e5bc706211
|
4
|
+
data.tar.gz: 737f981e31b4507c83d4c9727694465e8e8aa65f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0adfd065978317da2da25ee3a4301556496ab7cbe164854440e3c96d2c4a631da974c069d34603a1292b06cb0a9ea998a81b1db825614d3964df2bc382835a35
|
7
|
+
data.tar.gz: cefbc63aacef98bdd97015735b0caa6e7256a84bbe917f8b8e312047f8a786fc82c7373a0036e5936be4c01c2c17fb21dbe14bf4d5e2be6003be80a321333d2c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -18,14 +18,14 @@ $ gem install rundock
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
Edit your
|
21
|
+
Edit your targetgroup to "targetgroup.yml" like this sample.
|
22
22
|
|
23
23
|
```
|
24
|
-
#
|
25
|
-
-
|
26
|
-
-
|
24
|
+
# target section
|
25
|
+
- target: 192.168.1.11
|
26
|
+
- target: host-alias-01
|
27
27
|
---
|
28
|
-
#
|
28
|
+
# target information section
|
29
29
|
host-alias-01:
|
30
30
|
host: 192.168.1.12
|
31
31
|
ssh_opts:
|
@@ -36,7 +36,7 @@ host-alias-01:
|
|
36
36
|
|
37
37
|
and execute rundock.
|
38
38
|
|
39
|
-
$ rundock ssh -g /path/to/your-dir/
|
39
|
+
$ rundock ssh -g /path/to/your-dir/targetgroup.yml -c 'your-gread-command'
|
40
40
|
|
41
41
|
or
|
42
42
|
|
@@ -44,18 +44,18 @@ Edit your operation scenario to "[scenario.yml](https://github.com/hiracy/rundoc
|
|
44
44
|
|
45
45
|
```
|
46
46
|
# scenario section
|
47
|
-
-
|
47
|
+
- target: 192.168.1.11
|
48
48
|
command:
|
49
49
|
- "sudo hostname new-host-01"
|
50
50
|
- "sudo sed -i -e 's/HOSTNAME=old-host-01/HOSTNAME=new-host-01/g' /etc/sysconfig/network"
|
51
|
-
-
|
51
|
+
- target: host-alias-01
|
52
52
|
command:
|
53
53
|
- "sudo yum -y install ruby"
|
54
54
|
task:
|
55
55
|
- update_gem
|
56
56
|
- install_bundler
|
57
57
|
---
|
58
|
-
#
|
58
|
+
# target information section
|
59
59
|
host-alias-01:
|
60
60
|
host: 192.168.1.12
|
61
61
|
ssh_opts:
|
@@ -80,17 +80,17 @@ and execute rundock.
|
|
80
80
|
You can also specify [default_ssh_options.yml](https://github.com/hiracy/rundock/blob/master/default_ssh.yml) [(Net::SSH options)](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html) file contents that you specified "-d" option to the default ssh options.
|
81
81
|
|
82
82
|
```
|
83
|
-
$ rundock ssh -g /path/to/your-dir/
|
83
|
+
$ rundock ssh -g /path/to/your-dir/targetgroup.yml -c 'your-gread-command' -d /path/to/your-dir/default_ssh_options.yml
|
84
84
|
```
|
85
85
|
```
|
86
|
-
$ rundock do
|
86
|
+
$ rundock do /path/to/your-dir/scenario.yml -d /path/to/your-dir/default_ssh_options.yml
|
87
87
|
```
|
88
88
|
|
89
89
|
For more detail. You can see from `rundock -h` command.
|
90
90
|
|
91
91
|
## Documentations
|
92
92
|
|
93
|
-
|
93
|
+
- [Rundock Wiki](https://github.com/hiracy/rundock/wiki)
|
94
94
|
|
95
95
|
## Run tests
|
96
96
|
|
data/lib/rundock.rb
CHANGED
@@ -15,6 +15,7 @@ require 'rundock/scenario'
|
|
15
15
|
require 'rundock/backend'
|
16
16
|
require 'rundock/builder/base'
|
17
17
|
require 'rundock/builder/default_ssh_builder'
|
18
|
+
require 'rundock/builder/target_builder'
|
18
19
|
require 'rundock/builder/backend_builder'
|
19
20
|
require 'rundock/builder/hook_builder'
|
20
21
|
require 'rundock/builder/operation_builder'
|
@@ -1,47 +1,52 @@
|
|
1
1
|
module Rundock
|
2
2
|
module Builder
|
3
3
|
class OperationBuilder < Base
|
4
|
-
def build_first(scenario,
|
5
|
-
if @options[:
|
6
|
-
raise CommandArgNotFoundError, %("--command or -c" option is required if
|
4
|
+
def build_first(scenario, targets, tasks, hooks)
|
5
|
+
if @options[:targetgroup] && !@options[:command]
|
6
|
+
raise CommandArgNotFoundError, %("--command or -c" option is required if targetgroup specified.)
|
7
7
|
end
|
8
8
|
|
9
9
|
node = nil
|
10
|
+
node_attribute = nil
|
10
11
|
scen = Scenario.new
|
11
|
-
node_attribute = Rundock::Attribute::NodeAttribute.new(task_info: {})
|
12
|
-
tasks.each { |k, v| node_attribute.task_info[k] = v } if tasks
|
13
|
-
scen.node_info = node_info
|
14
|
-
scen.node_info = {} unless node_info
|
15
12
|
scen.tasks = tasks
|
16
13
|
|
17
14
|
# use scenario file
|
18
15
|
scenario.each do |n|
|
19
16
|
scen.nodes.push(node) if node
|
20
17
|
|
21
|
-
n.deep_symbolize_keys.each do |
|
22
|
-
if
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
18
|
+
n.deep_symbolize_keys.each do |sk, sv|
|
19
|
+
if sk == :target
|
20
|
+
target_builder = TargetBuilder.new(@options)
|
21
|
+
target = target_builder.build(sv, targets)
|
22
|
+
|
23
|
+
if target.is_a?(Node)
|
24
|
+
if node_attribute.nil?
|
25
|
+
node_attribute = Rundock::Attribute::NodeAttribute.new(task_info: {})
|
26
|
+
else
|
27
|
+
node_attribute.next
|
28
|
+
end
|
29
|
+
|
30
|
+
node_attribute.nodename = sv
|
31
|
+
node = target
|
32
|
+
tasks.each { |k, v| node_attribute.task_info[k] = v } if tasks
|
33
|
+
scen.node_info[sv.to_sym] = node_attribute.nodeinfo = target_builder.parsed_options
|
34
|
+
end
|
30
35
|
|
31
36
|
if @options[:command]
|
32
37
|
node.add_operation(build_cli_command_operation(@options[:command], node_attribute, @options))
|
33
38
|
end
|
34
|
-
elsif
|
39
|
+
elsif sk == :hook
|
35
40
|
hooks_builder = HookBuilder.new(@options)
|
36
41
|
if node
|
37
|
-
node.hooks = hooks_builder.build(Array(
|
42
|
+
node.hooks = hooks_builder.build(Array(sv), hooks)
|
38
43
|
node_attribute.hooks = hooks_builder.enable_hooks
|
39
44
|
end
|
40
45
|
else
|
41
46
|
|
42
47
|
next unless node
|
43
48
|
|
44
|
-
ope = build_operations(
|
49
|
+
ope = build_operations(sk, Array(sv), node_attribute, @options, false)
|
45
50
|
node.add_operation(ope) if ope
|
46
51
|
end
|
47
52
|
end
|
@@ -22,8 +22,8 @@ module Rundock
|
|
22
22
|
build_scenario_with_file
|
23
23
|
end
|
24
24
|
|
25
|
-
def build_task(tasks, backend,
|
26
|
-
OperationBuilder.new(@options).build_task(tasks, backend,
|
25
|
+
def build_task(tasks, backend, target_attributes)
|
26
|
+
OperationBuilder.new(@options).build_task(tasks, backend, target_attributes)
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
@@ -37,7 +37,7 @@ module Rundock
|
|
37
37
|
def build_scenario_with_file
|
38
38
|
if @scenario_file
|
39
39
|
|
40
|
-
type = [:main, :
|
40
|
+
type = [:main, :target_info, :tasks, :hooks]
|
41
41
|
scenario_data = {}
|
42
42
|
|
43
43
|
YAML.load_documents(@scenario_file).each_with_index do |data, idx|
|
@@ -52,7 +52,7 @@ module Rundock
|
|
52
52
|
ope = OperationBuilder.new(@options)
|
53
53
|
ope.build_first(
|
54
54
|
scenario_data[:main],
|
55
|
-
scenario_data[:
|
55
|
+
scenario_data[:target_info],
|
56
56
|
scenario_data[:tasks],
|
57
57
|
scenario_data[:hooks])
|
58
58
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Rundock
|
2
|
+
module Builder
|
3
|
+
class TargetBuilder < Base
|
4
|
+
TargetNoSupportError = Class.new(NotImplementedError)
|
5
|
+
|
6
|
+
attr_accessor :parsed_options
|
7
|
+
|
8
|
+
def build(target_name, target_info)
|
9
|
+
if target_info.nil? ||
|
10
|
+
!target_info.key?(target_name.to_sym) ||
|
11
|
+
!target_info[target_name.to_sym].key?(:target_type) ||
|
12
|
+
target_info[target_name.to_sym][:target_type] == 'host'
|
13
|
+
|
14
|
+
backend_builder = BackendBuilder.new(@options, target_name, target_info)
|
15
|
+
backend = backend_builder.build
|
16
|
+
@parsed_options = backend_builder.parsed_options
|
17
|
+
|
18
|
+
return Node.new(target_name, backend)
|
19
|
+
else
|
20
|
+
raise TargetNoSupportError
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/rundock/cli.rb
CHANGED
@@ -5,7 +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 = './
|
8
|
+
DEFAULT_HOSTGROUP_FILE_PATH = './targetgroup.yml'
|
9
9
|
|
10
10
|
class_option :log_level, type: :string, aliases: ['-l'], default: 'info'
|
11
11
|
class_option :color, type: :boolean, default: true
|
@@ -46,7 +46,7 @@ module Rundock
|
|
46
46
|
option :default_ssh_opts, type: :string, aliases: ['-d'], default: DEFAULT_SSH_OPTIONS_DEFAULT_FILE_PATH
|
47
47
|
option :hooks, type: :string, aliases: ['-k']
|
48
48
|
option :host, type: :string, aliases: ['-h'], banner: 'You can specify comma separated hosts.[ex: host1,host2,..]'
|
49
|
-
option :
|
49
|
+
option :targetgroup, type: :string, aliases: ['-g']
|
50
50
|
option :user, type: :string, aliases: ['-u']
|
51
51
|
option :key, type: :string, aliases: ['-i']
|
52
52
|
option :port, type: :numeric, aliases: ['-p']
|
data/lib/rundock/runner.rb
CHANGED
@@ -8,7 +8,7 @@ module Rundock
|
|
8
8
|
|
9
9
|
class << self
|
10
10
|
def run(options)
|
11
|
-
Logger.debug 'Starting
|
11
|
+
Logger.debug 'Starting Rundock:'
|
12
12
|
|
13
13
|
runner = self.new(options)
|
14
14
|
runner.load_plugins
|
@@ -28,14 +28,14 @@ module Rundock
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def build(options)
|
31
|
-
if options[:scenario] || options[:
|
31
|
+
if options[:scenario] || options[:targetgroup]
|
32
32
|
if options[:scenario] && !FileTest.exist?(options[:scenario])
|
33
33
|
raise ScenarioNotFoundError, "'#{options[:scenario]}' scenario file is not found."
|
34
|
-
elsif options[:
|
35
|
-
raise ScenarioNotFoundError, "'#{options[:
|
34
|
+
elsif options[:targetgroup] && !FileTest.exist?(options[:targetgroup])
|
35
|
+
raise ScenarioNotFoundError, "'#{options[:targetgroup]}' targetgroup file is not found."
|
36
36
|
end
|
37
37
|
|
38
|
-
options[:scenario] = options[:
|
38
|
+
options[:scenario] = options[:targetgroup] if options[:targetgroup]
|
39
39
|
|
40
40
|
# parse scenario
|
41
41
|
if options[:scenario] =~ %r{^(http|https)://}
|
data/lib/rundock/scenario.rb
CHANGED
data/lib/rundock/version.rb
CHANGED
data/scenario_sample.yml
CHANGED
@@ -3,41 +3,47 @@
|
|
3
3
|
#
|
4
4
|
# -------------------------------------------------------------------
|
5
5
|
# ### scenario section ###
|
6
|
-
# -
|
7
|
-
# <
|
8
|
-
# - <
|
6
|
+
# - target: <target_name>
|
7
|
+
# <operation_name>:
|
8
|
+
# - <operation_detail>
|
9
9
|
# - :
|
10
|
-
# <
|
11
|
-
#
|
12
|
-
#
|
13
|
-
# - node: <nodename>
|
10
|
+
# <operation_name>:
|
11
|
+
# :
|
12
|
+
# - target: <target_name>
|
14
13
|
# :
|
15
14
|
# ---
|
16
|
-
# ###
|
17
|
-
# <
|
18
|
-
#
|
19
|
-
# <
|
15
|
+
# ### target information section ###
|
16
|
+
# <target_name>:
|
17
|
+
# target_type: host
|
18
|
+
# <target_attributes>:
|
20
19
|
# :
|
21
|
-
# <
|
20
|
+
# <target_name>:
|
22
21
|
# :
|
23
22
|
# ---
|
24
|
-
# ### task
|
23
|
+
# ### task section ###
|
25
24
|
# <taskname>:
|
26
25
|
# - "<actual command>"
|
27
26
|
# - :
|
28
27
|
# <taskname>:
|
29
28
|
# :
|
29
|
+
# ---
|
30
|
+
# ### hook section ###
|
31
|
+
# <hookname>:
|
32
|
+
# hook_type: <hook_type>
|
33
|
+
# <hook_attribute_key>: <hook_attribute_value>
|
34
|
+
# :
|
35
|
+
# <hookname>:
|
36
|
+
# :
|
30
37
|
# -------------------------------------------------------------------
|
31
38
|
#
|
32
39
|
|
33
|
-
-
|
40
|
+
- target: 127.0.0.1
|
34
41
|
command:
|
35
42
|
- "hostname"
|
36
43
|
- "uname -a"
|
37
44
|
hook:
|
38
|
-
-
|
39
|
-
|
40
|
-
- node: anyhost-01
|
45
|
+
- logging
|
46
|
+
- target: anyhost-01
|
41
47
|
task:
|
42
48
|
- echo_platform
|
43
49
|
- echo_users
|
@@ -50,6 +56,7 @@
|
|
50
56
|
hook: all
|
51
57
|
---
|
52
58
|
anyhost-01:
|
59
|
+
target_type: host
|
53
60
|
host: 192.168.1.11
|
54
61
|
ssh_opts:
|
55
62
|
port: 22
|
@@ -65,3 +72,7 @@ echo_users:
|
|
65
72
|
command:
|
66
73
|
- "whoami"
|
67
74
|
- "w"
|
75
|
+
---
|
76
|
+
logging:
|
77
|
+
hook_type: file
|
78
|
+
filepath: /var/log/rundock.log
|
@@ -1,6 +1,6 @@
|
|
1
1
|
FROM centos:6
|
2
2
|
|
3
|
-
RUN yum install -y yum install openssh openssh-server openssh-clients sudo
|
3
|
+
RUN yum install -y yum install openssh openssh-server openssh-clients sudo passwd
|
4
4
|
RUN useradd tester
|
5
5
|
RUN echo "tester" | passwd --stdin tester
|
6
6
|
RUN mkdir -p /home/tester/.ssh; chown tester /home/tester/.ssh; chmod 700 /home/tester/.ssh
|
@@ -1,10 +1,10 @@
|
|
1
|
-
-
|
1
|
+
- target: localhost
|
2
2
|
command:
|
3
3
|
- "rm -f /var/tmp/hello_rundock_from_file_hook_one_scenario"
|
4
4
|
- "rm -f /var/tmp/hello_rundock_from_file_hook_array_1_scenario"
|
5
5
|
- "rm -f /var/tmp/hello_rundock_from_file_hook_array_2_scenario"
|
6
6
|
hook: file_one
|
7
|
-
-
|
7
|
+
- target: anyhost-01
|
8
8
|
command:
|
9
9
|
- "echo aaa"
|
10
10
|
hook:
|
@@ -1,10 +1,10 @@
|
|
1
|
-
-
|
1
|
+
- target: localhost
|
2
2
|
command:
|
3
3
|
- "rm -f /var/tmp/hello_rundock_from_deploy_src_file_scenario"
|
4
4
|
- "rm -fr /var/tmp/hello_rundock_from_deploy_src_dir_scenario"
|
5
5
|
- "echo 'Hello Rundock from deploy Scenario.' > /var/tmp/hello_rundock_from_deploy_src_file_scenario"
|
6
6
|
- "mkdir /var/tmp/hello_rundock_from_deploy_src_dir_scenario"
|
7
|
-
-
|
7
|
+
- target: anyhost-01
|
8
8
|
command:
|
9
9
|
- "rm -f /var/tmp/hello_rundock_from_deploy_dst_file_scenario"
|
10
10
|
- "rm -fr /var/tmp/hello_rundock_from_deploy_dst_dir_scenario"
|
@@ -1,25 +1,27 @@
|
|
1
|
-
-
|
1
|
+
- target: localhost
|
2
2
|
command:
|
3
3
|
- "rm -f /var/tmp/hello_rundock_from_scenario"
|
4
4
|
- "echo 'Hello Rundock from Scenario.' > /var/tmp/hello_rundock_from_scenario"
|
5
|
-
-
|
5
|
+
- target: anyhost-01
|
6
6
|
task:
|
7
7
|
- echo_platform
|
8
8
|
command:
|
9
9
|
- "hostname"
|
10
|
-
-
|
10
|
+
- target: anyhost-02
|
11
11
|
command:
|
12
12
|
- "uname -a"
|
13
13
|
task:
|
14
14
|
- write_echo
|
15
15
|
---
|
16
16
|
anyhost-01:
|
17
|
+
target_type: host
|
17
18
|
host: 172.17.42.1
|
18
19
|
ssh_opts:
|
19
20
|
port: 22222
|
20
21
|
user: tester
|
21
22
|
key: "<replaced_by_platforms>"
|
22
23
|
anyhost-02:
|
24
|
+
target_type: host
|
23
25
|
host: "172.17.42.1"
|
24
26
|
ssh_opts:
|
25
27
|
port: 22222
|
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.5.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-09-
|
11
|
+
date: 2015-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- lib/rundock/builder/hook_builder.rb
|
162
162
|
- lib/rundock/builder/operation_builder.rb
|
163
163
|
- lib/rundock/builder/scenario_builder.rb
|
164
|
+
- lib/rundock/builder/target_builder.rb
|
164
165
|
- lib/rundock/cli.rb
|
165
166
|
- lib/rundock/ext/hash.rb
|
166
167
|
- lib/rundock/ext/object/blank.rb
|