marathon_deploy 0.0.5 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/TODO +4 -3
 - data/bin/deploy.rb +39 -9
 - data/examples/jondeploy2.yaml +1 -1
 - data/lib/marathon_deploy/application.rb +11 -4
 - data/lib/marathon_deploy/marathon_client.rb +1 -1
 - data/lib/marathon_deploy/marathon_defaults.rb +2 -0
 - data/lib/marathon_deploy/version.rb +1 -1
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 0b3213c4005fdc4ffb221d60f443a949c60f1c0c
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 30b2c173fa0ae0800f607314efdb0ad2b73b7dc1
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 05cf5e91997520dfae47244112b20042cb9aa108e1859bc07b567940ca0b612286eeedd1a49b5e38b44f4478382420016483ea30869735e6c26c4a585b6af69e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 924f980722aadb76eb761ebf827636a9453627172654b6bf102f99ebf57fdc2a81cd97592e43c57d2d4409539cce611f0f3c531c94d50020f768dd4511557739
         
     | 
    
        data/TODO
    CHANGED
    
    | 
         @@ -4,8 +4,9 @@ 
     | 
|
| 
       4 
4 
     | 
    
         
             
            DONE datacenter handling, iterate
         
     | 
| 
       5 
5 
     | 
    
         
             
            DONE deployment status polling
         
     | 
| 
       6 
6 
     | 
    
         
             
            - config assembler / generate properties script ?
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
            DESCOPED read in ENVIRONMENT VARIABLES WITH MARATHON_ and add to deployment json ?
         
     | 
| 
       8 
8 
     | 
    
         
             
            - inject / replce minimumHealthCapacity is 1, maximumOverCapacity is 1
         
     | 
| 
       9 
9 
     | 
    
         
             
            DESCOPED custom external ports (must be provided in json)
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 10 
     | 
    
         
            +
            DONE read macros %NAME% from yaml/json and verify they are defined
         
     | 
| 
      
 11 
     | 
    
         
            +
            DONE gem structure / packaging / metadata
         
     | 
| 
      
 12 
     | 
    
         
            +
            DONE implement noop
         
     | 
    
        data/bin/deploy.rb
    CHANGED
    
    | 
         @@ -12,11 +12,13 @@ require 'logger' 
     | 
|
| 
       12 
12 
     | 
    
         
             
            options = {}
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
            # DEFAULTS
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
            DEFAULT_DEPLOYFILE = MarathonDeploy::MarathonDefaults::DEFAULT_DEPLOYFILE
         
     | 
| 
       16 
16 
     | 
    
         
             
            options[:debug] = MarathonDeploy::MarathonDefaults::DEFAULT_LOGLEVEL
         
     | 
| 
       17 
17 
     | 
    
         
             
            options[:environment] = MarathonDeploy::MarathonDefaults::DEFAULT_ENVIRONMENT_NAME
         
     | 
| 
       18 
18 
     | 
    
         
             
            options[:marathon_endpoints] = MarathonDeploy::MarathonDefaults::DEFAULT_PREPRODUCTION_MARATHON_ENDPOINTS
         
     | 
| 
       19 
19 
     | 
    
         
             
            options[:logfile] = MarathonDeploy::MarathonDefaults::DEFAULT_LOGFILE
         
     | 
| 
      
 20 
     | 
    
         
            +
            options[:force] = MarathonDeploy::MarathonDefaults::DEFAULT_FORCE_DEPLOY
         
     | 
| 
      
 21 
     | 
    
         
            +
            options[:noop] = MarathonDeploy::MarathonDefaults::DEFAULT_NOOP
         
     | 
| 
       20 
22 
     | 
    
         | 
| 
       21 
23 
     | 
    
         
             
            OptionParser.new do |opts|
         
     | 
| 
       22 
24 
     | 
    
         
             
              opts.banner = "Usage: #{$0} [options]"
         
     | 
| 
         @@ -39,10 +41,15 @@ OptionParser.new do |opts| 
     | 
|
| 
       39 
41 
     | 
    
         
             
                exit
         
     | 
| 
       40 
42 
     | 
    
         
             
              end
         
     | 
| 
       41 
