Project for running Ansible, inside a newly created virtual machine.
For the UNIX example, see here
For the Windows example, see here
To install Vagrant, run:
apt-get update
apt-get install vagrant
Additionally a hypervisor must be installed, the default is VirtualBox:
apt-get update
apt-get install virtualbox
Other hypervisors can be installed instead, refer to the FAQ for this.
Vagrant can be installed using the Homebrew CLI.
Only the Virtualbox hypervisor is supported on MacOS.
To install Vagrant and Virtualbox, add the 'cask' tap to homebrew and run:
brew tap caskroom/cask
brew install caskroom/cask/virtualbox
brew install caskroom/cask/vagrant
To install Vagrant;
- Download the msi file from here
- Install it using the default Windows method of clicking 'Next' and accepting everything blindly.
- Reboot
As Vagrant cannot run under the Windows Terminal, we need Cygwin;
- Download the exe file for Cygwin from here
- Install it using the default Windows method of clicking 'Next' and accepting everything blindly.
- Reboot?
Additionally a hypervisor must be installed, on Windows we use VirtualBox;
- Download the exe file from here
- Install it using the default Windows method of clicking 'Next' and accepting everything blindly.
- Reboot
No other hypervisors are supported.
Not supported, please figure out a solution yourself, and add it via. a pull request.
Simply run vagrant up
, and wait for the machine to be available.
After this, the machine can be accessed over ssh, using:
vagrant ssh
If you wish to rerun the provisioning (Shell/Ansible), it can be done using:
vagrant provision
By default, no port forwards are made, however the default portforward;
8000 --> 8000
Can be made, by enabling this when calling the vagrant up
command.
This can be with the FORWARD_PORT
environmental variable.
The variable does not hold anything meaningful at this time;
FORWARD_PORT=1 vagrant up
When utilizing the VirtualBox provider, a tiny amount of diskspace is provided. Namely about 8GB, this is to keep disk usage to a minimum, when it is not required. For cases where this does not suffice, it is possible to get a larger machine, by installing the following two plugins:
vagrant plugin install vagrant-reload
vagrant plugin install vagrant-disksize
And calling the vagrant up
command, with the MIGRATE_DISK
environmental
variable. The variable holds the new size of the disk, in gigabytes;
MIGRATE_DISK=50 vagrant up
Migrating disks should not be necessary on LXC as it utilizes all available disk on the host.
By default the default.yml
playbook is run, but any playbook can be run, by
changing the PLAYBOOK
environmental variable before running vagrant provision
,
as done by:
PLAYBOOK=demo.yml vagrant provision
At the moment provisioning is done using Ansible inside the guest container. This is to simply the setup process for users, but does incur a tiny overhead.
It is however supported to provision the container using the hosts Ansible installation,
to do this, simply set the PROVISIONER
environmental variable before running
vagrant provision
, as done by:
PROVISIONER=ansible vagrant provision
This does however require Ansible to be installed on the host machine. See below for how to install Ansible on your system.
To install Ansible, run:
apt-get update
apt-get install ansible
Ansible can be installed using the Homebrew CLI.
To install Ansible, run:
brew install ansible
Windows is not officially supported for the control machine.
It is however possible to get Ansible running anyway. See here and here
Could be related to using VirtualBox. When using Vagrant with VirtualBox, you'll be prompted to choose a bridged network interface. Select the interface that is being used to connect to the internet.
Also, try to forward ports in your Vagrantfile
by adding this line:
config.vm.network "forwarded_port", guest: 8000, host: 8000
Fortunately several other providers can be utilized, specifically:
lxc
libvirt
Some provider specific setup is required however. The approach below is confirmed to work on Ubuntu 16.04 (Xenial).
Install the system dependencies, using:
apt-get update
apt-get install lxc lxc-templates cgroup-lite redir
Install the vagrant lxc plugin, using:
vagrant plugin install vagrant-lxc
The expected output is:
Installing the 'vagrant-lxc' plugin. This can take a few minutes...
Installed the plugin 'vagrant-lxc (1.2.3)'!
If the expected result is different, please check the Quirks section below.
Install the system dependencies, using:
apt-get update
apt-get build-dep vagrant ruby-libvirt
apt-get install qemu libvirt-bin ebtables dnsmasq
apt-get install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev
Install the vagrant lxc plugin, using:
vagrant plugin install vagrant-libvirt
The expected output is:
Installing the 'vagrant-libvirt' plugin. This can take a few minutes...
Installed the plugin 'vagrant-libvirt (0.0.40)'!
If the expected result is different, please check the Quirks section below.
It is a known issue, that installing the libvirt or LXC proviers, can result in an issue, alike the one below:
Installing the 'vagrant-lxc' plugin. This can take a few minutes...
/usr/lib/ruby/2.3.0/rubygems/specification.rb:946:in `all=':
undefined method `group_by' for nil:NilClass (NoMethodError)
...
The solution to this issue, is running code of the internet:
sed -i'' "s/Specification.all = nil/Specification.reset/" \
/usr/lib/ruby/vendor_ruby/vagrant/bundler.rb