choria-mcorpc-support 2.23.0 → 2.24.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +5 -5
  2. data/lib/mcollective.rb +3 -3
  3. data/lib/mcollective/agent/bolt_tasks.ddl +18 -0
  4. data/lib/mcollective/agent/bolt_tasks.json +18 -0
  5. data/lib/mcollective/agent/bolt_tasks.rb +4 -2
  6. data/lib/mcollective/agent/rpcutil.ddl +2 -2
  7. data/lib/mcollective/agent/rpcutil.json +2 -2
  8. data/lib/mcollective/application/choria.rb +3 -63
  9. data/lib/mcollective/application/facts.rb +2 -67
  10. data/lib/mcollective/application/federation.rb +1 -3
  11. data/lib/mcollective/application/find.rb +1 -1
  12. data/lib/mcollective/application/ping.rb +31 -3
  13. data/lib/mcollective/application/plugin.rb +2 -15
  14. data/lib/mcollective/application/tasks.rb +9 -0
  15. data/lib/mcollective/client.rb +1 -1
  16. data/lib/mcollective/config.rb +135 -103
  17. data/lib/mcollective/ddl.rb +0 -1
  18. data/lib/mcollective/discovery.rb +12 -65
  19. data/lib/mcollective/discovery/broadcast.ddl +11 -0
  20. data/lib/mcollective/discovery/choria.ddl +6 -4
  21. data/lib/mcollective/discovery/delegate.ddl +13 -0
  22. data/lib/mcollective/discovery/delegate.rb +73 -0
  23. data/lib/mcollective/discovery/external.ddl +13 -0
  24. data/lib/mcollective/discovery/file.ddl +13 -0
  25. data/lib/mcollective/discovery/flatfile.ddl +7 -5
  26. data/lib/mcollective/discovery/inventory.ddl +13 -0
  27. data/lib/mcollective/discovery/mc.ddl +3 -3
  28. data/lib/mcollective/generators.rb +0 -1
  29. data/lib/mcollective/message.rb +0 -24
  30. data/lib/mcollective/optionparser.rb +2 -2
  31. data/lib/mcollective/pluginpackager/forge_packager.rb +1 -1
  32. data/lib/mcollective/rpc/client.rb +6 -4
  33. data/lib/mcollective/security/base.rb +1 -37
  34. data/lib/mcollective/util.rb +23 -31
  35. data/lib/mcollective/util/choria.rb +0 -157
  36. data/lib/mcollective/util/tasks_support.rb +22 -3
  37. metadata +9 -27
  38. data/lib/mcollective/application/describe_filter.rb +0 -87
  39. data/lib/mcollective/data.rb +0 -96
  40. data/lib/mcollective/data/agent_data.ddl +0 -22
  41. data/lib/mcollective/data/agent_data.rb +0 -17
  42. data/lib/mcollective/data/base.rb +0 -68
  43. data/lib/mcollective/data/bolt_task_data.ddl +0 -90
  44. data/lib/mcollective/data/bolt_task_data.rb +0 -32
  45. data/lib/mcollective/data/collective_data.ddl +0 -20
  46. data/lib/mcollective/data/collective_data.rb +0 -9
  47. data/lib/mcollective/data/fact_data.ddl +0 -28
  48. data/lib/mcollective/data/fact_data.rb +0 -55
  49. data/lib/mcollective/data/fstat_data.ddl +0 -89
  50. data/lib/mcollective/data/fstat_data.rb +0 -54
  51. data/lib/mcollective/data/result.rb +0 -50
  52. data/lib/mcollective/ddl/dataddl.rb +0 -56
  53. data/lib/mcollective/discovery/choria.rb +0 -223
  54. data/lib/mcollective/discovery/flatfile.rb +0 -47
  55. data/lib/mcollective/discovery/stdin.ddl +0 -11
  56. data/lib/mcollective/discovery/stdin.rb +0 -67
  57. data/lib/mcollective/generators/data_generator.rb +0 -50
  58. data/lib/mcollective/generators/templates/data_input_snippet.erb +0 -7
  59. data/lib/mcollective/matcher.rb +0 -220
  60. data/lib/mcollective/matcher/parser.rb +0 -118
  61. data/lib/mcollective/matcher/scanner.rb +0 -236
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 240757ac597e3d2cfe78d338c925b62b7e9ae384
4
- data.tar.gz: d67ed99f4a98219aa82f9b193c3eafc6a7ed0668
2
+ SHA256:
3
+ metadata.gz: 56d418c1be77553ab3139e83deb55a7e0c765e0772ef7774da3f4e3a8150757b
4
+ data.tar.gz: 1b4a31f0f2abf0e567c72549f0dc602b4a9e80021aa4f53528c24fbb2bca8ece
5
5
  SHA512:
