Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9123347
swarm_token.rb
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
559 B
Subscribers
None
swarm_token.rb
View Options
#!/opt/puppetlabs/puppet/bin/ruby
require
'json'
require
'open3'
require
'puppet'
def
swarm_token
(
node_role
)
cmd_string
=
"docker swarm join-token -q"
cmd_string
<<
"
#{
node_role
}
"
unless
node_role
.
nil?
stdout
,
stderr
,
status
=
Open3
.
capture3
(
cmd_string
)
raise
Puppet
::
Error
,
(
"stderr: '
#{
stderr
}
'"
)
if
status
!=
0
stdout
.
strip
end
params
=
JSON
.
parse
(
STDIN
.
read
)
node_role
=
params
[
'node_role'
]
begin
result
=
swarm_token
(
node_role
)
puts
result
exit
0
rescue
Puppet
::
Error
=>
e
puts
({
status
:
'failure'
,
error
:
e
.
message
})
exit
1
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Sat, Jun 21, 5:21 PM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3370865
Attached To
R205 puppet-puppetlabs-docker
Event Timeline
Log In to Comment