Last active
January 5, 2018 08:46
-
-
Save geoHeil/591dd4c22f2f965466fe082fcf18214f to your computer and use it in GitHub Desktop.
Cloudbreak vagrant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure(2) do |config| | |
# Base Box | |
config.vm.box = "centos/7" | |
# Base IP address range used for VMs. Pretty sure not to be already used on the local network. | |
$BASE_RANGE = ENV.fetch("BASE_RANGE", "10.200.0.") | |
cloudbreak_ip = $BASE_RANGE + ENV.fetch("CB_IP", "3") | |
config.vm.define "cloudbreak", primary: true do |cb| | |
# Networking | |
############# | |
cb.vm.network "private_network", ip: cloudbreak_ip | |
# Environment | |
############## | |
# Add our custom stack to the available stacks | |
#cb.vm.synced_folder "vagrant/", "/vagrant" | |
# Setup the VM system properties | |
cb.vm.provider "virtualbox" do |vb| | |
# Customize the amount of memory on the VM: | |
vb.name = ENV.fetch("CB_VM_NAME", "cloudbreak_host") | |
vb.memory = ENV.fetch("CB_MEMORY", "8192") | |
vb.cpus = ENV.fetch("CB_CPUS", "4") | |
# cap the CPU usage to 75% (3 of 4 cores) | |
vb.customize ["modifyvm", :id, "--cpuexecutioncap", ENV.fetch("CB_CPU_PERCENT", "75")] | |
end | |
# Provisioning | |
############## | |
# copy the docker repo file into yum repos. runs as shell because file provisioner doesn't have perms | |
cb.vm.provision "prepare-docker", type: "shell", inline: "sudo yum install -y yum-utils device-mapper-persistent-data lvm2" | |
cb.vm.provision "prepare-docker", type: "shell", inline: "sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo" | |
cb.vm.provision "install-docker", type: "shell" do |s| | |
s.inline = <<-SHELL | |
# setup firewalld (wrapper for iptables) to allow cross-docker communication | |
firewall-cmd --permanent --zone=trusted --change-interface=docker0 | |
firewall-cmd --permanent --zone=trusted --add-port=4243/tcp | |
firewall-cmd --reload | |
# stuff docker actually needs | |
sudo yum install -y docker-ce | |
sudo service docker start | |
sudo docker run hello-world | |
# ensure the docker daemon is always running when we start | |
sudo chkconfig docker on | |
SHELL | |
end | |
cb.vm.provision "prepare-cloudbreak", type: "shell" do |s| | |
s.inline = <<-SHELL | |
yum install -y unzip | |
yum install -y net-tools | |
yum install -y telnet | |
# personal tools | |
yum install -y vim | |
SHELL | |
end | |
cb.vm.provision "install-cloudbreak", type: "shell" do |s| | |
s.inline = <<-SHELL | |
dest=/bin | |
hash -r > /dev/null | |
if (command -v cbd > /dev/null); then | |
existing=$(command -v cbd) | |
dest=${existing%/*} | |
else | |
if echo "$PATH" | grep -q '/usr/local/bin' ; then | |
dest=/usr/local/bin | |
fi | |
fi | |
curl -Ls s3.amazonaws.com/public-repo-1.hortonworks.com/HDP/cloudbreak/cloudbreak-deployer_2.2.0_Linux_x86_64.tgz | sudo tar -xz -C /bin cbd | |
cbd --version | |
echo "---> cbd installed into ${dest}" | |
cbd --version | |
SHELL | |
end | |
cloudbreak_dir = "/vagrant/cloudbreak-deployment" | |
cb.vm.provision "init-cloudbreak", type: "shell" do |s| | |
s.inline = <<-SHELL | |
# Setup the profile | |
dir="#{cloudbreak_dir}" | |
if [ -d $dir ]; then | |
rm -rf ${dir} | |
fi | |
mkdir $dir | |
cd $dir | |
echo "export PUBLIC_IP=#{cloudbreak_ip}" > Profile | |
echo "export PRIVATE_IP=#{cloudbreak_ip}" >> Profile | |
SHELL | |
end | |
if ENV.fetch("HEADLESS", false) | |
cb.vm.provision "setup-cloudbreak", type: "shell" do |s| | |
s.inline = <<-SHELL | |
cd "#{cloudbreak_dir}" | |
cbd generate | |
cbd start | |
cbd login | |
SHELL | |
end # last provision | |
else | |
# Do the cloudbreak setup. We can get part of the way, but requires an actual login to finish | |
cb.vm.provision "setup-cloudbreak", type: "shell" do |s| | |
s.inline = <<-SHELL | |
cd "#{cloudbreak_dir}" | |
echo "You need to login and run cloubreak on an interactive shell (yes, I know):" | |
echo " vagrant ssh" | |
echo " sudo su - root" | |
echo " cd #{cloudbreak_dir}; cbd generate; cbd start; cbd login" | |
SHELL | |
end # last provision | |
end # if statement | |
end #the vm | |
end |
requires https://www.vagrantup.com to be installed
On osx via https://brew.sh simply run
brew install vagrant
Download this file above, create an empty folder and name this file Vagrantfile
and execute vagrant up
then follow the instructions on the command line to login
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
set password according to http://sequenceiq.com/cloudbreak-docs/latest/security/