Sha256: ba66e6e6d3e55acd22492fa625ac3120ecb9e1346ceccdc2d135bbf44bdfd2c2
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
require_relative 'resource' require_relative 'app' module OpsWorks class Stack < Resource attr_accessor :id, :name def self.all client.describe_stacks.data[:stacks].map do |hash| new(id: hash[:stack_id], name: hash[:name]) end end def self.find_by_name(name) all.find { |stack| stack.name == name } end def apps @apps ||= initialize_apps end def find_app_by_name(name) apps.find { |app| app.name == name } end def update_custom_cookbooks create_deployment(command: { name: 'update_custom_cookbooks' }) end def execute_recipe(recipe) create_deployment( command: { name: 'execute_recipes', args: { 'recipes' => [recipe] } } ) end def deploy_app(app) fail 'App not found' unless app && app.id create_deployment(app_id: app.id, command: { name: 'deploy' }) end private def initialize_apps return [] unless id self.class.client.describe_apps(stack_id: id).data[:apps].map do |hash| revision = hash[:app_source][:revision] if hash[:app_source] App.new(id: hash[:app_id], name: hash[:name], revision: revision) end end def create_deployment(options = {}) response = self.class.client.create_deployment( options.merge(stack_id: id) ) Deployment.from_response(response) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
opsworks-cli-0.2.0 | lib/opsworks/stack.rb |