43 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
              opts.on("-f", "-- 
     | 
| 
       43 
     | 
    
         
            -
                options[: 
     | 
| 
      
 44 
     | 
    
         
            +
              opts.on("-f", "--force", "Force deployment when sending same deploy JSON to Marathon") do |f|
         
     | 
| 
      
 45 
     | 
    
         
            +
                options[:force] = true
         
     | 
| 
       44 
46 
     | 
    
         
             
              end
         
     | 
| 
       45 
47 
     | 
    
         | 
| 
      
 48 
     | 
    
         
            +
              opts.on("-n", "--noop", "No action. Just display what would be performed.") do |f|
         
     | 
| 
      
 49 
     | 
    
         
            +
                options[:noop] = true
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
              
         
     | 
| 
      
 52 
     | 
    
         
            +
              
         
     | 
| 
       46 
53 
     | 
    
         
             
              opts.on("-e", "--environment ENVIRONMENT", "Default: #{options[:environment]}" ) do |e|
         
     | 
| 
       47 
54 
     | 
    
         
             
                options[:environment] = e
         
     | 
| 
       48 
55 
     | 
    
         
             
              end
         
     | 
| 
         @@ -51,14 +58,28 @@ OptionParser.new do |opts| 
     | 
|
| 
       51 
58 
     | 
    
         
             
                puts opts
         
     | 
| 
       52 
59 
     | 
    
         
             
                exit
         
     | 
| 
       53 
60 
     | 
    
         
             
              end 
         
     | 
| 
      
 61 
     | 
    
         
            +
              
         
     | 
| 
       54 
62 
     | 
    
         
             
            end.parse!
         
     | 
| 
       55 
63 
     | 
    
         | 
| 
      
 64 
     | 
    
         
            +
            abort("Ambiguous arguments: #{ARGV.join(',')}. Only one deploy file argument may be passed.") if (ARGV.length > 1)
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
            argfile = ARGV.pop
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            if (!argfile.nil?)
         
     | 
| 
      
 69 
     | 
    
         
            +
              abort("Deploy file \'#{argfile}\' does not exist!") unless(File.file?(argfile))
         
     | 
| 
      
 70 
     | 
    
         
            +
              deployfile = argfile
         
     | 
| 
      
 71 
     | 
    
         
            +
            elsif (File.file?(DEFAULT_DEPLOYFILE))
         
     | 
| 
      
 72 
     | 
    
         
            +
              deployfile = DEFAULT_DEPLOYFILE
         
     | 
| 
      
 73 
     | 
    
         
            +
            else
         
     | 
| 
      
 74 
     | 
    
         
            +
              abort("No deploy file argument provided and default \'#{DEFAULT_DEPLOYFILE}\' does not exist in current directory \'#{Dir.pwd}\'")  
         
     | 
| 
      
 75 
     | 
    
         
            +
            end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
       56 
77 
     | 
    
         
             
            $LOG = options[:logfile] ? Logger.new(options[:logfile]) : Logger.new(STDOUT)
         
     | 
| 
       57 
78 
     | 
    
         
             
            $LOG.level = options[:debug]
         
     | 
| 
       58 
79 
     | 
    
         | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
      
 80 
     | 
    
         
            +
            noop = options[:noop]  
         
     | 
| 
       60 
81 
     | 
    
         
             
            environment = MarathonDeploy::Environment.new(options[:environment])
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
      
 82 
     | 
    
         
            +
                
         
     | 
| 
       62 
83 
     | 
    
         
             
            marathon_endpoints = Array.new
         
     | 
| 
       63 
84 
     | 
    
         
             
            if (options[:marathon_endpoints].nil?)
         
     | 
| 
       64 
85 
     | 
    
         
             
              if (environment.is_production?)
         
     | 
| 
         @@ -71,11 +92,15 @@ else 
     | 
|
| 
       71 
92 
     | 
    
         
             
            end
         
     | 
| 
       72 
93 
     | 
    
         | 
| 
       73 
94 
     | 
    
         
             
            begin
         
     | 
| 
       74 
     | 
    
         
            -
              application = MarathonDeploy::Application.new(deployfile)
         
     | 
| 
      
 95 
     | 
    
         
            +
              application = MarathonDeploy::Application.new(:deployfile => deployfile, :force => options[:force])
         
     | 
| 
       75 
96 
     | 
    
         
             
            rescue MarathonDeploy::Error::IOError, MarathonDeploy::Error::UndefinedMacroError,MarathonDeploy::Error::MissingMarathonAttributesError,MarathonDeploy::Error::UnsupportedFileExtension  => e
         
     | 
| 
       76 
97 
     | 
    
         
             
              $LOG.debug(e)
         
     | 
| 
       77 
98 
     | 
    
         
             
              $LOG.error(e.message)
         
     | 
| 
       78 
99 
     | 
    
         
             
              exit!
         
     | 
| 
      
 100 
     | 
    
         
            +
            rescue JSON::ParserError => e
         
     | 
| 
      
 101 
     | 
    
         
            +
              $LOG.debug(e)
         
     | 
| 
      
 102 
     | 
    
         
            +
              $LOG.error("\'#{deployfile}\' seems to be invalid JSON. Please verify the file.")
         
     | 
| 
      
 103 
     | 
    
         
            +
              exit!
         
     | 
| 
       79 
104 
     | 
    
         
             
            end
         
     | 
| 
       80 
105 
     | 
    
         | 
| 
       81 
106 
     | 
    
         
             
            begin
         
     | 
| 
         @@ -89,13 +114,16 @@ if (!environment.is_production?) 
     | 
|
| 
       89 
114 
     | 
    
         
             
              application.overlay_preproduction_settings
         
     | 
| 
       90 
115 
     | 
    
         
             
            end
         
     | 
| 
       91 
116 
     | 
    
         | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
      
 117 
     | 
    
         
            +
            display_msg = " MARATHON JSON DEPLOYMENT INSTRUCTIONS "
         
     | 
| 
      
 118 
     | 
    
         
            +
            puts '#' * 50 + display_msg + '#' * 50
         
     | 
| 
       93 
119 
     | 
    
         
             
            puts JSON.pretty_generate(application.json)
         
     | 
| 
       94 
     | 
    
         
            -
            puts "#" * 100
         
     | 
| 
      
 120 
     | 
    
         
            +
            puts "#" * (100 + display_msg.length)
         
     | 
| 
       95 
121 
     | 
    
         | 
| 
       96 
     | 
    
         
            -
            # deploy to each endpoint
         
     | 
| 
      
 122 
     | 
    
         
            +
            # deploy to each marathon endpoint
         
     | 
| 
       97 
123 
     | 
    
         
             
            marathon_endpoints.each do |marathon_url|
         
     | 
| 
       98 
124 
     | 
    
         
             
              begin
         
     | 
| 
      
 125 
     | 
    
         
            +
                puts "[NOOP] Sending JSON deployment instructions to marathon endpoint: #{marathon_url}." if (noop)
         
     | 
| 
      
 126 
     | 
    
         
            +
                next if (noop)
         
     | 
| 
       99 
127 
     | 
    
         
             
                client = MarathonDeploy::MarathonClient.new(marathon_url)
         
     | 
| 
       100 
128 
     | 
    
         
             
                client.application = application
         
     | 
| 
       101 
129 
     | 
    
         
             
                client.deploy  
         
     | 
| 
         @@ -111,3 +139,5 @@ marathon_endpoints.each do |marathon_url| 
     | 
|
| 
       111 
139 
     | 
    
         
             
              end
         
     | 
| 
       112 
140 
     | 
    
         | 
| 
       113 
141 
     | 
    
         
             
            end
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
            puts "[NOOP] Deployment completed." if (noop)
         
     | 
    
        data/examples/jondeploy2.yaml
    CHANGED
    
    
| 
         @@ -10,10 +10,16 @@ module MarathonDeploy 
     | 
|
| 
       10 
10 
     | 
    
         
             
              attr_reader :json, :id
         
     | 
| 
       11 
11 
     | 
    
         
             
              attr_accessor :envs
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
              def initialize( 
     | 
| 
      
 13 
     | 
    
         
            +
              def initialize(options={})
         
     | 
| 
      
 14 
     | 
    
         
            +
                default_options = {
         
     | 
| 
      
 15 
     | 
    
         
            +
                  :force => false,
         
     | 
| 
      
 16 
     | 
    
         
            +
                  :deployfile => 'deploy.yaml'
         
     | 
| 
      
 17 
     | 
    
         
            +
                  }
         
     | 
| 
      
 18 
     | 
    
         
            +
                options = default_options.merge!(options)
         
     | 
| 
      
 19 
     | 
    
         
            +
                deployfile = options[:deployfile]
         
     | 
| 
       14 
20 
     | 
    
         | 
| 
       15 
21 
     | 
    
         
             
                if (!File.exist?(File.join(Dir.pwd,deployfile)))
         
     | 
| 
       16 
     | 
    
         
            -
                  message = "#{deployfile} not found in current directory #{File.join(Dir.pwd)}"
         
     | 
| 
      
 22 
     | 
    
         
            +
                  message = "\'#{deployfile}\' not found in current directory #{File.join(Dir.pwd)}"
         
     | 
| 
       17 
23 
     | 
    
         
             
                  raise Error::IOError, message, caller
         
     | 
| 
       18 
24 
     | 
    
         
             
                end
         
     | 
| 
       19 
25 
     | 
    
         | 
| 
         @@ -43,8 +49,9 @@ module MarathonDeploy 
     | 
|
| 
       43 
49 
     | 
    
         
             
                end
         
     | 
| 
       44 
50 
     | 
    
         | 
| 
       45 
51 
     | 
    
         
             
                @deployfile = deployfile                
         
     | 
| 
       46 
     | 
    
         
            -
                @json =  Utils.deep_symbolize(@json) 
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
      
 52 
     | 
    
         
            +
                @json =  Utils.deep_symbolize(@json)  
         
     | 
| 
      
 53 
     | 
    
         
            +
                  
         
     | 
| 
      
 54 
     | 
    
         
            +
                add_identifier if (options[:force])
         
     | 
| 
       48 
55 
     | 
    
         | 
| 
       49 
56 
     | 
    
         
             
              end
         
     | 
| 
       50 
57 
     | 
    
         | 
| 
         @@ -48,7 +48,7 @@ module MarathonDeploy 
     | 
|
| 
       48 
48 
     | 
    
         
             
                else     
         
     | 
| 
       49 
49 
     | 
    
         
             
                  response = deployment.create_app
         
     | 
| 
       50 
50 
     | 
    
         
             
                end
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
       52 
52 
     | 
    
         
             
                if ((300..999).include?(response.code.to_i))
         
     | 
| 
       53 
53 
     | 
    
         
             
                  $LOG.error("Deployment response body => " + JSON.pretty_generate(JSON.parse(response.body)))
         
     | 
| 
       54 
54 
     | 
    
         
             
                  raise Error::DeploymentError, "Deployment returned response code #{response.code}", caller
         
     | 
| 
         @@ -18,6 +18,8 @@ module MarathonDeploy 
     | 
|
| 
       18 
18 
     | 
    
         
             
              DEFAULT_LOGLEVEL = Logger::INFO
         
     | 
| 
       19 
19 
     | 
    
         
             
              MARATHON_APPS_REST_PATH = '/v2/apps/'
         
     | 
| 
       20 
20 
     | 
    
         
             
              MARATHON_DEPLOYMENT_REST_PATH = '/v2/deployments/'
         
     | 
| 
      
 21 
     | 
    
         
            +
              DEFAULT_FORCE_DEPLOY = false
         
     | 
| 
      
 22 
     | 
    
         
            +
              DEFAULT_NOOP = false
         
     | 
| 
       21 
23 
     | 
    
         | 
| 
       22 
24 
     | 
    
         
             
              @@preproduction_override = {
         
     | 
| 
       23 
25 
     | 
    
         
             
                :instances => 5,
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: marathon_deploy
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Jonathan Colby
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015-05- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-05-24 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: logger
         
     | 
| 
         @@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       130 
130 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       131 
131 
     | 
    
         
             
            requirements: []
         
     | 
| 
       132 
132 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       133 
     | 
    
         
            -
            rubygems_version: 2.4. 
     | 
| 
      
 133 
     | 
    
         
            +
            rubygems_version: 2.4.5
         
     | 
| 
       134 
134 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       135 
135 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       136 
136 
     | 
    
         
             
            summary: Mesos/Marathon deployment tool.
         
     |