To make the tutorial self-contained, a Vagrant file is provided. Vagrant makes it easy to bootstrap barebones virtual machines with VirtualBox.
In order to run Vagrant, you need:
- VirtualBox installed
- Ruby installed (should be on your system already)
- Vagrant 1.1+ installed (see https://docs.vagrantup.com/v2/installation/index.html).
This should be all it takes to set up Vagrant.
Now bootstrap your virtual machines with the following command. Note that you
do not need to download any "box" manually. This tutorial already includes a
Vagrantfile
to get you up and running, and will get one for you if needed.
vagrant up
and go grab yourself a coffee (note that if you use vagrant-hostmaster, you'll need to type your password since it needs to sudo as root).
If something goes wrong, refer to Vagrant's Getting Started Guide.
On some systems, NetworkManager will take over vboxnet
interfaces and mess
everything up. If you're in this case, you should prevent NetworkManager from
trying to autoconfigure vboxnet
interfaces. Just edit
/etc/NetworkManager/NetworkManager.conf
(or whatever the NetworkManager
config is on your system) and add in section [keyfile]
:
unmanaged-devices=mac:MAC_OF_VBOXNET0_IF;mac:MAC_OF_VBOXNET1_IF;...
Then destroy Vagrant machines, restart NetworkManager and try again.
To follow this tutorial, you'll need to have your keys in VMs root's
authorized_keys
. While this is not absolutely necessary (Ansible can use
sudo, password authentication, etc...), it will make things way easier.
Ansible is perfect for this and we will use it for the job. However I won't explain what's happening for now. Just trust me.
ansible-playbook -i step-00/hosts step-00/setup.yml
If you get "Connections timed out" errors, please check the firewall settings of your machine.
If you get errors like:
fatal: [192.168.33.10]: UNREACHABLE! => {"changed": false, "msg": "host key mismatch for 192.168.33.10", "unreachable": true}
then you probably already have SSH host keys for those IPs in your
~/.ssh/known_hosts
. You can remove them with ssh-keygen -R <IP_ADDRESS>
.
Otherwise, just type yes
when prompted to access ssh host keys if
requested.
To polish things up, it's better to have an ssh-agent running, and add your
keys to it (ssh-add
).
NOTE: We are assuming that you're using Ansible version v2.5+ on your local machine. If not you should upgrade ansible to v2.5+ before using this repository (or run under virtualenv).
To check your ansible version use the command ansible --version
. The output
should be similar to the above:
ansible 2.10.5
...
python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
Now head to the first step in step-01.