6
- metadata.gz: d513a4149861bd15a98250139e282b0681465d58f6a1e6503dd8b7e0323f22f7c9c5c80a4f502a52dca8322d9349946ccef538c219bf899144f988a731262144
7
- data.tar.gz: eb5b2c1a2127999d93b49ae248e2f19ae95e30163c5b209eeb70c74ba2c5b6f10d6851172eb7656922e536c83f164d707526914bde8f5cc1303dfd2b62be1656
6
+ metadata.gz: 607d333a8a2e2b274686ffd68915cf3dafd133e515ea6441bdd13d5d5fe17f934a979990de3c8f3bc4046ba7c56fb0ace7da7a5991ab54f5ef564505680cb70e
7
+ data.tar.gz: 4673c0ff851b1f09fc0b480b8a7f1ae610e7f329ad444d6e41a88d76bd36724a843b3bdbad23cc47ff8570602383b629677dd51a2e465b4e37ae9afbd8fbd4fc
data/lib/mcollective.rb CHANGED
@@ -15,6 +15,7 @@ require "mcollective/monkey_patches"
15
15
  require "mcollective/cache"
16
16
  require "mcollective/exceptions"
17
17
  require "systemu"
18
+ require "open3"
18
19
 
19
20
  # == The Marionette Collective
20
21
  #
@@ -34,13 +35,12 @@ module MCollective
34
35
  require "mcollective/client"
35
36
  require "mcollective/config"
36
37
  require "mcollective/connector"
37
- require "mcollective/data"
38
38
  require "mcollective/ddl"
39
39
  require "mcollective/discovery"
40
+ require "mcollective/discovery/delegate"
40
41
  require "mcollective/facts"
41
42
  require "mcollective/logger"
42
43
  require "mcollective/log"
43
- require "mcollective/matcher"
44
44
  require "mcollective/message"
45
45
  require "mcollective/optionparser"
46
46
  require "mcollective/generators"
@@ -54,7 +54,7 @@ module MCollective
54
54
  require "mcollective/util"
55
55
  require "mcollective/validator"
56
56
 
57
- VERSION = "2.23.0".freeze
57
+ VERSION = "2.24.1".freeze
58
58
 
59
59
  def self.version
60
60
  VERSION
@@ -77,6 +77,15 @@ action "run_and_wait", :description => "Runs a Puppet Task that was previously d
77
77
  :default => "{}",
78
78
  :maxlength => 102400
79
79
 
80
+ input :run_as,
81
+ :prompt => "Run As",
82
+ :description => "User to run the task as",
83
+ :type => :string,
84
+ :validation => ".+",
85
+ :optional => true,
86
+ :default => nil,
87
+ :maxlength => 32
88
+
80
89
  output :task_id,
81
90
  :description => "The ID the task was created with",
82
91
  :display_as => "Task ID",
@@ -165,6 +174,15 @@ action "run_no_wait", :description => "Runs a Puppet Task that was previously do
165
174
  :default => "{}",
166
175
  :maxlength => 102400
167
176
 
177
+ input :run_as,
178
+ :prompt => "Run As",
179
+ :description => "User to run the task as",
180
+ :type => :string,
181
+ :validation => ".+",
182
+ :optional => true,
183
+ :default => nil,
184
+ :maxlength => 32
185
+
168
186
  output :task_id,
