rundock 1.1.5 → 1.1.6

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: f14472ccefd47f2343c17934f3a59c1942b19554
4
- data.tar.gz: e76b60e727665179ef6f25f6852d3855041d31f2
3
+ metadata.gz: 87276a62d3a318643a6fd4e1db23ef2bc8734406
4
+ data.tar.gz: 41189493f366d574722b6342fa5b325c33e4e8ee
5
5
  SHA512:
6
- metadata.gz: 07c04ad61de0ca22ec4119523e98aee2533da4dba31fb3f5f2217e41906e331167b437b15361e13d6ff3e82ea9136f7e5d87522c769e27799d26c8df08001fae
7
- data.tar.gz: 587f5eb7be9c3d8a2234fd37ab82db2ff6cb6df3b839d95e108c31b8f79547445d69f99de3bb4b09bb4d51960eaa0b39ab84e50c5eec711ddab4981c9573dbc8
6
+ metadata.gz: 62eb6c047d635fdd4af13f00cec08f776c254f0a260c9da20ddae46a5debdea17ba9be90928b207e29560d67cf12e4a501bbd0d297980c3020326f94664b3222
7
+ data.tar.gz: 972d42c65730a9e5ba759135603e4c5ff56dda98d724540903de8122bdbf4892297816ba57f62bfa2be29304e711e8b62f4c3faa71f6e1df5e2b64119e948881
data/.rubocop.yml CHANGED
@@ -72,5 +72,8 @@ Style/MethodMissing:
72
72
  Style/FormatStringToken:
73
73
  Enabled: false
74
74
 
75
+ Security/Open:
76
+ Enabled: false
77
+
75
78
  Lint/UnusedMethodArgument:
76
79
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## v1.1.6
2
+
3
+ Fix
4
+
5
+ - Fix error if merging scenario task and external task
6
+ - Fix rundock ssh of comma separated host arguments
7
+
8
+ Update
9
+
10
+ - Support multi external task file
11
+ - Support filtered tasks
12
+
1
13
  ## v1.1.5
2
14
 
3
15
  Update
data/default_ssh.yml CHANGED
@@ -2,7 +2,7 @@
2
2
  # Default ssh options are here.
3
3
  #
4
4
  :port: 22
5
- :paranoid: false
5
+ :verify_host_key: false
6
6
  #:user: "youre_name"
7
7
  #:keys: ["/path/to/private_key"]
8
8
  #:passphrase: "yourpassphrase"
@@ -4,6 +4,7 @@ module Rundock
4
4
  attr_accessor :nodename
5
5
  attr_accessor :nodeinfo
6
6
  attr_accessor :task_info
7
+ attr_accessor :filtered_tasks
7
8
  attr_accessor :errexit
8
9
  attr_accessor :cwd
9
10
  attr_accessor :sudo
@@ -59,7 +59,14 @@ module Rundock
59
59
 
60
60
  return nil if exec_options[:dry_run]
61
61
 
62
- result = @backend.run_command(command)
62
+ begin
63
+ result = @backend.run_command(command)
64
+ rescue StandardError => e
65
+ Logger.error(e.to_s)
66
+ raise CommandResultStatusError if exec_options[:errexit]
67
+ return nil
68
+ end
69
+
63
70
  exit_status = result.exit_status
64
71
 
65
72
  Logger.formatter.indent do
@@ -29,7 +29,7 @@ module Rundock
29
29
  return []
30
30
  end
31
31
  elsif hook_attributes.nil?
32
- Logger.warn("Hook source is not found. (enables:#{enables.join(',')})") unless enables.empty?
32
+ Logger.info("Hook source is not found. (enables:#{enables.join(',')})") unless enables.empty?
33
33
  return []
34
34
  end
35
35
 
@@ -72,7 +72,9 @@ module Rundock
72
72
  def build_cli
73
73
  scen = Scenario.new
74
74
 
75
- @options[:host].split(',').each do |host|
75
+ hosts = @options[:host].split(',')
76
+ hosts.each do |host|
77
+ @options[:host] = host
76
78
  backend = BackendBuilder.new(@options, host, nil).build
77
79
  node = Node.new(host, backend)
78
80
  node.hooks = HookBuilder.new(@options).build(['all'], nil)
@@ -109,6 +111,8 @@ module Rundock
109
111
  node_attributes.nodename = @options[:host] unless node_attributes.nodename
110
112
  node_attributes.errexit = !cli_options[:run_anyway]
111
113
  node_attributes.dry_run = cli_options[:dry_run] ? true : false
114
+ node_attributes.filtered_tasks = cli_options[:filtered_tasks] &&
115
+ cli_options[:filtered_tasks].split(',')
112
116
  Rundock::OperationFactory.instance(:command).create(Array(command), node_attributes.list)
113
117
  end
114
118
 
@@ -128,7 +132,9 @@ module Rundock
128
132
  else
129
133
  !cli_options[:run_anyway]
130
134
  end
131
- node_attributes.dry_run = cli_options && cli_options[:dry_run]
135
+ node_attributes.dry_run = cli_options[:dry_run]
136
+ node_attributes.filtered_tasks = cli_options[:filtered_tasks] &&
137
+ cli_options[:filtered_tasks].split(',')
132
138
  end
133
139
 
134
140
  # override by scenario
@@ -6,17 +6,28 @@ module Rundock
6
6
  DEFAULT_TASKS_FILE_PATH = './tasks.yml'
7
7
 
8
8
  def build(scenario_tasks)
9
- tasks = {} unless scenario_tasks
10
-
9
+ tasks = if scenario_tasks.nil?
10
+ {}
11
+ else
12
+ scenario_tasks
13
+ end
11
14
  return scenario_tasks unless @options[:tasks]
