Skip to content

Instantly share code, notes, and snippets.

@EntropyWorks
Created March 27, 2015 15:53
Show Gist options
  • Save EntropyWorks/045b19b0d2688d05adbe to your computer and use it in GitHub Desktop.
Save EntropyWorks/045b19b0d2688d05adbe to your computer and use it in GitHub Desktop.
trying to make this only run only if a file does not exisit
if File.exists?('user-data.master') && ARGV[0].eql?('up') || File.exists?('user-data.master.yml')
require 'open-uri'
token = open('https://discovery.etcd.io/new').read
file_names = ['user-data.master']
file_names.each do |file_name|
text = File.read(file_name)
new_contents = text.gsub(/AUTO_REPLACED_WITH_DISCOVERY_URL/, token )
# To merely print the contents of the file, use:
puts token
# To write changes to the file, use:
File.open(file_name + '.yaml', "w") {|file| file.puts new_contents }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment