From c8cd47ff6dd3037df01f40e99d3cfe71026615ec Mon Sep 17 00:00:00 2001 From: Artur Roszczyk Date: Sat, 3 Aug 2013 22:53:31 +0200 Subject: [PATCH] Make slaves connecting to first node --- plugins/guests/coreos/cap/configure_networks.rb | 14 ++++++++++---- templates/guests/coreos/etcd.service.erb | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/guests/coreos/cap/configure_networks.rb b/plugins/guests/coreos/cap/configure_networks.rb index 12cb81d28..6166105cf 100644 --- a/plugins/guests/coreos/cap/configure_networks.rb +++ b/plugins/guests/coreos/cap/configure_networks.rb @@ -38,11 +38,17 @@ module VagrantPlugins end primary_machine_ip = get_ip.(primary_machine) - if get_ip.(machine) == primary_machine_ip - entry = TemplateRenderer.render("guests/coreos/etcd.service") + current_ip = get_ip.(machine) + if current_ip == primary_machine_ip + entry = TemplateRenderer.render("guests/coreos/etcd.service", :options => { + :my_ip => current_ip + }) else - entry = TemplateRenderer.render("guests/coreos/etcd.service", - :options => {:connect_to => primary_machine_ip}) + connection_string = "#{primary_machine_ip}:7001" + entry = TemplateRenderer.render("guests/coreos/etcd.service", :options => { + :connection_string => connection_string, + :my_ip => current_ip + }) end puts entry diff --git a/templates/guests/coreos/etcd.service.erb b/templates/guests/coreos/etcd.service.erb index 4eb35aa78..65d7870ea 100644 --- a/templates/guests/coreos/etcd.service.erb +++ b/templates/guests/coreos/etcd.service.erb @@ -4,7 +4,7 @@ Description=Clustered etcd [Service] Restart=always -ExecStart=/usr/bin/etcd -c 4001 -s 7001 <% if options[:connect_to] %>-C <%= options[:connect_to] %>:7001<% end %> -d /home/core/etcd +ExecStart=/usr/bin/etcd -c 4001 -s 7001 -h <%= options[:my_ip] %> <% if options[:connection_string] %>-C <%= options[:connection_string] %><% end %> -d /home/core/etcd [Install] WantedBy=local.target