Module: EbDeployer
- Defined in:
- lib/eb_deployer.rb,
lib/eb_deployer/package.rb,
lib/eb_deployer/version.rb,
lib/eb_deployer/beanstalk.rb,
lib/eb_deployer/s3_driver.rb,
lib/eb_deployer/smoke_test.rb,
lib/eb_deployer/application.rb,
lib/eb_deployer/environment.rb,
lib/eb_deployer/event_poller.rb,
lib/eb_deployer/config_loader.rb,
lib/eb_deployer/default_config.rb,
lib/eb_deployer/deployment_strategy.rb,
lib/eb_deployer/cloud_formation_driver.rb,
lib/eb_deployer/cloud_formation_provisioner.rb
Defined Under Namespace
Modules: DeploymentStrategy Classes: Application, Beanstalk, CloudFormationDriver, CloudFormationProvisioner, ConfigLoader, DefaultConfig, Environment, EventPoller, Package, ResourceNotInReadyState, S3Driver, SmokeTest
Constant Summary collapse
- VERSION =
"0.2.6"
Class Method Summary collapse
- .cli ⇒ Object
-
.deploy(opts) ⇒ Object
Deploy a package to specfied environments on elastic beanstalk.
- .destroy(opts) ⇒ Object
-
.query_resource_output(key, opts) ⇒ Object
Query ouput value of the cloud formation stack.
Class Method Details
.cli ⇒ Object
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/eb_deployer.rb', line 206 def self.cli = { :action => :deploy, :environment => 'dev', :config_file => 'config/eb_deployer.yml' } parser = cli_parser() parser.parse! action = .delete(:action) unless File.exists?([:config_file]) puts "Generated default configuration at #{[:config_file]}." DefaultConfig.new(File.basename(Dir.pwd)).write_to([:config_file]) exit(2) end if ![:package] && action == :deploy puts "Missing options: -p (--package)" puts parser exit(-1) end self.send(action, ConfigLoader.new.load()) end |
.deploy(opts) ⇒ Object
Deploy a package to specfied environments on elastic beanstalk
packages will be stored. Note that the string ".packages" will be added as a suffix to your bucket. So, if "thoughtworks.simple" is passed as the bucket name, the actual s3 bucket name will be thoughtworks.simple.packages.
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/eb_deployer.rb', line 155 def self.deploy(opts) # AWS.config(:logger => Logger.new($stdout)) if region = opts[:region] AWS.config(:region => region) end bs = opts[:bs_driver] || Beanstalk.new s3 = opts[:s3_driver] || S3Driver.new cf = opts[:cf_driver] || CloudFormationDriver.new stack_name = opts[:solution_stack_name] || "64bit Amazon Linux running Tomcat 7" app = opts[:application] env_name = opts[:environment] version_label = opts[:version_label].to_s.strip cname = opts[:cname] env_settings = opts[:option_settings] || opts[:settings] || [] strategy_name = opts[:strategy] || :blue_green cname_prefix = opts[:cname_prefix] || [app, env_name].join('-') smoke_test = opts[:smoke_test] || Proc.new {} phoenix_mode = opts[:phoenix_mode] bucket = opts[:package_bucket] || app application = Application.new(app, bs, s3, bucket) cf = CloudFormationProvisioner.new("#{app}-#{env_name}", cf) strategy = DeploymentStrategy.create(strategy_name, app, env_name, bs, :solution_stack => stack_name, :cname_prefix => cname_prefix, :smoke_test => smoke_test, :phoenix_mode => phoenix_mode) if resources = opts[:resources] env_settings += cf.provision(resources) end application.create_version(version_label, opts[:package]) strategy.deploy(version_label, env_settings) end |
.destroy(opts) ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/eb_deployer.rb', line 194 def self.destroy(opts) if region = opts[:region] AWS.config(:region => region) end app = opts[:application] bs = opts[:bs_driver] || Beanstalk.new s3 = opts[:s3_driver] || S3Driver.new cf = opts[:cf_driver] || CloudFormationDriver.new Application.new(app, bs, s3).delete end |
.query_resource_output(key, opts) ⇒ Object
Query ouput value of the cloud formation stack
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/eb_deployer.rb', line 35 def self.query_resource_output(key, opts) # AWS.config(:logger => Logger.new($stdout)) if region = opts[:region] AWS.config(:region => region) end app = opts[:application] env_name = opts[:environment] cf = opts[:cf_driver] || CloudFormationDriver.new provisioner = CloudFormationProvisioner.new("#{app}-#{env_name}", cf) provisioner.output(key) end |