This repository was archived by the owner on Sep 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 645
/
Copy pathconfig.rb.sample
153 lines (125 loc) · 5.59 KB
/
config.rb.sample
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# Size of the CoreOS cluster created by Vagrant
$num_instances=1
# Change basename of the VM
# The default value is "core", which results in VMs named starting with
# "core-01" through to "core-${num_instances}".
#$instance_name_prefix="core"
# Enables the use of the etcd discovery service. The default is enabled.
# When disabled the cluster will be statically defined with each instance
# as a member.
#$enable_discovery_service=true
# 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}"
if File.exists?('user-data') && ARGV[0].eql?('up')
require 'open-uri'
require 'yaml'
data = YAML.load(IO.readlines('user-data')[1..-1].join)
# Automatically replace the discovery token on 'vagrant up'
if $enable_discovery_service
token = open($new_discovery_url).read
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
else
# Static cluster configuration explicitly configures the initial cluster members
# etcd v1 uses peers list
peers = (1..$num_instances).map{|i|
ip = "172.17.8.#{i+100}"
"%s:7001" % ip
}.join(",")
if data.key? 'coreos' and data['coreos'].key? 'etcd'
data['coreos']['etcd']['peers'] = peers
end
# etcd2 uses initial cluster key-value list
initial_cluster = (1..$num_instances).map{|i|
ip = "172.17.8.#{i+100}"
"%s-%02d=http://%s:2380" % [$instance_name_prefix, i, ip]
}.join(",")
if data.key? 'coreos' and data['coreos'].key? 'etcd2'
data['coreos']['etcd2']['initial-cluster'] = initial_cluster
end
# Remove discovery token if it exists
if data.key? 'coreos' and data['coreos'].key? 'etcd' and data['coreos']['etcd'].key? 'discovery'
data['coreos']['etcd'].delete 'discovery'
end
if data.key? 'coreos' and data['coreos'].key? 'etcd2' and data['coreos']['etcd2'].key? 'discovery'
data['coreos']['etcd2'].delete 'discovery'
end
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
if $enable_discovery_service
yaml = YAML.dump(data)
File.open('user-data', 'w') { |file| file.write("#cloud-config\n\n#{yaml}") }
else
# When static configuration is used a name must be specified.
# This requires a unique user-data file for each node. The user-data files
# will have the node instance id appended. (ex. user-data-01)
(1..$num_instances).each do |i|
if data.key? 'coreos' and data['coreos'].key? 'etcd'
data['coreos']['etcd']['name'] = "%s-%02d" % [$instance_name_prefix, i]
end
if data.key? 'coreos' and data['coreos'].key? 'etcd2'
data['coreos']['etcd2']['name'] = "%s-%02d" % [$instance_name_prefix, i]
end
# etcd v1 requires that a single node to not have a peer list.
# Choosing last instance to be initial leader.
if (i == $num_instances)
if data.key? 'coreos' and data['coreos'].key? 'etcd' and data['coreos']['etcd'].key? 'peers'
data['coreos']['etcd'].delete 'peers'
end
end
yaml = YAML.dump(data)
File.open("user-data-%02d" % i, 'w') { |file| file.write("#cloud-config\n\n#{yaml}") }
end
end
end
#
# coreos-vagrant is configured through a series of configuration
# options (global ruby variables) which are detailed below. To modify
# these options, first copy this file to "config.rb". Then simply
# uncomment the necessary lines, leaving the $, and replace everything
# after the equals sign..
# Change the version of CoreOS to be installed
# 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
#$image_version = "current"
# Official CoreOS channel from which updates should be downloaded
#$update_channel='alpha'
# Log the serial consoles of CoreOS VMs to log/
# Enable by setting value to true, disable with false
# WARNING: Serial logging is known to result in extremely high CPU usage with
# VirtualBox, so should only be used in debugging situations
#$enable_serial_logging=false
# Enable port forwarding of Docker TCP socket
# Set to the TCP port you want exposed on the *host* machine, default is 2375
# If 2375 is used, Vagrant will auto-increment (e.g. in the case of $num_instances > 1)
# You can then use the docker tool locally by setting the following env var:
# export DOCKER_HOST='tcp://127.0.0.1:2375'
#$expose_docker_tcp=2375
# Enable NFS sharing of your home directory ($HOME) to CoreOS
# It will be mounted at the same path in the VM as on the host.
# Example: /Users/foobar -> /Users/foobar
#$share_home=false
# Customize VMs
#$vm_gui = false
#$vm_memory = 1024
#$vm_cpus = 1
#$vb_cpuexecutioncap = 100
# Share additional folders to the CoreOS VMs
# For example,
# $shared_folders = {'/path/on/host' => '/path/on/guest', '/home/foo/app' => '/app'}
# or, to map host folders to guest folders of the same name,
# $shared_folders = Hash[*['/home/foo/app1', '/home/foo/app2'].map{|d| [d, d]}.flatten]
#$shared_folders = {}
# Enable port forwarding from guest(s) to host machine, syntax is: { 80 => 8080 }, auto correction is enabled by default.
#$forwarded_ports = {}