class Opsicle::ChefUpdate
Attributes
client[R]
stack[R]
tar_file[R]
Public Class Methods
new(environment)
click to toggle source
# File lib/opsicle/commands/chef_update.rb, line 13 def initialize(environment) @environment = environment @client = Client.new(environment) @stack = Stack.new(@client) @tar_file = "#{@stack.name}.tgz" end
Public Instance Methods
execute(options={ monitor: true })
click to toggle source
# File lib/opsicle/commands/chef_update.rb, line 20 def execute(options={ monitor: true }) if options[:"bucket-name"] tar_cookbooks(options[:path]) s3_upload(options[:"bucket-name"]) cleanup_tar end response = update_custom_cookbooks launch_stack_monitor(response, options) end
Private Instance Methods
cleanup_tar()
click to toggle source
# File lib/opsicle/commands/chef_update.rb, line 43 def cleanup_tar FileUtils.rm(tar_file) end
s3_upload(bucket_name)
click to toggle source
# File lib/opsicle/commands/chef_update.rb, line 38 def s3_upload(bucket_name) bucket = S3Bucket.new(@client, bucket_name) bucket.update(tar_file) end
tar_cookbooks(cookbooks_dir)
click to toggle source
# File lib/opsicle/commands/chef_update.rb, line 32 def tar_cookbooks(cookbooks_dir) tgz = Zlib::GzipWriter.new(File.open(tar_file, 'wb')) package = Dir[cookbooks_dir].entries.reject{ |entry| entry =~ /^\.\.?$/ } Archive::Tar::Minitar.pack(package, tgz) end
update_custom_cookbooks()
click to toggle source
# File lib/opsicle/commands/chef_update.rb, line 47 def update_custom_cookbooks Output.say "Starting OpsWorks Custom Cookboks Update..." client.run_command('update_custom_cookbooks') end