knife-node-context-exec 1.0.7 → 1.0.8

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: e5269957a4d043e29c5f3444102508a935c9a50d
4
- data.tar.gz: e9150da6b57f87de0169a74f8c0e975f2f18e56c
3
+ metadata.gz: 924b310b24ebca668eaa253f28aacf9c5b30f487
4
+ data.tar.gz: 5332adaa69f487fb901e1b56485803f9d9370839
5
5
  SHA512:
6
- metadata.gz: f445ffbddd8a670aab38f429c3a45855b8ae6c066817fe6fca1195013d09e84782c3a1cf30eaaa6c7a74016b9ce9b5dc5214712b23150425f6caa3044a04335f
7
- data.tar.gz: 233b49f475cb9c4d3d257d56e472a0d9c5edf0575c0ff3a4b427b30a97b1470d10a73113d2d3856e7768faac9f45be10bec68d962ba32db00723f02bcc97a119
6
+ metadata.gz: edb59950c594b10d4cc97194363cd9b0b9fb408fb07dea793c200c2c628fae43c493d24ab932160389e71d479f8c41f0320a9dc43ba1c7454b1e23ced2b6bdbf
7
+ data.tar.gz: 3b6854e76099d3214e2aced02dc6bc63b1769aea8742ca74517d3cf6e32a503b590f9bd46a33738befda25cba2e83f1c1b4b78a2284d1d194abe1ee8bb1aabfb
@@ -1,73 +1,81 @@
1
1
  require 'knife-node-context-exec/version'
2
2
  require 'chef/knife'
3
3
 
4
- # The knife
5
- class ContextExec < Chef::Knife
6
- banner 'knife context exec'
4
+ module KnifeNodeContextExec
5
+ # The knife
6
+ class ContextExec < Chef::Knife
7
+ banner 'knife context exec'
7
8
 
8
- deps do
9
- require 'chef/search/query'
10
- require 'knife-node-context-exec/runner'
11
- end
9
+ deps do
10
+ require 'chef/search/query'
11
+ require 'knife-node-context-exec/runner'
12
+ end
12
13
 
13
- option :environment,
14
- short: '-E VALUE',
15
- long: '--environment VALUE',
16
- description: 'The environment to search.'
17
- option :node_query,
18
- short: '-Q VALUE',
19
- long: '--query VALUE',
20
- description: 'The node query.'
21
- option :directory,
22
- short: '-D VALUE',
23
- long: '--directory VALUE',
24
- description: 'A directory for working files.'
25
- option :template_filename,
26
- short: '-T VALUE',
27
- long: '--template VALUE',
28
- description: 'The filename of a template.'
29
- option :script_filename,
30
- short: '-S VALUE',
31
- long: '--script VALUE',
32
- description: 'The environment to search.'
33
- option :command,
34
- short: '-C VALUE',
35
- long: '--command VALUE',
36
- description: 'The command to run.'
37
- option :filter_regex,
38
- short: '-R VALUE',
39
- long: '--regex VALUE',
40
- description: 'A regex used to filter output.'
41
- option :parallel,
42
- short: '-P',
43
- long: '--parallel',
44
- description: 'Run in parallel?',
45
- boolean: true | false,
46
- default: false
14
+ option :environment,
15
+ short: '-E ENVIRONMENT',
16
+ long: '--environment ENVIRONMENT',
17
+ description: 'The environment to search.'
18
+ option :node_query,
19
+ short: '-Q QUERY',
20
+ long: '--query QUERY',
21
+ description: 'The node query.'
22
+ option :directory,
23
+ short: '-D DIRECTORY',
24
+ long: '--directory DIRECTORY',
25
+ description: 'A directory for working files.'
26
+ option :template_filename,
27
+ short: '-T TEMPLATE',
28
+ long: '--template TEMPLATE',
29
+ description: 'The filename of a template.'
30
+ option :script_filename,
31
+ short: '-S SCRIPT',
32
+ long: '--script SCRIPT',
33
+ description: 'The environment to search.'
34
+ option :command,
35
+ short: '-C COMMAND',
36
+ long: '--command COMMAND',
37
+ description: 'The command to run.'
38
+ option :filter_regex,
39
+ short: '-R REGEX',
40
+ long: '--regex REGEX',
41
+ description: 'A regex used to filter output.'
42
+ option :parallel,
43
+ short: '-P',
44
+ long: '--parallel',
45
+ description: 'Run in parallel?',
46
+ boolean: true | false,
47
+ default: false
47
48
 
