rundock 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +7 -0
- data/README.md +25 -1
- data/Rakefile +10 -10
- data/lib/rundock/attribute/node_attribute.rb +4 -0
- data/lib/rundock/backend.rb +3 -0
- data/lib/rundock/plugin/hook/file.rb +1 -1
- data/lib/rundock/version.rb +1 -1
- data/spec/integration/platforms/centos6/Dockerfile +1 -1
- data/spec/integration/platforms/centos6/setup.sh +1 -1
- data/spec/integration/platforms/localhost/scenarios/cwd_scenario.yml +6 -0
- data/spec/integration/platforms/localhost/scenarios/sudo_scenario.yml +8 -0
- data/spec/integration/recipes/cwd_spec.rb +6 -0
- data/spec/integration/recipes/sudo_spec.rb +11 -0
- data/spec/integration/scenarios/cwd_scenario.yml +18 -0
- data/spec/integration/scenarios/sudo_scenario.yml +20 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be69d1204087ff6b81446b6303ec46351a15324b
|
4
|
+
data.tar.gz: c8d4edf9535b4495e8c57f3b0186baabba97fcbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a11d81638882d166d039e394e2efd3db08d01d5d24fa3f5e5e397cdb2101091b7a1bd14f02b601d3a22c62075e7a0d3ae63bae44fe2bc59007b2e194992439f
|
7
|
+
data.tar.gz: 1d2bc6ac9a8d3a1545161138fa5d599dd2556fb10199370f4ad6685d798c0a39cf6f6c3f60663858fab5994abb6467140d5bbd74945c95d0ef49c3df7bb3344d
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -79,14 +79,38 @@ and execute rundock.
|
|
79
79
|
|
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
|
+
- use adhoc ssh
|
83
|
+
|
82
84
|
```
|
83
85
|
$ rundock ssh -g /path/to/your-dir/targetgroup.yml -c 'your-gread-command' -d /path/to/your-dir/default_ssh_options.yml
|
84
86
|
```
|
87
|
+
|
88
|
+
- use scenario file
|
89
|
+
|
85
90
|
```
|
86
91
|
$ rundock do /path/to/your-dir/scenario.yml -d /path/to/your-dir/default_ssh_options.yml
|
87
92
|
```
|
88
93
|
|
89
|
-
|
94
|
+
You can see from `rundock -h` command.
|
95
|
+
|
96
|
+
```
|
97
|
+
Commands:
|
98
|
+
rundock do [SCENARIO] [options] # Run rundock from scenario file
|
99
|
+
rundock help [COMMAND] # Describe available commands or one specific command
|
100
|
+
rundock ssh [options] # Run rundock ssh with various options
|
101
|
+
rundock version # Print version
|
102
|
+
|
103
|
+
Options:
|
104
|
+
-l, [--log-level=LOG_LEVEL]
|
105
|
+
# Default: info
|
106
|
+
[--color], [--no-color]
|
107
|
+
# Default: true
|
108
|
+
[--header], [--no-header]
|
109
|
+
# Default: true
|
110
|
+
[--short-header], [--no-short-header]
|
111
|
+
[--date-header], [--no-date-header]
|
112
|
+
# Default: true
|
113
|
+
```
|
90
114
|
|
91
115
|
## Documentations
|
92
116
|
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ run_commands = [
|
|
8
8
|
'echo \'Hello Rundock.\' > /var/tmp/hello_rundock'
|
9
9
|
]
|
10
10
|
|
11
|
-
def execute(command, clean_env)
|
11
|
+
def execute(command, clean_env, errexit)
|
12
12
|
puts "[EXECUTE:] #{command}"
|
13
13
|
|
14
14
|
if clean_env
|
@@ -18,11 +18,11 @@ def execute(command, clean_env)
|
|
18
18
|
else
|
19
19
|
system command
|
20
20
|
end
|
21
|
-
raise 'Execute Error.'
|
21
|
+
raise 'Execute Error.' if $?.to_i != 0 && errexit
|
22
22
|
end
|
23
23
|
|
24
24
|
def setup_docker(platform, timeout, interval)
|
25
|
-
execute("./spec/integration/platforms/#{platform}/setup.sh &", false)
|
25
|
+
execute("./spec/integration/platforms/#{platform}/setup.sh &", false, true)
|
26
26
|
found = false
|
27
27
|
(timeout / interval).times do
|
28
28
|
system 'sudo docker ps | grep rundock'
|
@@ -41,17 +41,17 @@ def do_rundock_ssh(commands, platform)
|
|
41
41
|
|
42
42
|
if platform == 'localhost'
|
43
43
|
commands.each do |cmd|
|
44
|
-
execute("bundle exec exe/rundock ssh -c \"#{cmd}\" -h localhost -l debug", true)
|
44
|
+
execute("bundle exec exe/rundock ssh -c \"#{cmd}\" -h localhost -l debug", true, true)
|
45
45
|
end
|
46
46
|
else
|
47
47
|
commands.each do |cmd|
|
48
48
|
execute('bundle exec exe/rundock' \
|
49
49
|
" ssh -c \"#{cmd}\" -h 172.17.42.1 -p 22222 -u tester" \
|
50
|
-
" -i #{ENV['HOME']}/.ssh/id_rsa_rundock_spec_#{platform}_tmp -l debug", true)
|
50
|
+
" -i #{ENV['HOME']}/.ssh/id_rsa_rundock_spec_#{platform}_tmp -l debug", true, true)
|
51
51
|
Dir.glob(groups_files_pattern).each do |g|
|
52
52
|
execute('bundle exec exe/rundock' \
|
53
53
|
" ssh -c \"#{cmd}\" -g #{g} -p 22222 -u tester" \
|
54
|
-
" -i #{ENV['HOME']}/.ssh/id_rsa_rundock_spec_#{platform}_tmp -l debug", true)
|
54
|
+
" -i #{ENV['HOME']}/.ssh/id_rsa_rundock_spec_#{platform}_tmp -l debug", true, true)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -83,23 +83,23 @@ def do_rundock_scenarios(platform)
|
|
83
83
|
end
|
84
84
|
|
85
85
|
execute('bundle exec exe/rundock' \
|
86
|
-
" do #{scenario}#{default_ssh_opt}#{options} -l debug", true)
|
86
|
+
" do #{scenario}#{default_ssh_opt}#{options} -l debug", true, true)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
desc 'Cleaning environments'
|
91
91
|
|
92
92
|
task :clean do
|
93
|
-
execute('rm -fr /var/tmp/hello_rundock*', false)
|
93
|
+
execute('rm -fr /var/tmp/hello_rundock*', false, false)
|
94
94
|
Dir.glob('./spec/integration/platforms/*').each do |platform|
|
95
95
|
next if platform =~ /localhost$/
|
96
|
-
execute("#{platform}/setup.sh --clean", false)
|
96
|
+
execute("#{platform}/setup.sh --clean", false, true)
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
100
|
desc 'execute rubocop'
|
101
101
|
task :rubocop do
|
102
|
-
execute('rubocop', false)
|
102
|
+
execute('rubocop', false, true)
|
103
103
|
end
|
104
104
|
|
105
105
|
desc 'Run all tests.'
|
@@ -5,12 +5,16 @@ module Rundock
|
|
5
5
|
attr_accessor :nodeinfo
|
6
6
|
attr_accessor :task_info
|
7
7
|
attr_accessor :errexit
|
8
|
+
attr_accessor :cwd
|
9
|
+
attr_accessor :sudo
|
8
10
|
attr_accessor :dry_run
|
9
11
|
attr_accessor :hooks
|
10
12
|
|
11
13
|
AVAIL_TAKE_OVERS = [
|
12
14
|
:task_info,
|
13
15
|
:errexit,
|
16
|
+
:cwd,
|
17
|
+
:sudo,
|
14
18
|
:dry_run
|
15
19
|
]
|
16
20
|
|
data/lib/rundock/backend.rb
CHANGED
@@ -51,6 +51,7 @@ module Rundock
|
|
51
51
|
|
52
52
|
def run_command(cmd, exec_options = {})
|
53
53
|
command = cmd.strip
|
54
|
+
command = "sudo #{command.gsub(/^sudo +/, '')}" if exec_options[:sudo]
|
54
55
|
command = "cd #{Shellwords.escape(exec_options[:cwd])} && #{command}" if exec_options[:cwd]
|
55
56
|
command = "sudo -H -u #{Shellwords.escape(user)} -- /bin/sh -c #{command}" if exec_options[:user]
|
56
57
|
|
@@ -62,6 +63,8 @@ module Rundock
|
|
62
63
|
exit_status = result.exit_status
|
63
64
|
|
64
65
|
Logger.formatter.indent do
|
66
|
+
Logger.debug("cwd: #{exec_options[:cwd]}") if exec_options[:cwd]
|
67
|
+
Logger.debug("sudo: #{exec_options[:sudo]}") if exec_options[:sudo]
|
65
68
|
Logger.error("#{result.stderr.strip}") unless result.stderr.strip.blank?
|
66
69
|
Logger.info("#{result.stdout.strip}") unless result.stdout.strip.blank?
|
67
70
|
Logger.debug("errexit: #{exec_options[:errexit]}")
|
data/lib/rundock/version.rb
CHANGED
@@ -6,7 +6,7 @@ RUN echo "tester" | passwd --stdin tester
|
|
6
6
|
RUN mkdir -p /home/tester/.ssh; chown tester /home/tester/.ssh; chmod 700 /home/tester/.ssh
|
7
7
|
ADD authorized_keys /home/tester/.ssh/
|
8
8
|
RUN chown tester /home/tester/.ssh/authorized_keys; chmod 600 /home/tester/.ssh/authorized_keys
|
9
|
-
RUN echo "tester ALL=(ALL) ALL" >> /etc/sudoers.d/tester
|
9
|
+
RUN echo "tester ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/tester
|
10
10
|
RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config
|
11
11
|
RUN sed -ri 's/#UsePAM no/UsePAM no/g' /etc/ssh/sshd_config
|
12
12
|
RUN sed -ri 's/PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config
|
@@ -25,6 +25,7 @@ RUNDOCK_GROUP_CACHE_DIR="${RUNDOCK_CACHE_DIR}/groups"
|
|
25
25
|
RUNDOCK_TARGET_CACHE_DIR="${RUNDOCK_CACHE_DIR}/targets"
|
26
26
|
|
27
27
|
if [ "${1}x" = "--cleanx" ];then
|
28
|
+
set +e
|
28
29
|
rm -f ${RUNDOCK_DEFAULT_SSH_YML}
|
29
30
|
rm -f ${RUNDOCK_SCENARIO_CACHE_DIR}/*.yml
|
30
31
|
rm -f ${RUNDOCK_GROUP_CACHE_DIR}/*.yml
|
@@ -35,7 +36,6 @@ if [ "${1}x" = "--cleanx" ];then
|
|
35
36
|
rm -f ${DOCKER_SSH_KEY_PUBLIC_LOCAL}
|
36
37
|
rm -f ${DOCKER_SSH_CONFIG}
|
37
38
|
rm -f ${DOCKER_SSH_KEY_PUBLIC_REMOTE}
|
38
|
-
set +x
|
39
39
|
sudo docker ps -q | xargs sudo docker rm -f
|
40
40
|
fi
|
41
41
|
|
@@ -0,0 +1,8 @@
|
|
1
|
+
- target: localhost
|
2
|
+
command:
|
3
|
+
- "sudo rm -f /var/tmp/hello_rundock_from_sudo_scenario"
|
4
|
+
- "sudo rm -f /var/tmp/hello_rundock_from_no_sudo_scenario"
|
5
|
+
- sudo: true
|
6
|
+
- "sudo touch /var/tmp/hello_rundock_from_sudo_scenario"
|
7
|
+
- sudo: false
|
8
|
+
- "touch /var/tmp/hello_rundock_from_no_sudo_scenario"
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe file('/var/tmp/hello_rundock_from_sudo_scenario') do
|
4
|
+
it { should be_file }
|
5
|
+
it { should be_owned_by 'root' }
|
6
|
+
end
|
7
|
+
|
8
|
+
describe file('/var/tmp/hello_rundock_from_no_sudo_scenario') do
|
9
|
+
it { should be_file }
|
10
|
+
it { should_not be_owned_by 'root' }
|
11
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
- target: anyhost-01
|
2
|
+
command:
|
3
|
+
- "mkdir -p /var/tmp/cwd_scenario_test"
|
4
|
+
- "rm -f /var/tmp/hello_rundock_from_cwd_scenario"
|
5
|
+
task:
|
6
|
+
- pwd_echo
|
7
|
+
---
|
8
|
+
anyhost-01:
|
9
|
+
host: 172.17.42.1
|
10
|
+
ssh_opts:
|
11
|
+
port: 22222
|
12
|
+
user: tester
|
13
|
+
key: "<replaced_by_platforms>"
|
14
|
+
---
|
15
|
+
pwd_echo:
|
16
|
+
command:
|
17
|
+
- cwd: /var/tmp/cwd_scenario_test
|
18
|
+
- "echo `pwd` > /var/tmp/hello_rundock_from_cwd_scenario"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
- target: anyhost-01
|
2
|
+
command:
|
3
|
+
- "sudo rm -f /var/tmp/hello_rundock_from_sudo_scenario"
|
4
|
+
- "sudo rm -f /var/tmp/hello_rundock_from_no_sudo_scenario"
|
5
|
+
task:
|
6
|
+
- sudo_touch
|
7
|
+
---
|
8
|
+
anyhost-01:
|
9
|
+
host: 172.17.42.1
|
10
|
+
ssh_opts:
|
11
|
+
port: 22222
|
12
|
+
user: tester
|
13
|
+
key: "<replaced_by_platforms>"
|
14
|
+
---
|
15
|
+
sudo_touch:
|
16
|
+
command:
|
17
|
+
- sudo: true
|
18
|
+
- "sudo touch /var/tmp/hello_rundock_from_sudo_scenario"
|
19
|
+
- sudo: false
|
20
|
+
- "touch /var/tmp/hello_rundock_from_no_sudo_scenario"
|
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.5.
|
4
|
+
version: 0.5.4
|
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-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- spec/integration/platforms/centos6/Dockerfile
|
191
191
|
- spec/integration/platforms/centos6/setup.sh
|
192
192
|
- spec/integration/platforms/localhost/scenarios/all_file_hooks_by_option_scenario.yml
|
193
|
+
- spec/integration/platforms/localhost/scenarios/cwd_scenario.yml
|
193
194
|
- spec/integration/platforms/localhost/scenarios/deploy_erb_scenario.yml
|
194
195
|
- spec/integration/platforms/localhost/scenarios/deploy_scenario.yml
|
195
196
|
- spec/integration/platforms/localhost/scenarios/file_hooks_by_option_scenario.yml
|
@@ -197,11 +198,13 @@ files:
|
|
197
198
|
- spec/integration/platforms/localhost/scenarios/run_anyway_scenario.yml
|
198
199
|
- spec/integration/platforms/localhost/scenarios/simple_echo_scenario.yml
|
199
200
|
- spec/integration/platforms/localhost/scenarios/simple_plugin_scenario.yml
|
201
|
+
- spec/integration/platforms/localhost/scenarios/sudo_scenario.yml
|
200
202
|
- spec/integration/platforms/localhost/scenarios/target_by_option_scenario.yml
|
201
203
|
- spec/integration/platforms/localhost/scenarios/target_group_scenario.yml
|
202
204
|
- spec/integration/platforms/localhost/scenarios/task_by_option_scenario.yml
|
203
205
|
- spec/integration/platforms/localhost/scenarios/use_default_ssh_scenario.yml
|
204
206
|
- spec/integration/platforms/localhost/targets/target_by_option.yml
|
207
|
+
- spec/integration/recipes/cwd_spec.rb
|
205
208
|
- spec/integration/recipes/deploy_erb_spec.rb
|
206
209
|
- spec/integration/recipes/deploy_spec.rb
|
207
210
|
- spec/integration/recipes/file_hook_by_option_spec.rb
|
@@ -209,16 +212,19 @@ files:
|
|
209
212
|
- spec/integration/recipes/simple_echo_scenario_spec.rb
|
210
213
|
- spec/integration/recipes/simple_echo_spec.rb
|
211
214
|
- spec/integration/recipes/simple_plugin_scenario_spec.rb
|
215
|
+
- spec/integration/recipes/sudo_spec.rb
|
212
216
|
- spec/integration/recipes/tareget_group_scenario_spec.rb
|
213
217
|
- spec/integration/recipes/target_by_option_spec.rb
|
214
218
|
- spec/integration/recipes/task_by_option_spec.rb
|
215
219
|
- spec/integration/scenarios/all_file_hooks_by_option_scenario.yml
|
220
|
+
- spec/integration/scenarios/cwd_scenario.yml
|
216
221
|
- spec/integration/scenarios/deploy_erb_scenario.yml
|
217
222
|
- spec/integration/scenarios/deploy_scenario.yml
|
218
223
|
- spec/integration/scenarios/file_hooks_by_option_scenario.yml
|
219
224
|
- spec/integration/scenarios/file_hooks_scenario.yml
|
220
225
|
- spec/integration/scenarios/simple_echo_scenario.yml
|
221
226
|
- spec/integration/scenarios/simple_plugin_scenario.yml
|
227
|
+
- spec/integration/scenarios/sudo_scenario.yml
|
222
228
|
- spec/integration/scenarios/target_by_option_scenario.yml
|
223
229
|
- spec/integration/scenarios/target_group_scenario.yml
|
224
230
|
- spec/integration/scenarios/task_by_option_scenario.yml
|