169
187
  :description => "The ID the task was created with",
170
188
  :display_as => "Task ID",
@@ -101,6 +101,15 @@
101
101
  "optional": false,
102
102
  "validation": "^.+$",
103
103
  "maxlength": 102400
104
+ },
105
+ "run_as": {
106
+ "prompt": "Run As",
107
+ "description": "User to run the task as",
108
+ "type": "string",
109
+ "default": null,
110
+ "optional": true,
111
+ "validation": ".+",
112
+ "maxlength": 32
104
113
  }
105
114
  },
106
115
  "output": {
@@ -233,6 +242,15 @@
233
242
  "optional": true,
234
243
  "validation": "^.+$",
235
244
  "maxlength": 102400
245
+ },
246
+ "run_as": {
247
+ "prompt": "Run As",
248
+ "description": "User to run the task as",
249
+ "type": "string",
250
+ "default": null,
251
+ "optional": true,
252
+ "validation": ".+",
253
+ "maxlength": 32
236
254
  }
237
255
  },
238
256
  "output": {
@@ -37,7 +37,8 @@ module MCollective
37
37
  "task" => request[:task],
38
38
  "input_method" => request[:input_method],
39
39
  "input" => request[:input],
40
- "files" => JSON.parse(request[:files])
40
+ "files" => JSON.parse(request[:files]),
41
+ "run_as" => request[:run_as]
41
42
  }
42
43
 
43
44
  unless tasks.cached?(task["files"])
@@ -77,7 +78,8 @@ module MCollective
77
78
  "task" => request[:task],
78
79
  "input_method" => request[:input_method],
79
80
  "input" => request[:input],
80
- "files" => JSON.parse(request[:files])
81
+ "files" => JSON.parse(request[:files]),
82
+ "run_as" => request[:run_as]
81
83
  }
82
84
 
83
85
  status = tasks.run_task_command(reply[:task_id], task, false, request.caller)
@@ -65,9 +65,9 @@ action "get_fact", :description => "Retrieve a single fact from the fact store"
65
65
  :prompt => "The name of the fact",
66
66
  :description => "The fact to retrieve",
67
67
  :type => :string,
68
- :validation => '^[\w\-\.]+$',
68
+ :validation => '.+',
69
69
  :optional => false,
70
- :maxlength => 256
70
+ :maxlength => 512
71
71
 
72
72
  output :fact,
73
73
  :description => "The name of the fact being returned",
@@ -216,8 +216,8 @@
216
216
  "type": "string",
217
217
  "default": null,
218
218
  "optional": false,
219
- "validation": "^[\\w\\-\\.]+$",
220
- "maxlength": 256
219
+ "validation": ".+",
220
+ "maxlength": 512
221
221
  }
222
222
  },