12
- if FileTest.exist?(@options[:tasks])
13
- tasks.merge!(YAML.load_file(@options[:tasks]).deep_symbolize_keys)
14
- Logger.info("merged tasks file #{@options[:tasks]}")
15
- elsif FileTest.exist?(DEFAULT_TASKS_FILE_PATH)
16
- Logger.warn("tasks file is not found. use #{DEFAULT_TASKS_FILE_PATH}")
17
- tasks.merge!(YAML.load_file(DEFAULT_TASKS_FILE_PATH).deep_symbolize_keys)
18
- else
19
- Logger.warn("Task path is not available. (#{@options[:tasks]})")
15
+ return tasks if @options[:tasks].nil?
16
+
17
+ task_files = @options[:tasks].split(',')
18
+
19
+ task_files.each do |tk|
20
+ tk.gsub!(/~/, Dir.home)
21
+
22
+ if FileTest.exist?(tk)
23
+ tasks.merge!(YAML.load_file(tk).deep_symbolize_keys)
24
+ Logger.info("merged tasks file #{tk}")
25
+ elsif FileTest.exist?(DEFAULT_TASKS_FILE_PATH)
26
+ Logger.warn("tasks file is not found. use #{DEFAULT_TASKS_FILE_PATH}")
27
+ tasks.merge!(YAML.load_file(DEFAULT_TASKS_FILE_PATH).deep_symbolize_keys)
28
+ else
29
+ Logger.warn("Task path is not available. (#{tk})")
30
+ end
20
31
  end
21
32
 
22
33
  tasks
data/lib/rundock/cli.rb CHANGED
@@ -32,9 +32,10 @@ module Rundock
32
32
  option :sudo, type: :boolean, default: false
33
33
  option :default_ssh_opts, type: :string, aliases: ['-d'], default: DEFAULT_SSH_OPTIONS_DEFAULT_FILE_PATH
34
34
  option :targetgroup, type: :string, aliases: ['-g']
35
- option :tasks, type: :string, aliases: ['-t']
35
+ option :tasks, type: :string, aliases: ['-t'], banner: 'You can specify comma separated task file paths.[ex: task_file1,task_file2,..]'
36
+ option :filtered_tasks, type: :string, aliases: ['-T'], banner: 'You can specify comma separated tasks.[ex: task1,task2,..]'
36
37
  option :hooks, type: :string, aliases: ['-k']
37
- option :run_anyway, type: :boolean, default: false
38
+ option :run_anyway, type: :boolean, aliases: ['-r'], default: false
38
39
  option :dry_run, type: :boolean, aliases: ['-n']
39
40
  def do(*scenario_file_path)
40
41
  scenario_file_path = [DEFAULT_SCENARIO_FILE_PATH] if scenario_file_path.empty?
@@ -46,7 +47,8 @@ module Rundock
46
47
  desc 'ssh [options]', 'Run rundock ssh with various options'
47
48
  option :command, type: :string, aliases: ['-c']
48
49
  option :default_ssh_opts, type: :string, aliases: ['-d'], default: DEFAULT_SSH_OPTIONS_DEFAULT_FILE_PATH
49
- option :tasks, type: :string, aliases: ['-t']
50
+ option :tasks, type: :string, aliases: ['-t'], banner: 'You can specify comma separated task file paths.[ex: task_file1,task_file2,..]'
51
+ option :filtered_tasks, type: :string, aliases: ['-T'], banner: 'You can specify comma separated tasks.[ex: task1,task2,..]'
50
52
  option :hooks, type: :string, aliases: ['-k']
51
53
  option :host, type: :string, aliases: ['-h'], banner: 'You can specify comma separated hosts.[ex: host1,host2,..]'
52
54
  option :targetgroup, type: :string, aliases: ['-g']
@@ -56,7 +58,7 @@ module Rundock
56
58
  option :ssh_config, type: :string, aliases: ['-F']
57
59
  option :ask_password, type: :boolean, default: false
58
60
  option :sudo, type: :boolean, default: false
59
- option :run_anyway, type: :boolean, default: false
61
+ option :run_anyway, type: :boolean, aliases: ['-r'], default: false
60
62
  option :dry_run, type: :boolean, aliases: ['-n']
61
63
  def ssh
62
64
  opts = {}
data/lib/rundock/node.rb CHANGED
@@ -29,6 +29,7 @@ module Rundock
29
29
  @operations.each do |ope|
30
30
  Logger.debug("run operation: #{ope.class}")
31
31
  node_attributes << ope.attributes
32
+ ope.attributes[:nodename] = @name
32
33
  ope.run(@backend, ope.attributes)
33
34
  end
34
35
 
@@ -17,6 +17,8 @@ module Rundock
17
17
  next
18
18
  end
19
19
 
20
+ next if !attributes[:filtered_tasks].nil? && !attributes[:filtered_tasks].include?(task_name)
21
+
20
22
  scenario = Rundock::Builder::ScenarioBuilder.new(nil, nil).build_task(
21
23
  attributes[:task_info][task_name.to_sym], backend, Rundock::Attribute::NodeAttribute.new(attributes)
22
24
  )
@@ -1,3 +1,3 @@
1
1
  module Rundock
2
- VERSION = '1.1.5'
2
+ VERSION = '1.1.6'
3
3
  end
data/rundock.gemspec CHANGED
@@ -1,4 +1,4 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'rundock/version'
4
4
 
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: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - hiracy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-17 00:00:00.000000000 Z
11
+ date: 2018-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler