Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9124508
swarm_update.rb
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
662 B
Subscribers
None
swarm_update.rb
View Options
#!/opt/puppetlabs/puppet/bin/ruby
# frozen_string_literal: true
require
'json'
require
'open3'
require
'puppet'
def
swarm_update
(
image
,
service
)
cmd_string
=
'docker service update'
cmd_string
+=
" --image
#{
image
}
"
unless
image
.
nil?
cmd_string
+=
"
#{
service
}
"
unless
service
.
nil?
stdout
,
stderr
,
status
=
Open3
.
capture3
(
cmd_string
)
raise
Puppet
::
Error
,
"stderr: '
#{
stderr
}
'"
if
status
!=
0
stdout
.
strip
end
params
=
JSON
.
parse
(
STDIN
.
read
)
image
=
params
[
'image'
]
service
=
params
[
'service'
]
begin
result
=
swarm_update
(
image
,
service
)
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, 7:13 PM (2 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3370965
Attached To
R205 puppet-puppetlabs-docker
Event Timeline
Log In to Comment