module Stackit::Mixin::OpsWorks
Attributes
opsworks[RW]
Public Instance Methods
opsworks_cookbook_source(key = :DevOpsBucket, cookbook_archive = 'cookbooks.tar.gz')
click to toggle source
# File lib/stackit/mixin/opsworks.rb, line 11 def opsworks_cookbook_source(key = :DevOpsBucket, cookbook_archive = 'cookbooks.tar.gz') "https://s3.amazonaws.com/#{resolve_parameter(key)}/#{cookbook_archive}" end
opsworks_execute_recipe(stack_id, layer_ids, recipes, attributes = nil)
click to toggle source
# File lib/stackit/mixin/opsworks.rb, line 47 def opsworks_execute_recipe(stack_id, layer_ids, recipes, attributes = nil) recipes = recipes.is_a?(Array) ? recipes : [recipes] layer_ids = layer_ids.is_a?(Array) ? layer_ids : [layer_ids] opsworks.create_deployment({ stack_id: stack_id, layer_ids: layer_ids, command: { name: "execute_recipes", args: { "recipes" => recipes, }, }, custom_json: attributes })[:deployment_id] end
opsworks_instance(key = :OpsWorksInstance)
click to toggle source
# File lib/stackit/mixin/opsworks.rb, line 29 def opsworks_instance(key = :OpsWorksInstance) opsworks.describe_instances({ instance_ids: [ Stackit::ParameterResolver.new(stack).resolve(key) ] })[:instances][0] end
opsworks_layer_id(key = :OpsWorksLayer)
click to toggle source
# File lib/stackit/mixin/opsworks.rb, line 19 def opsworks_layer_id(key = :OpsWorksLayer) Stackit::ParameterResolver.new(stack).resolve(key) end
opsworks_layers(stack_id)
click to toggle source
# File lib/stackit/mixin/opsworks.rb, line 23 def opsworks_layers(stack_id) opsworks.describe_layers( stack_id: stack_id ).layers end
opsworks_service_role_arn(key = :OpsWorksServiceRole)
click to toggle source
# File lib/stackit/mixin/opsworks.rb, line 7 def opsworks_service_role_arn(key = :OpsWorksServiceRole) "arn:aws:iam::#{Stackit.aws.account_id}:role/#{resolve_parameter(key)}" end
opsworks_stack_id(key = :OpsWorksStack)
click to toggle source
# File lib/stackit/mixin/opsworks.rb, line 15 def opsworks_stack_id(key = :OpsWorksStack) Stackit::ParameterResolver.new(stack).resolve(key) end
opsworks_update_custom_cookbooks(stack_id, layer_id)
click to toggle source
# File lib/stackit/mixin/opsworks.rb, line 37 def opsworks_update_custom_cookbooks(stack_id, layer_id) opsworks.create_deployment({ stack_id: stack_id, layer_ids: [layer_id], command: { name: "update_custom_cookbooks" } })[:deployment_id] end
opsworks_wait_for_deployment(deployment_id, status_pattern = /successful/) { |stack| ... }
click to toggle source
# File lib/stackit/mixin/opsworks.rb, line 63 def opsworks_wait_for_deployment(deployment_id, status_pattern = /successful/) Stackit.logger.info "Waiting for deployment #{deployment_id} to complete..." wait_for(timeout: 15.minutes) do deployment = Stackit.aws.opsworks.describe_deployments({ deployment_ids: [deployment_id] })[:deployments][0] case deployment.status when /failed/ raise Stackit::WaitError, "Deployment failed during wait: #{deployment_id}" when status_pattern yield stack if block_given? true else false end end end