Instead of running this training on a cloud provider, you can simulate the infrastructure locally. These instructions apply to the PART ONE of the workshop.
Virtualbox, Vagrant and Ansible
-
Virtualbox: https://www.virtualbox.org/wiki/Downloads
-
Vagrant: https://www.vagrantup.com/downloads.html
- install vagrant-vbguest plugin (https://github.com/dotless-de/vagrant-vbguest)
-
Ansible:
-
install Ansible's prerequisites:
$ sudo pip install paramiko PyYAML Jinja2 httplib2 six pycrypto
-
clone the Ansible repository and checkout to a stable version (don't forget the
--recursive
argument when cloning!):$ git clone --recursive https://github.com/ansible/ansible.git $ cd ansible $ git checkout stable-{{ getStableVersionFromAnsibleProject }} $ git submodule update
-
source the setup script to make Ansible available on this terminal session:
$ source path/to/your-ansible-clone/hacking/env-setup
-
you need to repeat the last step every time you open a new terminal session and want to use any Ansible command (but you'll probably only need to run it once).
-
Change into directory that has your Vagrantfile
Run the following commands:
$ vagrant up
$ chmod 600 private-key
$ ansible-playbook provisioning.yml
And that's it! Now you should be able to ssh on node1
using:
$ ssh [email protected] -i private-key
These are the default IP addresses for the nodes:
10.10.10.10 node1
10.10.10.20 node2
10.10.10.30 node3
10.10.10.40 node4
10.10.10.50 node5
The source code of this repo will be mounted at ~/orchestration-workshop
(only on the node1
), so you can edit the code externally and the changes
will reflect inside the instance.
-
Depending on the Vagrant version,
sudo apt-get install bsdtar
may be needed -
If you get an error like "no Vagrant file found" or you have a file but "cannot open base box" when running
vagrant up
, chances are good you not in the correct directory. Make sure you are in sub directory named "prepare-local". It has all the config files required by ansible, vagrant and virtualbox -
If you are using Python 3.7, running the ansible-playbook provisioning, see an error like "SyntaxError: invalid syntax" and it mentions the word "async", you need to upgrade your Ansible version to 2.6 or higher to resolve the keyword conflict. ansible/ansible#42105
-
If you get strange Ansible errors about dependencies, try to check your pip version with
pip --version
. The current version is 8.1.1. If your pip is older than this, upgrade it withsudo pip install --upgrade pip
, restart your terminal session and install the Ansible prerequisites again. -
If the IP's
10.10.10.[10-50]
are already taken in your machine, you can change them to other values in thevagrant.yml
andinventory
files in this directory. Make sure you pick a set of IP's inside the same subnet. -
If you suspend your computer, the simulated private network may stop to work. This is a known problem of Virtualbox. To fix it, reload all the VM's with
vagrant reload
. -
If you get a ssh error saying
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED
it means that you already had in the past some other host using one of the IP addresses we use here. To solve this, remove the old entry in yourknown_hosts
file with:$ ssh-keygen -f "~/.ssh/known_hosts" -R 10.10.10.10 -R 10.10.10.20 -R 10.10.10.30 -R 10.10.10.40 -R 10.10.10.50