Created
February 19, 2015 14:16
-
-
Save popsikle/bd8df3359c186be03fe4 to your computer and use it in GitHub Desktop.
CoreOS vagrant - config.rb snippet to regen token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# init a cluster, if needed | |
if File.exists?('user-data') | |
require 'open-uri' | |
require 'yaml' | |
data = YAML.load(IO.readlines('user-data')[1..-1].join) | |
if data['coreos']['etcd']['discovery'].nil? and ARGV[0].eql?('up') | |
token = open('https://discovery.etcd.io/new?size=3').read | |
data['coreos']['etcd']['discovery'] = token | |
yaml = YAML.dump(data) | |
File.open('user-data', 'w') { |file| file.write("#cloud-config\n\n#{yaml}") } | |
elsif not data['coreos']['etcd']['discovery'].nil? and ARGV[0].eql?('destroy') | |
data['coreos']['etcd']['discovery'] = nil | |
yaml = YAML.dump(data) | |
File.open('user-data', 'w') { |file| file.write("#cloud-config\n\n#{yaml}") } | |
end | |
end | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment