Skip to content

Commit

Permalink
changed to use user_data for setting public dns name as its hostname.
Browse files Browse the repository at this point in the history
  • Loading branch information
everpeace committed Feb 7, 2014
1 parent 5d87663 commit 80fd3cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
22 changes: 5 additions & 17 deletions multinodes/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,34 +61,22 @@ Vagrant.configure("2") do |config|
aws.tags = {
Name: "vagrant-mesos-#{ninfo[:hostname]}"
}

if conf[:default_vpc] then
aws.elastic_ip = true
end

if master?(ninfo[:hostname]) || slave?(ninfo[:hostname]) then
aws.user_data = File.read(File.join(base_dir,"scripts","aws_set_hostname.sh"))
end

override.ssh.username = "ubuntu"
override.ssh.private_key_path = conf["ssh_private_key_path"]

override.vm.provision :shell do |s|
s.path = "scripts/populate_sshkey.sh"
s.args = "/home/ubuntu ubuntu"
end

if master?(ninfo[:hostname]) || slave?(ninfo[:hostname]) then
override.vm.provision :shell , :inline => <<SCRIPT
PUBLIC_DNS=`wget -q -O - http://169.254.169.254/latest/meta-data/public-hostname`
hostname $PUBLIC_DNS
echo $PUBLIC_DNS > /etc/hostname
HOSTNAME=$PUBLIC_DNS # Fix the bash built-in hostname variable too
SCRIPT
end

if master?(ninfo[:hostname]) then
override.vm.provision :shell , :inline => 'restart mesos-master'
end

if slave?(ninfo[:hostname]) then
override.vm.provision :shell , :inline => 'restart mesos-slave'
end
end

cfg.vm.provision :chef_solo do |chef|
Expand Down
5 changes: 5 additions & 0 deletions multinodes/scripts/aws_set_hostname.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /bin/bash
PUBLIC_DNS=`wget -q -O - http://169.254.169.254/latest/meta-data/public-hostname`
hostname $PUBLIC_DNS
echo $PUBLIC_DNS > /etc/hostname
HOSTNAME=$PUBLIC_DNS # Fix the bash built-in hostname variable too

0 comments on commit 80fd3cc

Please sign in to comment.