Thanks for your help.
Below is my vagrant file, I will have to pass the ip details for my etcd configuration. I do not want to hardcode the IP, hence using
config.vm.network "public_network",
use_dhcp_assigned_default_route: true
Could you let me know how can I get the ip details to pass to etcd configuration?
# -*- mode: ruby -*-
# vi: set ft=ruby :
# The calicoctl download URL.
# The version of the calico docker images to install. This is used to pre-load
# the calico/node and calico/node-libnetwork images which slows down the
# install process, but speeds up the tutorial.
#
# This version should match the version required by calicoctl installed from
# calicoctl_url.
calico_node_ver = "v0.22.0"
calico_libnetwork_ver = "v0.9.0"
# Size of the cluster created by Vagrant
num_instances=2
# Change basename of the VM
instance_name_prefix="calico"
Vagrant.configure(2) do |config|
# always use Vagrants insecure key
config.ssh.insert_key = true
config.ssh.username = "vagrant"
config.vm.network "public_network",
use_dhcp_assigned_default_route: true
# Use Bento Ubuntu 16.04 box (officially-recommended box by Vagrant)
config.vm.box = "bento/ubuntu-16.04"
# Workaround 16.04 issue with Virtualbox where Box waits 5 minutes to start
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
end
# Set up each box
(1..num_instances).each do |i|
vm_name = "%s-%02d" % [instance_name_prefix, i]
config.vm.define vm_name do |host|
host.vm.hostname = vm_name
config.vm.network "public_network",
use_dhcp_assigned_default_route: true
config.vm.provision "fix-no-tty", type: "shell" do |s|
s.privileged = false
s.inline = "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile"
end
# The docker provisioner installs docker.
host.vm.provision :docker, images: [
"busybox:latest",
"calico/node-libnetwork:#{calico_libnetwork_ver}",
"calico/node:#{calico_node_ver}"
]
# Calico uses etcd for calico and docker clustering. Install it on the first host only.
if i == 1
# Download etcd and start.
host.vm.provision :shell, inline: <<-SHELL
# sudo apt-get install -y unzip
tar xzvf etcd-v2.2.0-linux-amd64.tar.gz
nohup etcd-v2.2.0-linux-amd64/etcd --addr=#{primary_ip}:2379 > etcd.log &
SHELL
end
# Set Docker to use etcd for multihost, then reload systemctl and restart Docker.
host.vm.provision :shell, inline: "mkdir -p /etc/systemd/system/docker.service.d/"
host.vm.provision :shell, inline: %Q|sudo sh -c 'printf "[Service]\nExecStart=\nExecStart=/usr/bin/dockerd -H fd:// --cluster-store=etcd://#{primary_ip}:2379" > /etc/systemd/system/docker.service.d/10-execstart.conf'|
host.vm.provision :shell, inline: "systemctl daemon-reload"
host.vm.provision :shell, inline: "systemctl restart docker.service"
end
end
end
Regards,
Sunil