Class: Commands::ChefUpload
- Inherits:
-
Object
- Object
- Commands::ChefUpload
- Defined in:
- lib/commands/chef_upload.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#options ⇒ Object
holds the options that were passed you can set any initial defaults here.
- #register(opts, global_options) ⇒ Object
-
#required_options ⇒ Object
required options.
- #run(global_options, amazon) ⇒ Object
Class Method Details
.get_upload_command(recipes_deploy_tag) ⇒ Object
58 59 60 |
# File 'lib/commands/chef_upload.rb', line 58 def self.get_upload_command(recipes_deploy_tag) "cd #{::ZZDeploy::RECIPES_DIR} && git fetch && git checkout -f #{recipes_deploy_tag} && bundle install --path #{::ZZDeploy::RECIPES_BUNDLE_DIR} --deployment" end |
Instance Method Details
#options ⇒ Object
holds the options that were passed you can set any initial defaults here
6 7 8 9 |
# File 'lib/commands/chef_upload.rb', line 6 def @options ||= { } end |
#register(opts, global_options) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/commands/chef_upload.rb', line 19 def register(opts, ) opts. = "Usage: chef_upload [options]" opts.description = "Upload the chef scripts" opts.on('-g', "--group name", "Required - Name of this deploy group.") do |v| [:group] = v end opts.on('-t', "--tag tag", "Required - Git tag to use for pulling chef code.") do |v| [:tag] = v end end |
#required_options ⇒ Object
required options
12 13 14 15 16 17 |
# File 'lib/commands/chef_upload.rb', line 12 def @required_options ||= Set.new [ :group, :tag, ] end |
#run(global_options, amazon) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/commands/chef_upload.rb', line 33 def run(, amazon) ec2 = amazon.ec2 group_name = [:group] recipes_deploy_tag = [:tag] # first see group exists deploy_group = amazon.find_deploy_group(group_name) # verify that the tag given is on the remote repo cmd = "git ls-remote --tags [email protected]:zangzing/zz-chef-repo.git refs/tags/#{recipes_deploy_tag}^{} refs/tags/#{recipes_deploy_tag} | egrep refs/tags/#{recipes_deploy_tag}" if ZZSharedLib::CL.do_cmd_result(cmd) != 0 raise "Could not find the tag specified in the remote zz-chef-repo repository. Make sure you check in and tag your code." end # tag is good, go ahead and upload to simple db deploy_group.recipes_deploy_tag = recipes_deploy_tag deploy_group.save deploy_group.reload # save corrupts the in memory state so must reload, kinda lame remote_cmd = ChefUpload.get_upload_command(recipes_deploy_tag) multi = MultiSSH.new(amazon, group_name, deploy_group) multi.run(remote_cmd) end |