This repository has been archived by the owner on Nov 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from Icinga/feature/vagrantfile-refactor
Refactor Vagrantfile, use centos/7 box for VirtualBox, require vbguest plugin Many thanks to @lbetz & @lazyfrosch for the inspirations! fixes #17 fixes #53
- Loading branch information
Showing
34 changed files
with
977 additions
and
998 deletions.
There are no files selected for viewing
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
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
VAGRANTFILE_API_VERSION = "2" | ||
VAGRANT_REQUIRED_VERSION = "1.6.5" | ||
VAGRANT_REQUIRED_LINKED_CLONE_VERSION = "1.8.4" | ||
|
||
# Require 1.6.5 at least | ||
if ! defined? Vagrant.require_version | ||
if Gem::Version.new(Vagrant::VERSION) < Gem::Version.new(VAGRANT_REQUIRED_VERSION) | ||
puts "Vagrant >= " + VAGRANT_REQUIRED_VERSION + " required. Your version is " + Vagrant::VERSION | ||
exit 1 | ||
end | ||
else | ||
Vagrant.require_version ">= " + VAGRANT_REQUIRED_VERSION | ||
end | ||
|
||
# inspired by https://github.com/lbetz/vagrant-icinga-book/blob/master/Vagrantfile | ||
nodes = { 'icinga2-freebsd' => { | ||
:box => 'freebsd/FreeBSD-11.0-STABLE', | ||
:mac => '080027D14C66', | ||
:net => 'icinga2-freebsd.demo.local', | ||
:hostonly => '192.168.33.9', | ||
:memory => '2048', | ||
:cpu => '2', | ||
:fowarded => { | ||
'443' => '8443', | ||
'80' => '8082', | ||
'22' => '2082' | ||
} | ||
} | ||
} | ||
|
||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | ||
nodes.each_pair do |name, options| | ||
config.vm.define name do |node_config| | ||
node_config.vm.box = options[:box] | ||
node_config.vm.hostname = name | ||
node_config.vm.box_url = options[:url] if options[:url] | ||
if options[:forwarded] | ||
options[:forwarded].each_pair do |guest, local| | ||
node_config.vm.network "forwarded_port", guest: guest, host: local | ||
end | ||
end | ||
|
||
#node_config.vm.network :private_network, ip: options[:hostonly] if options[:hostonly] | ||
|
||
# FreeBSD specific modifications | ||
node_config.vm.base_mac = "080027D14C66" | ||
node_config.vm.guest = :freebsd | ||
node_config.vm.synced_folder ".", "/vagrant", disabled: true | ||
node_config.ssh.shell = "bash" | ||
|
||
# provider: parallels | ||
#node_config.vm.provider :parallels do |p, override| | ||
# override.vm.box = "parallels/centos-7.2" | ||
# override.vm.boot_timeout = 600 | ||
|
||
# p.name = "Icinga 2: #{name.to_s}" | ||
# p.update_guest_tools = false | ||
# p.linked_clone = true if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new(VAGRANT_REQUIRED_LINKED_CLONE_VERSION) | ||
|
||
# # Set power consumption mode to "Better Performance" | ||
# p.customize ["set", :id, "--longer-battery-life", "off"] | ||
|
||
# p.memory = options[:memory] if options[:memory] | ||
# p.cpus = options[:cpus] if options[:cpus] | ||
#end | ||
|
||
# provider: virtualbox | ||
node_config.vm.provider :virtualbox do |vb, override| | ||
#unless Vagrant.has_plugin?("vagrant-vbguest") | ||
# raise 'vagrant-vbguest is not installed! Run "vagrant plugin install vagrant-vbguest"' | ||
#end | ||
#node_config.vbguest.auto_update = true | ||
#vb.linked_clone = true if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new(VAGRANT_REQUIRED_LINKED_CLONE_VERSION) | ||
vb.name = name | ||
vb.gui = options[:gui] if options[:gui] | ||
|
||
# FreeBSD specific modifications | ||
vb.customize ["modifyvm", :id, | ||
"--groups", "/Icinga Vagrant/" + options[:net], | ||
"--memory", "2048", | ||
"--cpus", "2", | ||
"--natdnshostresolver1", "on", | ||
"--hwvirtex", "on", | ||
"--nictype1", "virtio", | ||
"--nictype2", "virtio", | ||
#"--audio", "none", | ||
#"--usb", "on", | ||
#"--usbehci", "off", | ||
#"--nic2", "intnet", | ||
#"--intnet2", options[:net], | ||
#"--macaddress2". options[:mac] | ||
] | ||
#vb.memory = options[:memory] if options[:memory] | ||
#vb.cpus = options[:cpus] if options[:cpus] | ||
end | ||
|
||
# provider: libvirt | ||
#node_config.vm.provider :libvirt do |lv, override| | ||
# lv.memory = options[:memory] if options[:memory] | ||
# lv.cpus = options[:cpus] if options[:cpus] | ||
#end | ||
|
||
# provisioner: ensure that hostonly network is up | ||
# | ||
# workaround for Vagrant >1.8.4-1.9.1 not bringing up eth1 properly | ||
# https://github.com/mitchellh/vagrant/issues/8096 | ||
#node_config.vm.provision "shell", inline: "service network restart", run: "always" | ||
|
||
# provisioner: install requirements | ||
#node_config.vm.provision :shell, :path => "../scripts/shell_provisioner.sh" | ||
|
||
# provisioner: install box using puppet manifest | ||
#node_config.vm.provision :puppet do |puppet| | ||
# puppet.module_path = "../modules" | ||
# puppet.manifests_path = "manifests" | ||
# puppet.hiera_config_path = "hiera.yaml" | ||
# #puppet.options = "--verbose --debug --parser=future" | ||
# puppet.options = "--parser=future" | ||
#end | ||
|
||
# print a friendly message | ||
#node_config.vm.provision "shell", inline: <<-SHELL | ||
# echo "Finished installing the Vagrant box '#{name}'." | ||
# echo "Navigate to http://#{options[:hostonly]}" | ||
#SHELL | ||
# FreeBSD specific modifications | ||
node_config.vm.provision "shell", inline: <<-SHELL | ||
env ASSUME_ALWAYS_YES=YES pkg install icinga2 wget curl gdb vim python | ||
sysrc icinga2_enable=yes | ||
icinga2 api setup | ||
echo 'object ApiUser "root" {' >/usr/local/etc/icinga2/conf.d/api-users.conf | ||
echo ' password = "icinga"' >>/usr/local/etc/icinga2/conf.d/api-users.conf | ||
echo ' permissions = [ "*" ]' >>/usr/local/etc/icinga2/conf.d/api-users.conf | ||
echo '}' >>/usr/local/etc/icinga2/conf.d/api-users.conf | ||
service icinga2 restart | ||
echo "Finished installing the Vagrant box '#{name}'." | ||
SHELL | ||
end | ||
end | ||
end | ||
|
Oops, something went wrong.