ansible-devops-vm/Vagrantfile

91 lines
4.5 KiB
Ruby

# This guide is optimized for Vagrant 1.8 and above.
# Older versions of Vagrant put less info in the inventory they generate.
Vagrant.require_version ">= 1.8.0"
require 'etc'
Vagrant.configure(2) do |config|
#config.vm.box = "hashicorp/bionic64"
config.vm.box = "generic/debian10"
config.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: ".git/"
# The currently only supported provider is Virtualbox
# You will have to install Virtualbox from https://www.virtualbox.org
# Manual for the following settings: https://www.virtualbox.org/manual/ch03.html
config.vm.provider :virtualbox do |vbox, override|
vbox.customize ["modifyvm", :id, "--name", "jotbe DevOps VM Ansible Playground"]
# Amount of virtual memory
vbox.customize ["modifyvm", :id, "--memory", 8192]
# Amount of virtual CPUs, by default it uses half ot the physical CPUs
vbox.customize ["modifyvm", :id, "--cpus", Etc.nprocessors/2]
# The amount of graphics memory
vbox.customize ["modifyvm", :id, "--vram", 128]
# If you want to use the 3D graphic acceleration in the VM, turn it on
vbox.customize ["modifyvm", :id, "--accelerate3d", "off"]
# Required. Allows to use more than 16 IRQs, important esp. for 64-bit guests and if more than 1 virtual CPU is used
vbox.customize ["modifyvm", :id, "--ioapic", "on"]
# Enable copy & paste between the VM and the host
vbox.customize ["modifyvm", :id, "--clipboard-mode", "bidirectional"]
# Disable serial ports (COM) if not needed
vbox.customize ["modifyvm", :id, "--uartmode1", "disconnected"]
# If your local network uses the same subnet as the default Virtualbox one (10.0.2.0/24), set a different one here
vbox.customize ["modifyvm", :id, "--natnet1", "10.0.50.0/24"]
# Attach a virtual DVD drive to be able to easily install the Virtualbox Guest Additions
vbox.customize ["storageattach", :id, "--storagectl", "IDE Controller", "--port", "1", "--device", "1", "--type", "dvddrive", "--medium", "emptydrive"]
#vbox.customize ["storagectl", :id, "--name", "SATA Controller", "--hostiocache", "on"]
# Default: The VM is hosted on an SSD.
# Set to "off" if it is hosted on an HDD to enable performance optimizations for rotational drives (e.g. defragmentation):
#vbox.customize ["storageattach", :id, "--storagectl", "SCSI", "--port", 0, "--nonrotational", "on"]
#vbox.customize ["storageattach", :id, "--storagectl", "SCSI", "--port", 1, "--nonrotational", "on"]
# Set to true, if you intent to use a GUI
vbox.gui = true
end
config.vm.define "jbdev" do |dev|
dev.vm.hostname = "jbdev.local"
# If you have installed the Vagrant::Hostsupdate plugin, you can add additional domains
# that should be mapped to the VM.
#dev.hostsupdater.aliases = ["jenkins.jbdev.local", "grafana.jbdev.local"]
# An additional IP that allows you to access the VM and its services from the VM host.
# If you change this IP, you will have to modify the `ansible_host` in the inventory file correspondingly.
# More information about the various network modes:
# https://www.virtualbox.org/manual/ch06.html#network_nat_service
dev.vm.network :private_network, ip: "192.168.6.65"
# Provision the VM from the Vagrant host.
# The host has to have Ansible installed and will connect to the VM via SSH
# dev.vm.provision :ansible do |ansible|
# #ansible.verbose = "vvv"
# ansible.compatibility_mode = "2.0"
# ansible.playbook = "provisioning/playbook.yml"
# ansible.inventory_path = "provisioning/inventory"
# ansible.become = true
# end
# Provision by running Ansible from within the VM.
# Vagrant will try to install Ansible automatically using pip
# Advantage: Ansible doesn't have to be installed on the Vagrant host
# See also: https://www.vagrantup.com/docs/provisioning/ansible_local.html
dev.vm.provision "ansible_local" do |ansible|
#ansible.verbose = "vvv"
ansible.compatibility_mode = "2.0"
ansible.install_mode = "pip"
ansible.pip_install_cmd = "sudo apt install -y python3-distutils && curl https://bootstrap.pypa.io/get-pip.py | sudo python3"
ansible.version = "2.10.8"
ansible.playbook = "provisioning/playbook.yml"
#ansible.inventory_path = "provisioning/inventory"
ansible.galaxy_role_file = "provisioning/requirements.yml"
ansible.galaxy_roles_path = "provisioning/roles"
ansible.become = true
ansible.extra_vars = {
virtualbox_host_version: "6.1.18"
}
end
end
end