rundock 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e657f6e86984349d8a0d7ac6e98d1602bd43d029
4
- data.tar.gz: c4de7b5e3823537219d7279abc896908742702f8
3
+ metadata.gz: d6a61fa117dd4b85c77ab87e31b4847d3238a2f7
4
+ data.tar.gz: 1ddc1ab8bba6da04cb75984587ba79c874a8f7d8
5
5
  SHA512:
6
- metadata.gz: 50861c2f2384facd81bd4f2acd461e017070d25d089c270dccbc168f3272902f92952282a399c3a084d110354b61809377ef30248f316d0c0f7d5a70fcba238f
7
- data.tar.gz: a3d89d692a3213c7b2a98f39e1bed79337f10c0cc929bd1ba3c5b45212d2ab31ad043320598c9e242b64ab46b1eccdb8172449e0aa43a4f6e3f4ca5232e52aa1
6
+ metadata.gz: f2309c7c12e7d172f695aac8dbe61a608e9e4fe6e86d72aa03de6f506d2ee4d79a9ab15a64eea3a88fe8e54a154804ec44a282e2b2aacbebb297fe60fedee3be
7
+ data.tar.gz: 8b07d8c2f35496f5fbd5a83dee6d5e0c8d43572e11eb24c378584501604507d436f4cfdfc5d03fb145b69c4d61ff7ebcc846976469fb584bf14e691de6b1cc6e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## v1.0.2
2
+
3
+ Update
4
+
5
+ - Support task with arguments
6
+ - Update specify private ssh setting unless current ssh setting
7
+
1
8
  ## v1.0.0
2
9
 
3
10
  Update
@@ -8,9 +8,20 @@ module Rundock
8
8
  next
9
9
  end
10
10
 
11
- backend.run_commands(i, attributes)
11
+ backend.run_commands(
12
+ assign_args(i, attributes[:task_args]), attributes
13
+ )
12
14
  end
13
15
  end
16
+
17
+ private
18
+
19
+ def assign_args(cmd, args)
20
+ return cmd unless args
21
+ cmd.gsub(/\$#/, args.length.to_s)
22
+ .gsub(/\$@/, args.join(' '))
23
+ .gsub(/\$[1-9]*/) { |arg_n| args[arg_n.chars[1..-1].join.to_i - 1] }
24
+ end
14
25
  end
15
26
  end
16
27
  end
@@ -3,16 +3,19 @@ module Rundock
3
3
  class Task < Base
4
4
  def run(backend, attributes = {})
5
5
  @instruction.each do |i|
6
- unless attributes[:task_info].key?(i.to_sym)
7
- Logger.warn("task not found and ignored: #{i}")
6
+ task_set = i.split(' ')
7
+ task_name = task_set.first
8
+ attributes[:task_args] = task_set.slice(1..-1) if task_set.length > 1
9
+ unless attributes[:task_info].key?(task_name.to_sym)
10
+ Logger.warn("task not found and ignored: #{task_name}")
8
11
  next
9
12
  end
10
13
 
11
14
  scenario = Rundock::Builder::ScenarioBuilder.new(nil, nil).build_task(
12
- attributes[:task_info][i.to_sym], backend, Rundock::Attribute::NodeAttribute.new(attributes)
15
+ attributes[:task_info][task_name.to_sym], backend, Rundock::Attribute::NodeAttribute.new(attributes)
13
16
  )
14
17
 
15
- Logger.info("start task: #{i}")
18
+ Logger.info("start task: #{task_name}")
16
19
 
17
20
  Logger.formatter.rec_lock
18
21
 
@@ -1,3 +1,3 @@
1
1
  module Rundock
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
@@ -0,0 +1,12 @@
1
+ - target: localhost
2
+ command:
3
+ - "rm -rf /var/tmp/hello_rundock_from_task_with_args_scenario"
4
+ task:
5
+ - write_echo task_with_args two
6
+ ---
7
+ ---
8
+ write_echo:
9
+ command:
10
+ - mkdir /var/tmp/hello_rundock_from_$1_scenario
11
+ - echo 'Hello Rundock from task with args Scenario. $@ $#' > /var/tmp/hello_rundock_from_$1_scenario/hello_rundock_from_$1_scenario
12
+ - cp /var/tmp/hello_rundock_from_$1_scenario/hello_rundock_from_$1_scenario /var/tmp/hello_rundock_from_$1_scenario_$2
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe file('/var/tmp/hello_rundock_from_task_with_args_scenario/hello_rundock_from_task_with_args_scenario') do
4
+ it { should be_file }
5
+ its(:content) { should match(/Hello Rundock from task with args Scenario. task_with_args two 2/) }
6
+ end
7
+
8
+ describe file('/var/tmp/hello_rundock_from_task_with_args_scenario_two') do
9
+ it { should be_file }
10
+ end
@@ -0,0 +1,20 @@
1
+ - target: localhost
2
+ command:
3
+ - "rm -rf /var/tmp/hello_rundock_from_task_with_args_scenario"
4
+ - target: anyhost-01
5
+ task:
6
+ - write_echo task_with_args two
7
+ ---
8
+ anyhost-01:
9
+ target_type: host
10
+ host: 172.17.42.1
11
+ ssh_opts:
12
+ port: 22222
13
+ user: tester
14
+ key: "<replaced_by_platforms>"
15
+ ---
16
+ write_echo:
17
+ command:
18
+ - mkdir /var/tmp/hello_rundock_from_$1_scenario
19
+ - echo 'Hello Rundock from task with args Scenario. $@ $#' > /var/tmp/hello_rundock_from_$1_scenario/hello_rundock_from_$1_scenario
20
+ - cp /var/tmp/hello_rundock_from_$1_scenario/hello_rundock_from_$1_scenario /var/tmp/hello_rundock_from_$1_scenario_$2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rundock
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - hiracy
@@ -204,6 +204,7 @@ files:
204
204
  - spec/integration/platforms/localhost/scenarios/target_by_option_scenario.yml
205
205
  - spec/integration/platforms/localhost/scenarios/target_group_scenario.yml
206
206
  - spec/integration/platforms/localhost/scenarios/task_by_option_scenario.yml
207
+ - spec/integration/platforms/localhost/scenarios/task_with_args_scenario.yml
207
208
  - spec/integration/platforms/localhost/scenarios/use_default_ssh_scenario.yml
208
209
  - spec/integration/platforms/localhost/targets/target_by_option.yml
209
210
  - spec/integration/recipes/cwd_spec.rb
@@ -218,6 +219,7 @@ files:
218
219
  - spec/integration/recipes/tareget_group_scenario_spec.rb
219
220
  - spec/integration/recipes/target_by_option_spec.rb
220
221
  - spec/integration/recipes/task_by_option_spec.rb
222
+ - spec/integration/recipes/task_with_args_spec.rb
221
223
  - spec/integration/scenarios/all_file_hooks_by_option_scenario.yml
222
224
  - spec/integration/scenarios/cwd_scenario.yml
223
225
  - spec/integration/scenarios/deploy_erb_scenario.yml
@@ -230,6 +232,7 @@ files:
230
232
  - spec/integration/scenarios/target_by_option_scenario.yml
231
233
  - spec/integration/scenarios/target_group_scenario.yml
232
234
  - spec/integration/scenarios/task_by_option_scenario.yml
235
+ - spec/integration/scenarios/task_with_args_scenario.yml
233
236
  - spec/integration/scenarios/use_default_ssh_scenario.yml
234
237
  - spec/integration/spec_helper.rb
235
238
  - spec/integration/targets/target_by_option.yml