Class: Qops::Cookbook
- Inherits:
-
Thor
- Object
- Thor
- Qops::Cookbook
- Includes:
- CookbookHelpers
- Defined in:
- lib/qops/cookbook/cookbook.rb
Instance Method Summary collapse
- #cleanup ⇒ Object
- #package ⇒ Object
- #release ⇒ Object
- #update_custom_cookbooks ⇒ Object
- #update_custom_json ⇒ Object
- #update_stack_cookbooks ⇒ Object
- #upload ⇒ Object
- #vendor ⇒ Object
Instance Method Details
#cleanup ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/qops/cookbook/cookbook.rb', line 106 def cleanup Dir.chdir(config.cookbook_dir) do remove_zip_files FileUtils.remove_dir('vendor') if File.directory?('vendor') say("Cleaned up directory '#{config.cookbook_dir}/vendor'", :green) end end |
#package ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/qops/cookbook/cookbook.rb', line 16 def package initialize_run move_custom_templates Dir.chdir(config.cookbook_dir) do remove_zip_files system("zip -r #{artifact_name} vendor/*") end end |
#release ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/qops/cookbook/cookbook.rb', line 74 def release vendor && package && upload && update_custom_cookbooks && update_stack_cookbooks ping_slack('Quandl::Slack::Cookbook', 'Cookbook updated', 'success', command: 'opsworks cookbook release', status: 'success', name: config.cookbook_name, version: config.cookbook_version, stack: config.stack_id) say('Released!', :green) end |
#update_custom_cookbooks ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/qops/cookbook/cookbook.rb', line 88 def update_custom_cookbooks if yes?("Are you sure you want to update the custom the custom cookbook for opsworks stack #{config.stack_id}?", :yellow) config.opsworks.update_stack( stack_id: config.stack_id, use_custom_cookbooks: true, custom_cookbooks_source: { type: 's3', url: "https://s3.amazonaws.com/#{config.cookbook_s3_bucket}/#{remote_artifact_file}" } ) say('Cookbooks updated', :green) else say('You said no, so we\'re done here.', :yellow) exit(-1) end end |
#update_custom_json ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/qops/cookbook/cookbook.rb', line 37 def update_custom_json initialize_run raw_json = File.read(File.join(config.cookbook_dir, config.cookbook_json)) json = JSON.parse(raw_json) say(JSON.pretty_generate(json), :yellow) if yes?("Are you sure you want to update the custom JSON for opsworks stack #{config.stack_id}?", :yellow) config.opsworks.update_stack( stack_id: config.stack_id, custom_json: JSON.pretty_generate(json) ) say('Updated!', :green) else say('You said no, so we\'re done here.', :yellow) end rescue JSON::ParserError say('Check your JSON for errors!', :red) end |
#update_stack_cookbooks ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/qops/cookbook/cookbook.rb', line 57 def update_stack_cookbooks initialize_run if yes?("Are you sure you want to run the 'Update Custom Cookbooks' command on stack #{config.stack_id}?", :yellow) run_opsworks_command( stack_id: config.stack_id, command: { name: 'update_custom_cookbooks' } ) say('Updated!', :green) else say('You said no, so we\'re done here.', :yellow) exit(-1) end end |
#upload ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/qops/cookbook/cookbook.rb', line 26 def upload initialize_run s3.put_object( bucket: config.cookbook_s3_bucket, acl: 'private', key: remote_artifact_file, body: IO.read(local_artifact_file) ) end |
#vendor ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/qops/cookbook/cookbook.rb', line 7 def vendor initialize_run cleanup Dir.chdir(config.cookbook_dir) do system('berks vendor vendor -e opsworks') end end |