Created
January 9, 2019 20:03
-
-
Save blakelead/ef5245f249277ac495c3629dea1e15b3 to your computer and use it in GitHub Desktop.
Centos7 Vagrantfile with disk creation
This file contains 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 : | |
boxes = [ | |
{ | |
:name => "node01.local", | |
:eth => "192.168.10.10", | |
:mem => "2048", | |
:cpu => "2" | |
}, | |
{ | |
:name => "node02.local", | |
:eth => "192.168.10.11", | |
:mem => "2048", | |
:cpu => "2" | |
}, | |
{ | |
:name => "node03.local", | |
:eth => "192.168.10.12", | |
:mem => "2048", | |
:cpu => "2" | |
} | |
] | |
Vagrant.configure("2") do |config| | |
config.vm.box = "centos/7" | |
boxes.each_with_index do |opts,index| | |
config.vm.define opts[:name] do |config| | |
config.vm.hostname = opts[:name] | |
config.ssh.private_key_path = ["default_key", "~/.vagrant.d/insecure_private_key"] | |
config.vm.provision "file", source: "default_key.pub", destination: "~/.ssh/authorized_keys" | |
config.ssh.insert_key = false | |
config.vm.network "private_network", ip: opts[:eth] | |
config.vm.provider "virtualbox" do |vb| | |
vb.name = opts[:name] | |
vb.memory = opts[:mem] | |
vb.cpus = opts[:cpu] | |
# Create a secondary disk | |
disk_file = ".vagrant/machines/#{vb.name}/disk.vdi" | |
vb.customize ['createhd', '--filename', disk_file, '--size', 10 * 1024] unless File.exist?(disk_file) | |
vb.customize ['storageattach', :id, '--storagectl', 'IDE', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', disk_file] | |
end | |
# Disable SELINUX | |
config.vm.provision "shell", inline: <<-SHELL | |
sudo setenforce 0 | |
sudo sed -i 's/SELINUX=\(enforcing\|permissive\)/SELINUX=disabled/g' /etc/selinux/config | |
SHELL | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment