mesos-deploy 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +1 -0
- data/bin/mesos-deploy +40 -0
- data/lib/mesos-deploy.rb +82 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 59fdc7d0147f32fdcc9203c700d1dffcd593a3bd
|
4
|
+
data.tar.gz: 222f071e0b9cd50e2844f376a2d1718560a5565b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d1cb3eb7b140ac1ada12bfd28687c1fe41765e16e1c0d2d9afe44d239652d60f8f7ef0db56bb4e84da4beca9a1bbd92c692034b9dbc41a0035d0b259ff0dd546
|
7
|
+
data.tar.gz: a93e41280c1162cf07ba54ce2b26934bfd0dc005ef38eb9f8a8ef71fcf0b06458372071c46eb63b104032b24b40f27368ada087908f0b0d30e3cce7cf14e81f5
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Offers.com
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# mesos-deploy
|
data/bin/mesos-deploy
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'mesos-deploy'
|
3
|
+
|
4
|
+
def valid_release?(release)
|
5
|
+
!!release && release =~ /r([0-9]*)/
|
6
|
+
end
|
7
|
+
|
8
|
+
def usage
|
9
|
+
puts <<USAGE
|
10
|
+
Usage: mesos-deploy <release> [config.yml]
|
11
|
+
You must have added a release tag in the registry/repo, like r01
|
12
|
+
|
13
|
+
USAGE
|
14
|
+
end
|
15
|
+
|
16
|
+
begin
|
17
|
+
release = ARGV[0]
|
18
|
+
usage unless valid_release?(release)
|
19
|
+
|
20
|
+
deployer = MesosDeploy.new(release, ARGV[1])
|
21
|
+
rescue
|
22
|
+
puts <<ERROR_MESSAGE
|
23
|
+
A mesos-config.yml file must be in the same directory that this command is run, or passed as an argument.
|
24
|
+
This yml file should be formatted like so and contain at least the top line:
|
25
|
+
|
26
|
+
repo: registry.example.net/engineering/example
|
27
|
+
singularity_url: http://singularity.example/singularity
|
28
|
+
marathon:
|
29
|
+
url: http://marathon.example
|
30
|
+
user: example
|
31
|
+
password: example
|
32
|
+
marathons:
|
33
|
+
- /example/example
|
34
|
+
- ...<as many entries here as necessary>
|
35
|
+
ERROR_MESSAGE
|
36
|
+
exit
|
37
|
+
end
|
38
|
+
|
39
|
+
deployer.run
|
40
|
+
|
data/lib/mesos-deploy.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'colorize'
|
3
|
+
require 'erb'
|
4
|
+
require 'json'
|
5
|
+
require 'singularity'
|
6
|
+
require 'yaml'
|
7
|
+
|
8
|
+
class MesosDeploy
|
9
|
+
|
10
|
+
def initialize(release, file = nil)
|
11
|
+
path = File.join(Dir.pwd, "mesos-deploy.yml")
|
12
|
+
if !!file
|
13
|
+
@config = YAML.load_file(file)
|
14
|
+
elsif File.exists? (path)
|
15
|
+
@config = YAML.load_file(path)
|
16
|
+
else
|
17
|
+
raise ArgumentError.new("No mesos-deploy.yml file found.")
|
18
|
+
end
|
19
|
+
|
20
|
+
if !valid_release?(release)
|
21
|
+
raise ArgumentError.new("Invalid release number given.")
|
22
|
+
end
|
23
|
+
|
24
|
+
if !@config['repo']
|
25
|
+
raise ArgumentError.new("YML file given has no repo defined.")
|
26
|
+
end
|
27
|
+
|
28
|
+
@release = release
|
29
|
+
@repo = @config['repo']
|
30
|
+
if @config['singularity_url']
|
31
|
+
@singularity_url = @config['singularity_url']
|
32
|
+
end
|
33
|
+
if @config['marathons']
|
34
|
+
@marathon_url = @config['marathon']['url']
|
35
|
+
@marathon_user = @config['marathon']['user']
|
36
|
+
@marathon_password = @config['marathon']['password']
|
37
|
+
@marathons = @config['marathons']
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def deploy_singularity
|
42
|
+
path = File.join(Dir.pwd, 'singularity')
|
43
|
+
Dir["#{path}/*.json"].each do |file|
|
44
|
+
Singularity::Deployer.new(@singularity_url, file, @release).deploy
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def update_mescal_config(image)
|
49
|
+
# Update mescal config file revision
|
50
|
+
config = JSON.parse(File.read(".mescal.json"))
|
51
|
+
config['image'] = image
|
52
|
+
File.open(".mescal.json", 'w') { |config_file| config_file.puts(JSON.dump(config)) }
|
53
|
+
|
54
|
+
puts "Updating .mescal.json".yellow
|
55
|
+
system("git add .mescal.json && git commit -m \"update .mescal.json [skip build]\" && git push origin `git rev-parse --abbrev-ref HEAD`")
|
56
|
+
end
|
57
|
+
|
58
|
+
def valid_release?(release)
|
59
|
+
!!release && release =~ /r([0-9]*)/
|
60
|
+
end
|
61
|
+
|
62
|
+
def run
|
63
|
+
# singularity deploy if necessary
|
64
|
+
if !!@singularity_url
|
65
|
+
deploy_singularity
|
66
|
+
end
|
67
|
+
|
68
|
+
# marathon deploy if necessary
|
69
|
+
docker_image = "#{@repo}:#{@release}"
|
70
|
+
if !!@marathons
|
71
|
+
@marathons.each do |app_id|
|
72
|
+
cmd = "haile -R #{@marathon_url} -U #{@marathon_user} -P #{@marathon_password} docker_deploy -i #{app_id} -d #{docker_image}"
|
73
|
+
system(cmd)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# update mescal configuration
|
78
|
+
if File.exists?(File.join(Dir.pwd, ".mescal.json"))
|
79
|
+
update_mescal_config(docker_image)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mesos-deploy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Travis Webb
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.7.7
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.7.7
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.7.7
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.7.7
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: singularity-cli
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.2.1
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.2.1
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: haile
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.4.2
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 0.4.2
|
73
|
+
description: 'Usage: mesos-deploy <release> [config.yml]'
|
74
|
+
email:
|
75
|
+
executables:
|
76
|
+
- mesos-deploy
|
77
|
+
extensions: []
|
78
|
+
extra_rdoc_files: []
|
79
|
+
files:
|
80
|
+
- LICENSE
|
81
|
+
- README.md
|
82
|
+
- bin/mesos-deploy
|
83
|
+
- lib/mesos-deploy.rb
|
84
|
+
homepage: https://github.com/offers/mesos-deploy
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.5.1
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: mesos deploy tools
|
108
|
+
test_files: []
|