223
223
  "output": {
@@ -8,37 +8,18 @@ module MCollective
8
8
 
9
9
  The ACTION can be one of the following:
10
10
 
11
- request_cert - requests a certificate from the Puppet CA
12
11
  show_config - shows the active configuration parameters
13
12
 
14
- The environment is chosen using --environment and the concurrent
15
- runs may be limited using --batch.
16
-
17
- The batching works a bit different than typical, it will only batch
18
- based on a sorted list of certificate names, this means the batches
19
- will always run in predictable order.
20
13
  USAGE
21
14
 
22
15
  exclude_argument_sections "common", "filter", "rpc"
23
16
 
24
- option :ca,
25
- :arguments => ["--ca SERVER"],
26
- :description => "Address of your Puppet CA",
27
- :type => String
28
-
29
- option :certname,
30
- :arguments => ["--certname CERTNAME"],
31
- :description => "Override the default certificate name",
32
- :type => String
33
-
34
17
  def post_option_parser(configuration)
35
18
  if ARGV.length >= 1
36
19
  configuration[:command] = ARGV.shift
37
20
  else
38
21
  abort("Please specify a command, valid commands are: %s" % valid_commands.join(", "))
39
22
  end
40
-
41
- ENV["MCOLLECTIVE_CERTNAME"] = configuration[:certname] if configuration[:certname]
42
23
  end
43
24
 
44
25
  # Validates the configuration
@@ -48,10 +29,6 @@ module MCollective
48
29
  Util.loadclass("MCollective::Util::Choria")
49
30
 
50
31
  abort("Unknown command %s, valid commands are: %s" % [configuration[:command], valid_commands.join(", ")]) unless valid_commands.include?(configuration[:command])
51
-
52
- if !choria.has_client_public_cert? && !["request_cert", "show_config"].include?(configuration[:command])
53
- abort("A certificate is needed from the Puppet CA for `%s`, please use the `request_cert` command" % choria.certname)
54
- end
55
32
  end
56
33
 
57
34
  def main
@@ -66,45 +43,8 @@ module MCollective
66
43
  #
67
44
  # @return [void]
68
45
  def request_cert_command
69
- disconnect
70
-
71
- raise(Util::Choria::UserError, "Cannot only request certificates in Puppet security mode") unless choria.puppet_security?
72
-
73
- raise(Util::Choria::UserError, "Already have a certificate '%s', cannot request a new one" % choria.client_public_cert) if choria.has_client_public_cert?
74
-
75
- choria.ca = configuration[:ca] if configuration[:ca]
76
-
77
- certname = choria.client_public_cert
78
-
79
- choria.make_ssl_dirs
80
- choria.fetch_ca
81
-
82
- if choria.waiting_for_cert?
83
- puts("Certificate %s has already been requested, attempting to retrieve it" % certname)
84
- else
85
- puts("Requesting certificate for '%s'" % certname)
86
- choria.request_cert
87
- end
88
-
89
- puts("Waiting up to 240 seconds for it to be signed")
90
- puts
91
-
92
- puts("Key fingerprint: %s" % choria.csr_fingerprint)
93
- puts
94
-
95
- 24.times do |time|
96
- print "Attempting to download certificate %s: %d / 24\r" % [certname, time]
97
-
98
- break if choria.attempt_fetch_cert
99
-
100
- sleep 10
101
- end
102
-
103
- unless choria.has_client_public_cert?
104
- raise(Util::Choria::UserError, "Could not fetch the certificate after 240 seconds, please ensure it gets signed and rerun this command")
105
- end
106
-
107
- puts("Certificate %s has been stored in %s" % [certname, choria.ssl_dir])
46
+ puts("Please use 'choria enroll' to enroll in the security subsystem")
47
+ raise(Util::Choria::Abort, "1")
108
48
  end
109
49
 
110
50
  def show_config_command # rubocop:disable Metrics/MethodLength
@@ -174,7 +114,7 @@ module MCollective
174
114
  if valid_ssl
175
115
  puts " Valid SSL Setup: %s" % [Util.colorize(:green, "yes")]
176
116
  else
177
- puts " Valid SSL Setup: %s try running 'mco choria request_cert'" % [Util.colorize(:red, "no")]
117
+ puts " Valid SSL Setup: %s try running 'choria enroll'" % [Util.colorize(:red, "no")]
178
118
  end
179
119
 
180
120
  puts " Security Provider: %s" % [choria.security_provider]
@@ -1,71 +1,6 @@
1
1
  class MCollective::Application::Facts < MCollective::Application # rubocop:disable Style/ClassAndModuleChildren
2
2
  description "Reports on usage for a specific fact"
3
3
 
4
- def post_option_parser(configuration)
5
- configuration[:fact] = ARGV.shift unless ARGV.empty?
6
- end
7
-
8
- def validate_configuration(configuration)
9
- raise "Please specify a fact to report for" unless configuration.include?(:fact)
10
- end
11
-
12
- def show_single_fact_report(fact, facts, verbose=false)
13
- puts("Report for fact: #{fact}\n\n")
14
-
15
- facts = stringify_facts_hash(facts)
16
-
17
- field_size = MCollective::Util.field_size(facts.keys)
18
- facts.keys.sort.each do |k|
19
- printf(" %-#{field_size}s found %d times\n", k, facts[k].size)
20
-
21
- next unless verbose
22
-
23
- puts
24
-
25
- facts[k].sort.each do |f|
26
- puts(" #{f}")
27
- end
28
-
29
- puts
30
- end
31
- end
32
-
33
- def stringify_facts_hash(facts)
34
- res = Hash.new([])
35
- facts.each { |k, v| res[k.to_s] += v }
36
- res
37
- end
38
-
39
- def main
40
- rpcutil = rpcclient("rpcutil")
41
- rpcutil.progress = false
42
-
43
- facts = {}
44
-
45
- rpcutil.get_fact(:fact => configuration[:fact]) do |resp|
46
- begin
47
- value = resp[:body][:data][:value].to_s
48
-
49
- if resp[:body][:data].include?(:value)
50
- if facts.include?(value)
51
- facts[value] << resp[:senderid]
52
- else
53
- facts[value] = [resp[:senderid]]
54
- end
55
- end
56
- rescue Exception => e # rubocop:disable Lint/RescueException
57
- warn "Could not parse facts for #{resp[:senderid]}: #{e.class}: #{e}"
58
- end
59
- end
60
-
61
- if facts.empty?
62
- puts "No values found for fact #{configuration[:fact]}\n"
63
- else
64
- show_single_fact_report(configuration[:fact], facts, options[:verbose])
65
- end
66
-
67
- printrpcstats
68
-
69
- halt rpcutil.stats
70
- end
4
+ external(:command => "choria", :args => ["facts"])
5
+ external_help(:command => "choria", :args => ["facts", "--help"])
71
6
  end
@@ -217,9 +217,7 @@ The ACTION can be one of the following:
217
217
 
218
218
  abort("Unknown command %s, valid commands are: %s" % [configuration[:command], valid_commands.join(", ")]) unless valid_commands.include?(configuration[:command])
219
219
 
220
- if !choria.has_client_public_cert? && !["request_cert", "show_config"].include?(configuration[:command])
221
- abort("A certificate is needed from the Puppet CA for `%s`, please use the `request_cert` command" % choria.certname)
222
- end
220
+ abort("A certificate is needed from the Puppet CA for `%s`, please use the `choria enroll` command" % choria.certname) unless choria.has_client_public_cert?
223
221
  end
224
222
 
225
223
  def main
@@ -16,7 +16,7 @@ class MCollective::Application::Find < MCollective::Application # rubocop:disabl
16
16
 
17
17
  nodes.each {|c| puts c}
18
18
 
19
- warn "\nDiscovered %s nodes in %.2f seconds using the %s discovery plugin" % [nodes.size, discoverytime, mc.client.discoverer.discovery_method] if options[:verbose]
19
+ warn "\nDiscovered %s nodes in %.2f seconds using the %s discovery plugin" % [nodes.size, discoverytime, mc.client.options[:discovery_method]] if options[:verbose]
20
20
 
21
21
  !nodes.empty? ? exit(0) : exit(1)
22
22
  end
@@ -1,8 +1,36 @@
1
1
  module MCollective
2
2
  class Application::Ping < Application # rubocop:disable Style/ClassAndModuleChildren
3
- description "Ping all nodes"
3
+ description "Low level network connectivity test"
4
4
 
5
- external(:command => "choria", :args => ["ping"])
6
- external_help(:command => "choria", :args => ["ping", "--help"])
5
+ def main
6
+ # If the user did not override the default timeout include the discovery timeout
7
+ if options[:timeout] == 5
8
+ discovery_timeout = options[:disctimeout] || Config.instance.discovery_timeout || 0
9
+ options[:timeout] = options[:timeout] + discovery_timeout
10
+ end
11
+ client = MCollective::Client.new(options)
12
+
13
+ start = Time.now.to_f
14
+ times = []
15
+
16
+ client.req("ping", "discovery") do |resp|
17
+ times << (Time.now.to_f - start) * 1000
18
+
19
+ puts "%-40s time=%.2f ms" % [resp[:senderid], times.last]
20
+ end
21
+
22
+ puts("\n\n---- ping statistics ----")
23
+
24
+ if !times.empty?
25
+ sum = times.inject(0) {|acc, i| acc + i}
26
+ avg = sum / times.length.to_f
27
+
28
+ puts "%d replies max: %.2f min: %.2f avg: %.2f" % [times.size, times.max, times.min, avg]
29
+ else
30
+ puts("No responses received")
31
+ end
32
+
33
+ halt client.stats
34
+ end
7
35
  end
8
36
  end
@@ -9,7 +9,6 @@ mco plugin package [options] <directory>
9
9
  mco plugin doc <plugin>
10
10
  mco plugin doc <type/plugin>
11
11
  mco plugin generate agent <pluginname> [actions=val,val]
12
- mco plugin generate data <pluginname> [outputs=val,val]
13
12
 
14
13
  info : Display plugin information including package details.
15
14
  package : Create all available plugin packages.
@@ -116,11 +115,6 @@ mco plugin package [options] <directory>
116
115
  :arguments => ["--actions [ACTIONS]"],
117
116
  :type => Array
118
117
 
119
- option :outputs,
120
- :description => "Outputs to be generated for an Data Plugin",
121
- :arguments => ["--outputs [OUTPUTS]"],
122
- :type => Array
123
-
124
118
  option :keep_artifacts,
125
119
  :description => "Don't remove artifacts after building packages",
126
120
  :arguments => ["--keep-artifacts"],
@@ -167,7 +161,7 @@ mco plugin package [options] <directory>
167
161
 
168
162
  # Generate a plugin skeleton
169
163
  def generate_command
170
- raise "undefined plugin type. cannot generate plugin. valid types are 'agent' and 'data'" if configuration["target"] == "."
164
+ raise "undefined plugin type. cannot generate plugin. valid types are 'agent'" if configuration["target"] == "."
171
165
 
172
166
  unless configuration[:pluginname]
173
167
  puts "No plugin name specified. Using 'new_plugin'"
@@ -181,12 +175,6 @@ mco plugin package [options] <directory>
181
175
  Generators::AgentGenerator.new(configuration[:pluginname], configuration[:actions], configuration[:pluginname],
182
176
  configuration[:description], configuration[:author], configuration[:license],
183
177
  configuration[:version], configuration[:url], configuration[:timeout])
184
- when "data"
185
- raise "data plugin must have at least one output" unless configuration[:outputs]
186
-
187
- Generators::DataGenerator.new(configuration[:pluginname], configuration[:outputs], configuration[:pluginname],
188
- configuration[:description], configuration[:author], configuration[:license],
189
- configuration[:version], configuration[:url], configuration[:timeout])
190
178
  else
191
179
  raise "invalid plugin type. cannot generate plugin '#{configuration[:target]}'"
192
180
  end
@@ -228,7 +216,6 @@ mco plugin package [options] <directory>
228
216
  ["Agents", :agent],
229
217
  ["Aggregate", :aggregate],
230
218
  ["Connectors", :connector],
231
- ["Data Queries", :data],
232
219
  ["Discovery Methods", :discovery],
233
220
  ["Validator Plugins", :validator]
234
221
  ]
@@ -345,7 +332,7 @@ mco plugin package [options] <directory>
345
332
  # Return the name of the type of plugin as a string
346
333
  def identify_plugin
347
334
  plugintype = Dir.glob(File.join(configuration[:target], "*")).select do |file|
348
- File.directory?(file) && file.match(/(connector|facts|registration|security|audit|pluginpackager|data|discovery|validator)/)
335
+ File.directory?(file) && file.match(/(connector|facts|registration|security|audit|pluginpackager|discovery|validator)/)
349
336
  end
350
337
 
351
338
  raise "more than one plugin type detected in directory" if plugintype.size > 1