lib/stack.rb in stack-kicker-0.0.15 vs lib/stack.rb in stack-kicker-0.0.16

- old
+ new

@@ -199,11 +199,11 @@ keypairs = os.keypairs() if (keypairs[config[:key_pair]].nil? && keypairs[config[:key_pair].to_sym].nil?) Logger.warn "#{config[:key_pair]} isn't available, uploading the key" # upload the key - key = os.create_keypair({:name=> config[:key_pair], :public_key=> File.read(config[:key_public])}) + key = os.create_keypair({:name=> config[:key_pair], :public_key=> File.read(File.expand_path(config[:key_public]))}) Logger.warn "#{config[:key_pair]} fingerprint=#{key[:fingerprint]}" else Logger.info "#{config[:key_pair]} fingerprint=#{keypairs[config[:key_pair].to_sym][:fingerprint]}" end @@ -213,11 +213,11 @@ security_groups = os.security_groups() # extract the names sg_names = security_groups.map { |secgroup, secgroup_details| secgroup_details[:name] } config[:roles].each do |role, role_details| - # is does the secgroup exist? + # does the secgroup exist? if sg_names.include?(role_details[:security_group]) Logger.info "security group #{role_details[:security_group]} exists in #{az}" else Logger.error "security group #{role_details[:security_group]} is missing in #{az}" end @@ -573,10 +573,12 @@ instance.delete! end end def Stack.delete_all(config) + # check that we have OS_* vars loaded etc + Stack.syntax_check(config) # this also populates out unspecified defaults, like az Stack.populate_config(config) # get the list of nodes we consider 'ours', i.e. with hostnames that match # those generated by this stack @@ -646,15 +648,19 @@ #sg_json = Tempfile.new(['secgroup_ips', '.json']) sg_json = File.new('secgroup_ips.json', "w") sg_json.write(secgroup_ips.to_json) sg_json.close - if File.exists?('secgroups.json') + # should we skip deletes + skip_deletes = config['skip-secgroup-sync-deletes'] ? "--skip-deletes" : "" + + secgroups_json_abs = Stack.find_file(config, "secgroups.json") + if File.exists?(secgroups_json_abs) Logger.info "Found secgroups.json, syncing secgroups across AZ" # run the secgroup-sync tool, across each AZ/REGION config[:azs].each do |az| Logger.info "Syncing security groups in #{az}" - system("stackhelper --os-region-name #{az} secgroup-sync --secgroup-json secgroups.json --additional-group-json #{sg_json.path}") + system("stackhelper --os-region-name #{az} secgroup-sync #{skip_deletes} --secgroup-json #{secgroups_json_abs} --additional-group-json #{sg_json.path}") end else Logger.info "No secgroups.json found, skipping secgroup sync" end end