The idea behind this repository is to use Vargrant, Oracle VirtualBox and Ansible to provision a simple Linux server, build a web service based on nginx and serve out a simple web page.
NOTE: The code will run on Linux or MacOS machines. But will not work on Windows machines as there is no native 'sshd' support on Windows.
-
Download and install the correct versions of following software : 1a. VirtualBox https://www.virtualbox.org/
1b. Vagrant https://www.vagrantup.com/downloads.html
-
Download this git repository to your computer and unzip it
-
cd to the directory where the unziped file are
-
Run "vagrant up"
-
Following message indicates the Web server has been built and in service
TASK [start the container] *****************************************************
NOTE: See "screen-capture-of-the-run.txt" for full output of the command
Testing:
-
Open a browser and enter : http://localhost:8080/
-
Following message must appear on the browser window:
Hello World !!!
-
Interactive login to the docker
ssh -l vagrant -i .vagrant/machines/default/virtualbox/private_key 192.168.33.99
Cleanup :
-
Press Ctrl/C on the terminal window where "vagrant up" was run
-
Tidy up Vagrant enviornment
$ vagrant global-status // look for the id of the virtual box.
$ vagrant destroy d21c245 // destroy the virtualbox
default: Are you sure you want to destroy the 'default' VM? [y/N] y
==> default: Forcing shutdown of VM...
==> default: Destroying VM and associated drives...
NETWORK SETUP
Local computer ip = 192.168.1.146
Guest OS ip = 192.168.33.99
This is specified in Vagrantfile
defined config.vm.network "private_network", ip: "192.168.33.99"
Port 80 in the docker is mapped to port 8080 on local computer
Confirm
config.vm.network "forwarded_port", guest: 80, host: 8080
NOTES:
-
debian/jessie64 is used as the guest host
-
Checking of the Debian version is omitted for simplicity
-
For MacOS users: I encountered the following bugs and used a workaround. Your mileage may vary.
docker_image, docker_container and docker modules fails with: "Failed to import docker-py - No module named requests.exceptions. Try
pip install docker-py
"}See: ansible/ansible-modules-core#4246 time spent on researching this
So, I am using the ansible 'command' module as an alternative.