Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

Commit

Permalink
Updated vagrant demo
Browse files Browse the repository at this point in the history
  • Loading branch information
kayrus committed Sep 21, 2015
1 parent 841844d commit f097358
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 42 deletions.
60 changes: 29 additions & 31 deletions config.rb.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,34 @@ $num_instances=1
# Used to fetch a new discovery token for a cluster of size $num_instances
$new_discovery_url="https://discovery.etcd.io/new?size=#{$num_instances}"

# To automatically replace the discovery token on 'vagrant up', uncomment
# the lines below:
#
#if File.exists?('user-data') && ARGV[0].eql?('up')
# require 'open-uri'
# require 'yaml'
#
# token = open($new_discovery_url).read
#
# data = YAML.load(IO.readlines('user-data')[1..-1].join)
# if data['coreos'].key? 'etcd'
# data['coreos']['etcd']['discovery'] = token
# end
# if data['coreos'].key? 'etcd2'
# data['coreos']['etcd2']['discovery'] = token
# end
#
# # Fix for YAML.load() converting reboot-strategy from 'off' to `false`
# if data['coreos'].key? 'update'
# if data['coreos']['update'].key? 'reboot-strategy'
# if data['coreos']['update']['reboot-strategy'] == false
# data['coreos']['update']['reboot-strategy'] = 'off'
# end
# end
# end
#
# yaml = YAML.dump(data)
# File.open('user-data', 'w') { |file| file.write("#cloud-config\n\n#{yaml}") }
#end
#
# Automatically replace the discovery token on 'vagrant up'

if File.exists?('user-data') && ARGV[0].eql?('up')
require 'open-uri'
require 'yaml'

token = open($new_discovery_url).read

data = YAML.load(IO.readlines('user-data')[1..-1].join)

if data.key? 'coreos' and data['coreos'].key? 'etcd'
data['coreos']['etcd']['discovery'] = token
end

if data.key? 'coreos' and data['coreos'].key? 'etcd2'
data['coreos']['etcd2']['discovery'] = token
end

# Fix for YAML.load() converting reboot-strategy from 'off' to `false`
if data.key? 'coreos' and data['coreos'].key? 'update' and data['coreos']['update'].key? 'reboot-strategy'
if data['coreos']['update']['reboot-strategy'] == false
data['coreos']['update']['reboot-strategy'] = 'off'
end
end

yaml = YAML.dump(data)
File.open('user-data', 'w') { |file| file.write("#cloud-config\n\n#{yaml}") }
end

#
# coreos-vagrant is configured through a series of configuration
Expand All @@ -48,7 +46,7 @@ $new_discovery_url="https://discovery.etcd.io/new?size=#{$num_instances}"
#$instance_name_prefix="core"

# Change the version of CoreOS to be installed
# To deploy a specific version, simply set $image_version accordingly.
# To deploy a specific version, simply set $image_version accordingly.
# For example, to deploy version 709.0.0, set $image_version="709.0.0".
# The default value is "current", which points to the current version
# of the selected channel
Expand Down
19 changes: 8 additions & 11 deletions user-data.sample
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#cloud-config

coreos:
etcd:
# generate a new token for each unique cluster from https://discovery.etcd.io/new
# WARNING: replace each time you 'vagrant destroy'
#discovery: https://discovery.etcd.io/<token>
addr: $public_ipv4:4001
peer-addr: $public_ipv4:7001
etcd2:
#generate a new token for each unique cluster from https://discovery.etcd.io/new
#discovery: https://discovery.etcd.io/<token>
Expand All @@ -22,14 +16,17 @@ coreos:
flannel:
interface: $public_ipv4
units:
- name: etcd.service
- name: etcd2.service
command: start
# To use etcd2, comment out the above service and uncomment these
# Note: this requires a release that contains etcd2
#- name: etcd2.service
# command: start
- name: fleet.service
command: start
- name: flanneld.service
drop-ins:
- name: 50-network-config.conf
content: |
[Service]
ExecStartPre=/usr/bin/etcdctl set /coreos.com/network/config '{ "Network": "10.1.0.0/16" }'
command: start
- name: docker-tcp.socket
command: start
enable: true
Expand Down

0 comments on commit f097358

Please sign in to comment.