48
- def run
49
- puts "knife context exec #{KnifeNodeContextExec::VERSION}"
50
- environment = config[:environment].to_s
51
- node_query = config[:node_query].to_s
52
- directory = config[:directory].to_s
53
- template_filename = config[:template_filename].to_s
54
- script_filename = config[:script_filename].to_s
55
- command = config[:command].to_s
56
- filter_regex = config[:filter_regex].to_s
57
- parallel = config[:parallel]
58
- puts "Environment: #{environment}"
59
- puts "Query: #{node_query}"
60
- puts "Directory: #{directory}"
61
- puts "Template: #{template_filename}"
62
- puts "Script: #{script_filename}"
63
- puts "Command: #{command}"
64
- puts "Regex: #{filter_regex}"
65
- puts "Parallel? #{parallel}"
66
- nodes = Chef::Search::Query.new.search(:node, node_query).first.select do |node|
67
- node.environment == environment
49
+ def run
50
+ puts "knife context exec #{KnifeNodeContextExec::VERSION}"
51
+ environment = config[:environment].to_s
52
+ node_query = config[:node_query].to_s
53
+ directory = config[:directory].to_s
54
+ template_filename = config[:template_filename].to_s
55
+ script_filename = config[:script_filename].to_s
56
+ command = config[:command].to_s
57
+ filter_regex = config[:filter_regex].to_s
58
+ parallel = config[:parallel]
59
+ raise 'Some parameters are missing' if
60
+ environment.empty? || node_query.empty? || directory.empty? || template_filename.empty? ||
61
+ script_filename.empty? || command.empty? || filter_regex.empty?
62
+ directory = File.expand_path(directory)
63
+ template_filename = File.expand_path(template_filename)
64
+ script_filename = File.expand_path(script_filename)
65
+ puts "Environment: #{environment}"
66
+ puts "Query: #{node_query}"
67
+ puts "Directory: #{directory}"
68
+ puts "Template: #{template_filename}"
69
+ puts "Script: #{script_filename}"
70
+ puts "Command: #{command}"
71
+ puts "Regex: #{filter_regex}"
72
+ puts "Parallel? #{parallel}"
73
+ nodes = Chef::Search::Query.new.search(:node, node_query).first.select do |node|
74
+ node.environment == environment
75
+ end
76
+ nodes.each { |node| puts "Found #{node.name}" }
77
+ KnifeNodeContextExec.run(nodes, directory, template_filename, script_filename, command, filter_regex,
78
+ parallel, false)
68
79
  end
69
- nodes.each { |node| puts "Found #{node.name}" }
70
- KnifeNodeContextExec.run(nodes, directory, template_filename, script_filename, command, filter_regex,
71
- parallel, false)
72
80
  end
73
81
  end
@@ -16,8 +16,8 @@ module KnifeNodeContextExec
16
16
  end
17
17
 
18
18
  def run
19
- yield(">>>> Executing script for #{node.name}")
20
19
  @thread = Thread.new do
20
+ yield(">>>> Executing script for #{node.name} <<<<")
21
21
  script_directory = "#{working_directory}/#{node.name}"
22
22
  FileUtils.makedirs(script_directory)
23
23
  template = File.read(template_filename)
@@ -35,6 +35,7 @@ module KnifeNodeContextExec
35
35
  end
36
36
  end
37
37
  end
38
+ yield(">>>> Executing script for #{node.name} <<<<")
38
39
  self
39
40
  end
40
41
 
@@ -1,3 +1,3 @@
1
1
  module KnifeNodeContextExec
2
- VERSION = '1.0.7'.freeze
2
+ VERSION = '1.0.8'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-node-context-exec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Heald