choria-mcorpc-support 2.24.2 → 2.25.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mcollective/agent/choria_provision.ddl +283 -0
- data/lib/mcollective/agent/choria_provision.json +309 -0
- data/lib/mcollective/agent/choria_registry.ddl +65 -0
- data/lib/mcollective/agent/choria_registry.json +74 -0
- data/lib/mcollective/agent/choria_util.ddl +24 -4
- data/lib/mcollective/agent/choria_util.json +24 -24
- data/lib/mcollective/agent/rpcutil.ddl +242 -183
- data/lib/mcollective/agent/rpcutil.json +53 -56
- data/lib/mcollective/agent/scout.ddl +1 -1
- data/lib/mcollective/agent/scout.json +1 -1
- data/lib/mcollective/application/plugin.rb +7 -159
- data/lib/mcollective/config.rb +10 -0
- data/lib/mcollective/discovery/delegate.rb +4 -2
- data/lib/mcollective/log.rb +1 -2
- data/lib/mcollective/util/choria.rb +14 -8
- data/lib/mcollective/util/tasks_support.rb +13 -3
- data/lib/mcollective.rb +0 -1
- metadata +12 -8
- data/lib/mcollective/generators/agent_generator.rb +0 -50
- data/lib/mcollective/generators/base.rb +0 -45
- data/lib/mcollective/generators/templates/action_snippet.erb +0 -13
- data/lib/mcollective/generators/templates/ddl.erb +0 -8
- data/lib/mcollective/generators/templates/plugin.erb +0 -7
- data/lib/mcollective/generators.rb +0 -6
data/lib/mcollective/config.rb
CHANGED
@@ -137,6 +137,8 @@ module MCollective
|
|
137
137
|
|
138
138
|
raise('Identities can only match /\w\.\-/') unless @identity =~ /^[\w.\-]+$/
|
139
139
|
|
140
|
+
check_deprecations
|
141
|
+
|
140
142
|
@configured = true
|
141
143
|
|
142
144
|
libdirs.each do |dir|
|
@@ -254,5 +256,13 @@ module MCollective
|
|
254
256
|
end
|
255
257
|
end
|
256
258
|
end
|
259
|
+
|
260
|
+
def check_deprecations
|
261
|
+
if @pluginconf["choria.use_srv_records"]
|
262
|
+
Log.warn("Configuration set 'choria.use_srv_records' which is deprecated in favor of 'choria.use_srv'.")
|
263
|
+
@pluginconf["choria.use_srv"] = @pluginconf["choria.use_srv_records"]
|
264
|
+
@pluginconf.delete("choria.use_srv_records")
|
265
|
+
end
|
266
|
+
end
|
257
267
|
end
|
258
268
|
end
|
@@ -10,6 +10,9 @@ module MCollective
|
|
10
10
|
|
11
11
|
cmd = [binary_name, "discover", "-j", "--silent"]
|
12
12
|
|
13
|
+
config = client.options.fetch(:config)
|
14
|
+
cmd << "--config" << config if config
|
15
|
+
|
13
16
|
cmd << "-T" << filter["collective"] if filter["collective"]
|
14
17
|
|
15
18
|
filter.fetch("identity", []).each do |i|
|
@@ -53,6 +56,7 @@ module MCollective
|
|
53
56
|
|
54
57
|
begin
|
55
58
|
Timeout.timeout(timeout + 0.5) do
|
59
|
+
nodes.concat(JSON.parse(stdout.read))
|
56
60
|
status = wait_thr.value
|
57
61
|
|
58
62
|
raise("Choria discovery failed: %s" % stderr.read) unless status.exitstatus == 0
|
@@ -62,8 +66,6 @@ module MCollective
|
|
62
66
|
Process.kill("KILL", wait_thr[:pid])
|
63
67
|
raise("Choria failed to complete discovery within %d timeout" % timeout)
|
64
68
|
end
|
65
|
-
|
66
|
-
nodes.concat(JSON.parse(stdout.read))
|
67
69
|
end
|
68
70
|
|
69
71
|
nodes
|
data/lib/mcollective/log.rb
CHANGED
@@ -96,9 +96,8 @@ module MCollective
|
|
96
96
|
end
|
97
97
|
|
98
98
|
@logger.start
|
99
|
-
rescue Exception
|
99
|
+
rescue Exception # rubocop:disable Lint/RescueException
|
100
100
|
@configured = false
|
101
|
-
warn "Could not start logger: #{e.class} #{e}"
|
102
101
|
end
|
103
102
|
|
104
103
|
# figures out the filename that called us
|
@@ -157,19 +157,19 @@ module MCollective
|
|
157
157
|
|
158
158
|
# Determines if SRV records should be used
|
159
159
|
#
|
160
|
-
# Setting choria.
|
160
|
+
# Setting choria.use_srv to anything other than t, true, yes or 1 will disable
|
161
161
|
# SRV records
|
162
162
|
#
|
163
163
|
# @return [Boolean]
|
164
164
|
def should_use_srv?
|
165
|
-
["t", "true", "yes", "1"].include?(get_option("choria.
|
165
|
+
["t", "true", "yes", "1"].include?(get_option("choria.use_srv", "1").downcase)
|
166
166
|
end
|
167
167
|
|
168
168
|
# Query DNS for a series of records
|
169
169
|
#
|
170
170
|
# The given records will be passed through {#srv_records} to figure out the domain to query in.
|
171
171
|
#
|
172
|
-
# Querying of records can be bypassed by setting choria.
|
172
|
+
# Querying of records can be bypassed by setting choria.use_srv to false
|
173
173
|
#
|
174
174
|
# @yield [Hash] each record for modification by the caller
|
175
175
|
# @param records [Array<String>] the records to query without their domain parts
|
@@ -634,21 +634,27 @@ module MCollective
|
|
634
634
|
|
635
635
|
# The PuppetDB server to connect to
|
636
636
|
#
|
637
|
-
#
|
638
|
-
# then
|
639
|
-
# to puppet:8081
|
637
|
+
# Use choria.puppetdb_host if set, otherwise query
|
638
|
+
# _x-puppet-db._tcp.example.net then _x-puppet._tcp.example.net if SRV
|
639
|
+
# lookup is enabled, and fallback to puppet:8081 if nothing else worked.
|
640
640
|
#
|
641
641
|
# @return [Hash] with :target and :port
|
642
642
|
def puppetdb_server
|
643
|
-
d_host = get_option("choria.puppetdb_host", "puppet")
|
644
643
|
d_port = get_option("choria.puppetdb_port", "8081")
|
645
644
|
|
645
|
+
answer = {
|
646
|
+
:target => get_option("choria.puppetdb_host", nil),
|
647
|
+
:port => d_port
|
648
|
+
}
|
649
|
+
|
650
|
+
return answer if answer[:target]
|
651
|
+
|
646
652
|
answer = try_srv(["_x-puppet-db._tcp"], nil, nil)
|
647
653
|
return answer if answer[:target]
|
648
654
|
|
649
655
|
# In the case where we take _x-puppet._tcp SRV records we unfortunately have
|
650
656
|
# to force the port else it uses the one from Puppet which will 404
|
651
|
-
answer = try_srv(["_x-puppet._tcp"],
|
657
|
+
answer = try_srv(["_x-puppet._tcp"], "puppet", d_port)
|
652
658
|
answer[:port] = d_port
|
653
659
|
|
654
660
|
answer
|
@@ -65,7 +65,7 @@ module MCollective
|
|
65
65
|
# AIO path to binaries like wrappers etc
|
66
66
|
def aio_bin_path
|
67
67
|
if Util.windows?
|
68
|
-
'C:\Program Files\Puppet Labs\Puppet\bin'
|
68
|
+
'C:\Program Files\Puppet Labs\Puppet\puppet\bin'
|
69
69
|
else
|
70
70
|
"/opt/puppetlabs/puppet/bin"
|
71
71
|
end
|
@@ -88,6 +88,13 @@ module MCollective
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
+
# Is this an AIO install?
|
92
|
+
#
|
93
|
+
# @return [Boolean]
|
94
|
+
def aio?
|
95
|
+
File.directory?(aio_bin_path)
|
96
|
+
end
|
97
|
+
|
91
98
|
# Path to the task wrapper executable
|
92
99
|
#
|
93
100
|
# @return [String]
|
@@ -179,6 +186,8 @@ module MCollective
|
|
179
186
|
"_choria_task_caller" => task_caller
|
180
187
|
}
|
181
188
|
|
189
|
+
environment["PATH"] = "#{aio_bin_path}#{File::PATH_SEPARATOR}#{ENV['PATH']}" if aio?
|
190
|
+
|
182
191
|
return environment unless task["input"]
|
183
192
|
return environment unless ["both", "environment"].include?(task_input_method(task))
|
184
193
|
|
@@ -186,6 +195,7 @@ module MCollective
|
|
186
195
|
environment["PT_%s" % k] = v.to_s
|
187
196
|
end
|
188
197
|
|
198
|
+
environment["PT__task"] = task["task"]
|
189
199
|
environment["PT__installdir"] = File.join(request_spooldir(task_id), "files")
|
190
200
|
|
191
201
|
environment
|
@@ -249,7 +259,7 @@ module MCollective
|
|
249
259
|
# act on these tasks either by asking for their status or perhaps killing
|
250
260
|
# them?
|
251
261
|
#
|
252
|
-
# @param command [
|
262
|
+
# @param command [String] command to run
|
253
263
|
# @param environment [Hash] environment to run with
|
254
264
|
# @param stdin [String] stdin to send to the command
|
255
265
|
# @param spooldir [String] path to the spool for this specific request
|
@@ -290,7 +300,7 @@ module MCollective
|
|
290
300
|
Process.exec(environment, command, options)
|
291
301
|
end
|
292
302
|
else
|
293
|
-
pid = Process.spawn(environment, command, options)
|
303
|
+
pid = Process.spawn(environment, [command, command], options)
|
294
304
|
end
|
295
305
|
|
296
306
|
sleep 0.1 until File.exist?(wrapper_stdout)
|
data/lib/mcollective.rb
CHANGED
@@ -43,7 +43,6 @@ module MCollective
|
|
43
43
|
require "mcollective/log"
|
44
44
|
require "mcollective/message"
|
45
45
|
require "mcollective/optionparser"
|
46
|
-
require "mcollective/generators"
|
47
46
|
require "mcollective/pluginmanager"
|
48
47
|
require "mcollective/pluginpackager"
|
49
48
|
require "mcollective/rpc"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: choria-mcorpc-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.25.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- R.I.Pienaar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: systemu
|
@@ -37,6 +37,9 @@ dependencies:
|
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0.6'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.7.0
|
40
43
|
type: :runtime
|
41
44
|
prerelease: false
|
42
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -44,6 +47,9 @@ dependencies:
|
|
44
47
|
- - "~>"
|
45
48
|
- !ruby/object:Gem::Version
|
46
49
|
version: '0.6'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.7.0
|
47
53
|
description: Libraries enabling Ruby support for the Choria Orchestration Server
|
48
54
|
email: rip@devco.net
|
49
55
|
executables:
|
@@ -57,6 +63,10 @@ files:
|
|
57
63
|
- lib/mcollective/agent/bolt_tasks.ddl
|
58
64
|
- lib/mcollective/agent/bolt_tasks.json
|
59
65
|
- lib/mcollective/agent/bolt_tasks.rb
|
66
|
+
- lib/mcollective/agent/choria_provision.ddl
|
67
|
+
- lib/mcollective/agent/choria_provision.json
|
68
|
+
- lib/mcollective/agent/choria_registry.ddl
|
69
|
+
- lib/mcollective/agent/choria_registry.json
|
60
70
|
- lib/mcollective/agent/choria_util.ddl
|
61
71
|
- lib/mcollective/agent/choria_util.json
|
62
72
|
- lib/mcollective/agent/rpcutil.ddl
|
@@ -118,12 +128,6 @@ files:
|
|
118
128
|
- lib/mcollective/facts.rb
|
119
129
|
- lib/mcollective/facts/base.rb
|
120
130
|
- lib/mcollective/facts/yaml_facts.rb
|
121
|
-
- lib/mcollective/generators.rb
|
122
|
-
- lib/mcollective/generators/agent_generator.rb
|
123
|
-
- lib/mcollective/generators/base.rb
|
124
|
-
- lib/mcollective/generators/templates/action_snippet.erb
|
125
|
-
- lib/mcollective/generators/templates/ddl.erb
|
126
|
-
- lib/mcollective/generators/templates/plugin.erb
|
127
131
|
- lib/mcollective/log.rb
|
128
132
|
- lib/mcollective/logger.rb
|
129
133
|
- lib/mcollective/logger/base.rb
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module MCollective
|
2
|
-
module Generators
|
3
|
-
class AgentGenerator < Base
|
4
|
-
attr_accessor :ddl, :content
|
5
|
-
|
6
|
-
def initialize(plugin_name, actions=[], name=nil, description=nil, author=nil,
|
7
|
-
license=nil, version=nil, url=nil, timeout=nil)
|
8
|
-
|
9
|
-
super(name, description, author, license, version, url, timeout)
|
10
|
-
@plugin_name = plugin_name
|
11
|
-
@actions = actions || []
|
12
|
-
@ddl = create_ddl
|
13
|
-
@mod_name = "Agent"
|
14
|
-
@pclass = "RPC::Agent"
|
15
|
-
@content = create_plugin_content
|
16
|
-
@plugin = create_plugin_string
|
17
|
-
write_plugins
|
18
|
-
end
|
19
|
-
|
20
|
-
def create_ddl
|
21
|
-
action_text = ""
|
22
|
-
@actions.each_with_index do |action, i|
|
23
|
-
action_text += "action \"#{action}\", :description => \"%ACTIONDESCRIPTION%\" do\n"
|
24
|
-
action_text += action_help if i == 0
|
25
|
-
action_text += "end\n"
|
26
|
-
action_text += "\n" unless @actions.size == (i + 1)
|
27
|
-
end
|
28
|
-
# Use inherited method to create metadata part of the ddl
|
29
|
-
create_metadata_string + action_text
|
30
|
-
end
|
31
|
-
|
32
|
-
def create_plugin_content
|
33
|
-
content_text = ""
|
34
|
-
|
35
|
-
# Add actions to agent file
|
36
|
-
@actions.each_with_index do |action, i|
|
37
|
-
content_text += "%6s%s" % [" ", "action \"#{action}\" do\n"]
|
38
|
-
content_text += "%6s%s" % [" ", "end\n"]
|
39
|
-
content_text += "\n" unless @actions.size == (i + 1)
|
40
|
-
end
|
41
|
-
content_text
|
42
|
-
end
|
43
|
-
|
44
|
-
def action_help
|
45
|
-
action_snippet = File.read(File.join(File.dirname(__FILE__), "templates", "action_snippet.erb"))
|
46
|
-
ERB.new(action_snippet).result
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module MCollective
|
2
|
-
module Generators
|
3
|
-
class Base
|
4
|
-
attr_accessor :meta, :plugin_name, :mod_name
|
5
|
-
|
6
|
-
def initialize(name, description, author, license, version, url, timeout)
|
7
|
-
@meta = {:name => name,
|
8
|
-
:description => description,
|
9
|
-
:author => author,
|
10
|
-
:license => license,
|
11
|
-
:version => version,
|
12
|
-
:url => url,
|
13
|
-
:timeout => timeout}
|
14
|
-
end
|
15
|
-
|
16
|
-
def create_metadata_string
|
17
|
-
ddl_template = File.read(File.join(File.dirname(__FILE__), "templates", "ddl.erb"))
|
18
|
-
ERB.new(ddl_template, nil, "-").result(binding)
|
19
|
-
end
|
20
|
-
|
21
|
-
def create_plugin_string
|
22
|
-
plugin_template = File.read(File.join(File.dirname(__FILE__), "templates", "plugin.erb"))
|
23
|
-
ERB.new(plugin_template, nil, "-").result(binding)
|
24
|
-
end
|
25
|
-
|
26
|
-
def write_plugins
|
27
|
-
Dir.mkdir @plugin_name
|
28
|
-
dirname = File.join(@plugin_name, @mod_name.downcase)
|
29
|
-
Dir.mkdir dirname
|
30
|
-
puts "Created plugin directory : #{@plugin_name}"
|
31
|
-
|
32
|
-
File.open(File.join(dirname, "#{@plugin_name}.ddl"), "w") {|f| f.puts @ddl}
|
33
|
-
puts "Created DDL file : #{File.join(dirname, "#{@plugin_name}.ddl")}"
|
34
|
-
|
35
|
-
File.open(File.join(dirname, "#{@plugin_name}.rb"), "w") {|f| f.puts @plugin}
|
36
|
-
puts "Created #{@mod_name} file : #{File.join(dirname, "#{@plugin_name}.rb")}"
|
37
|
-
rescue Errno::EEXIST
|
38
|
-
raise "cannot generate '#{@plugin_name}' : plugin directory already exists."
|
39
|
-
rescue Exception => e # rubocop:disable Lint/RescueException
|
40
|
-
FileUtils.rm_rf(@plugin_name) if File.directory?(@plugin_name)
|
41
|
-
raise "cannot generate plugin - #{e}"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# Example Input
|
2
|
-
input :name,
|
3
|
-
:prompt => "%PROMPT%",
|
4
|
-
:description => "%DESCRIPTION%",
|
5
|
-
:type => %TYPE%,
|
6
|
-
:validation => '%VALIDATION%',
|
7
|
-
:optional => %OPTIONAL%,
|
8
|
-
:maxlength => %MAXLENGTH%
|
9
|
-
|
10
|
-
# Example output
|
11
|
-
output :name,
|
12
|
-
:description => "%DESCRIPTION%",
|
13
|
-
:display_as => "%DISPLAYAS%"
|
@@ -1,8 +0,0 @@
|
|
1
|
-
metadata :name => "<%= meta[:name] || "%FULLNANE%" -%>",
|
2
|
-
:description => "<%= meta[:description] || "%DESCRIPTION%" -%>",
|
3
|
-
:author => "<%= meta[:author] || "%AUTHOR%" -%>",
|
4
|
-
:license => "<%= meta[:license] || "%LICENSE%" -%>",
|
5
|
-
:version => "<%= meta[:version] || "%VERSION%" -%>",
|
6
|
-
:url => "<%= meta[:url] || "%URL%" -%>",
|
7
|
-
:timeout => <%= meta[:timeout] || "%TIMEOUT%" %>
|
8
|
-
|