Custom Search

Friday, November 27, 2015

vagrant multinode setup

1)
Ubuntu 14.04.3 LTS
#sudo -i

2)
#export no_proxy='127.0.0.1,169.254.169.254,localhost'
#export http_proxy='http://100.140.192.30:10000/'
#export https_proxy='http://100.140.192.30:10000/'


3)
#apt-get update

4)
a)

#echo "deb http://download.virtualbox.org/virtualbox/debian trusty contrib" | sudo tee -a /etc/apt/sources.list

b)
#cat /etc/apt/sources.list | grep virtualbox
deb http://download.virtualbox.org/virtualbox/debian trusty contrib


5)
#apt-get update
GPG error: http://download.virtualbox.org trusty InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 54422A4B98AB5139

6)
#apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 54422A4B98AB5139

Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.yjM7CTppoR --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver keyserver.ubuntu.com --recv-keys 54422A4B98AB5139
gpg: requesting key 98AB5139 from hkp server keyserver.ubuntu.com
gpg: key 98AB5139: public key "Oracle Corporation (VirtualBox archive signing key) " imported
gpg: Total number processed: 1
gpg:               imported: 1

7)
#apt-get update

8)
#apt-get install linux-headers-3.13.0-63-generic

9)
#apt-get install virtualbox-5.0

10)
Install vagrant
#wget --no-check-certificate https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.4_x86_64.deb
#dpkg -i vagrant_1.7.4_x86_64.deb


11)
Install librarian-puppet
#apt-get install ruby
#gem install librarian-puppet-simple --no-ri --no-rdoc


12)
#apt-get install git
#git clone https://github.com/sajuptpm/puppet-mycloud


13)
#cd puppet-mycloud

14)
Install all puppet-mycloud dependencies from file "$pwd/Puppetfile" to "$pwd/modules"
#export pwd=`pwd`
#export git_protocol=https
#librarian-puppet install --puppetfile=$pwd/Puppetfile  --path=$pwd/modules


15)
Initialize Vagrant setup
#./vagrant_parallel_provision.sh initialize

* This command will provision a dhcp server and a separate vboxnet adapter.
* This command will provision "httpproxy1" server, that contains dhcp and proxy server.
* Before running the next command , ensure puppet has completed the provision of httpproxy server.

16)
Fix for Connection timeout:

httpproxy1: SSH address: 127.0.0.1:2222
httpproxy1: SSH username: vagrant
httpproxy1: SSH auth method: private key
httpproxy1: Warning: Connection timeout. Retrying...
httpproxy1: Warning: Connection timeout. Retrying...

* Check "/etc/resolv.conf" for correct "nameserver" entry.

17)
#bash vagrant_parallel_provision.sh up >> vagrant.log 2>&1 &

* The above commands , creates a new token for consul.The token and the "vboxnet" for your cluster can be found in the "vagrant_keys".

18)
In order to recreate the  vagrant environment:
#bash vagrant_parallel_provision.sh reset >> vagrant.log 2>&1 &
This will reprovision the entire setup in a new network and a new consul token.    

19)
In order to reprovision the environment by making changes in puppet-mycloud code;
#bash vagrant_parallel_provision.sh provision >> vagrant.log 2>&1 &

20)
In order to destroy the entire system
#bash vagrant_parallel_provision.sh destroy>> vagrant.log 2>&1 &

21)
In order to destroy and bring up a single server in the cluster
#vagrant destroy gcp1
#source vangrant_keys
#vagrant up gcp1


22)
In order to get the status of vagrant servers:
#vagrant status

23)
In order to login to a specific server:
#vagrant ssh gcp1

24)
In order to cleanup the environment:
#bash vagrant_parallel_provision.sh cleanup




3 comments:

  1. Current Issues

    “If vms are spawned on gcp1 , then the vm will not be reachable from gcp node”

    Corner Case Failures (This will be moved to a script going forward). Add any other corner case you find
    before initializing, please do ifconfig | grep 192.168.100 , if you have any interface having that IP address initialization will fail (delete that interface)
    After finishing the provisioning, do the below
    cat vagrant_keys (you will get the vboxnet associated with your vagrant setup)
    ps -aux | grep DHCP | grep , if you see a vBoXDHCPCLient running with IP on that interface , then your setup would have failed
    Kill the process
    do vagrant_parallel_provision.sh provision (to reprovision your setup)

    ReplyDelete
  2. ====== Error ======
    # ./vagrant_parallel_provision.sh up
    Fetching new tokens
    export consul_discovery_token=9fc5e6d2bdaf442d9a62cdad065d3674
    (If you ran newtokens.sh with '. newtokens.sh' or 'source newtokens.sh', these have already been exported)
    There was an error loading a Vagrantfile. The file being loaded
    and the error message are shown below. This is usually caused by
    a syntax error.

    Path:
    Line number: 47
    Message: NoMethodError: undefined method `[]' for nil:NilClass
    There was an error loading a Vagrantfile. The file being loaded
    and the error message are shown below. This is usually caused by
    a syntax error.

    Path:
    Line number: 47
    Message: NoMethodError: undefined method `[]' for nil:NilClass

    ====== Fix ======

    In Vagrantfile falied to get "flavor" from puppet-rjil/environment/vagrant-vbox.map.yaml based on the "flavor" defined in the puppet-rjil/environment/full.yaml

    env_data = YAML.load_file("environment/#{layout}.yaml")
    map_data = YAML.load_file("environment/#{map}.map.yaml")

    lavor = info['flavor'] || default_flavor
    vb.memory = map_data['flavor'][flavor]['ram']

    ReplyDelete
  3. Virtualbox commands
    -------------------------------
    VBoxManage
    VBoxManage list
    VBoxManage list runningvms
    VBoxManage list hostonlyifs
    VBoxManage list natnets
    VBoxManage list dhcpservers

    VBoxManage hostonlyif create

    ReplyDelete