# -*- mode: ruby -*- # vi: set ft=ruby : BOX_NAME = 'projectatomic/adb' IP_ADDRESS="10.2.2.2" REQUIRED_PLUGINS = %w(vagrant-service-manager vagrant-sshfs) errors = [] def message(name) "#{name} plugin is not installed, run `vagrant plugin install #{name}` to install it." end # Validate and collect error message if plugin is not installed REQUIRED_PLUGINS.each { |plugin| errors << message(plugin) unless Vagrant.has_plugin?(plugin) } unless errors.empty? msg = errors.size > 1 ? "Errors: \n* #{errors.join("\n* ")}" : "Error: #{errors.first}" fail Vagrant::Errors::VagrantError.new, msg end Vagrant.configure("2") do |config| # Use environment variable BOX or default 'projectatomic/adb' config.vm.box = (ENV.key?('BOX') ? (ENV['BOX'].empty? ? BOX_NAME : ENV['BOX']) : BOX_NAME) config.vm.provider "virtualbox" do |v, override| v.memory = 2048 v.cpus = 2 end config.vm.provider "libvirt" do |v, override| v.driver = "kvm" v.memory = 2048 v.cpus = 2 v.suspend_mode = "managedsave" end config.vm.provider "openstack" do |os| # Specify OpenStack authentication information os.openstack_auth_url = ENV['OS_AUTH_URL'] os.tenant_name = ENV['OS_TENANT_NAME'] os.username = ENV['OS_USERNAME'] os.password = ENV['OS_PASSWORD'] # Specify instance information os.server_name = ENV['OS_INSTANCE'] os.flavor = ENV['OS_FLAVOR'] os.image = ENV['OS_IMAGE'] os.floating_ip_pool = ENV['OS_FLOATING_IP_POOL'] os.security_groups = ['default', ENV['OS_SECURITY_GROUP']] os.keypair_name = ENV['OS_KEYPAIR_NAME'] config.ssh.private_key_path = ENV['OS_PRIVATE_KEYPATH'] config.ssh.username = 'vagrant' end config.vm.synced_folder '.', '/vagrant', disabled: true if Vagrant::Util::Platform.windows? target_path = ENV['USERPROFILE'].gsub(/\\/,'/').gsub(/[[:alpha:]]{1}:/){|s|'/' + s.downcase.sub(':', '')} config.vm.synced_folder ENV['USERPROFILE'], target_path, type: 'sshfs', sshfs_opts_append: '-o umask=000 -o uid=1000 -o gid=1000' else config.vm.synced_folder ENV['HOME'], ENV['HOME'], type: 'sshfs', sshfs_opts_append: '-o umask=000 -o uid=1000 -o gid=1000' end config.vm.provision "shell", inline: <<-SHELL sudo setsebool -P virt_sandbox_use_fusefs 1 SHELL ANSIBLE_PLAYBOOK = <<-EOF - hosts: localhost sudo: yes connection: local tasks: # Packages start services, this is why we need to configure it before install - name: Create dir for Mesos Slave config file: path=/etc/{{ item }} state=directory with_items: - marathon/conf - mesos-slave - name: Configure IP address for mesos-slave copy: content: '{{ ip_address }}' dest: /etc/mesos-slave/ip - name: Configure Port Ranges for mesos-slave copy: content: 'ports:[1024-32000]' dest: /etc/mesos-slave/resources - name: Increase timeout to account for docker pull delay copy: content: '5mins' dest: /etc/mesos-slave/executor_registration_timeout - name: Add docker containerizer copy: content: 'docker,mesos' dest: /etc/mesos-slave/containerizers - name: Configure IP address for Marathon copy: content: '{{ ip_address }}' dest: /etc/marathon/conf/hostname - name: Install Mesosphere repository yum: name=http://repos.mesosphere.com/el/7/noarch/RPMS/mesosphere-el-repo-7-3.noarch.rpm state=present - name: Installing zookeeper, mesos, marathon, docker, git, atomicapp yum: name={{item}} state=present with_items: - mesosphere-zookeeper - mesos - marathon - docker - git - atomicapp - name: Starting zookeeper, mesos, marathon, docker service: name={{item}} state=started enabled=yes with_items: - zookeeper - mesos-master - mesos-slave - marathon - docker EOF config.vm.provision "shell", run: "always", inline: <<-SHELL sudo yum -y install epel-release sudo yum -y install ansible sudo ansible-playbook -i localhost, -e ip_address=#{IP_ADDRESS} /dev/stdin <<< "#{ANSIBLE_PLAYBOOK}" SHELL config.vm.network "private_network", ip: "#{IP_ADDRESS}" end