No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Brian Salcedo afd7cdfc38 add screenshot 1 year ago
example initial commit 1 year ago
playbooks increase wait time for database 1 year ago
test_db @ 6c60bc6b4a initial commit 1 year ago
.gitignore initial commit 1 year ago
.gitmodules initial commit 1 year ago
README.md add screenshot 1 year ago
Vagrantfile initial commit 1 year ago
employees-screenshot.jpg increase wait time for database 1 year ago

README.md

Example Employees Application

alt text

Objective:

Write an application that displays a list of employees according to the following criteria:

  • Employee is male.
  • Employee was born on February 1st, 1965.
  • Employee was hired after January 1st, 1990.
  • List is ordered by the full name of the employee.

The application must make use of the following technology and tools:

  • Nginx web server.
  • Any programming language (PHP/Python/Perl/Whatever).
  • MySQL database server.
  • Configuration management tool (SaltStack, Ansible, Puppet, Chef, etc).
  • The employees database

How it Works:

The application is written in Django. After cloning this repository, use Vagrant to deploy the application. Vagrant will start an Ubuntu 16.04 LTS virtual machine, and then use Ansible to provision Docker, and start four containers:

  • cache (A Redis container used by Django to cache the rendered employees list)
  • database (A MySQL container to store the employees database)
  • application (An application container that serves Django via gunicorn)
  • webserver (An Nginx container to serve the application)

The Vagrantfile defines a private_network with an IP address of 192.168.33.10, so the user can access the application from a browser by visiting http://192.168.33.10/. You may change the IP, if needed.

Installation and Deployment:

This example requires Git, Vagrant with VirtualBox, and the latest Ansible. This documentation is written with Ubuntu 16.04 LTS as a base, in mind. Users of other distributions, or OSX, can adapt these steps to achieve the desired result.


The included playbooks make use of newer features in Ansible that may not be available in the packaged version shipped with Ubuntu 16.04 LTS or Fedora 25. In this case, run Ansible in a virtual environment.

Setting up a virtual environment for Ansible (If your Ansible version is less than 2.1.x):

  1. Install python-virtualenv and needed dependencies for Ansible: $ sudo apt-get install build-essential python-dev python-virtualenv libffi-dev libssl-dev
  2. Create and activate a virtual environment for Ansible: ``` $ cd employees $ virtualenv venv $ . venv/bin/activate (venv) $ pip install ansible (venv) $ hash -r # ensure we are using the environment Ansible, not a system Ansible. (venv) $ ansible --version ansible 2.3.0.0 ----

Once the dependencies are satisfied, use the following steps to deploy the application:

  1. Ensure Vagrant and VirtualBox are installed: $ sudo apt-get install vagrant virtualbox
  2. Clone this repository (the recursive switch is required to pull in the test_db submodule): $ git clone --recursive https://github.com/salcedo/employees.git employees $ cd employees
  3. Ensure you are running the latest Ansible version 2.1.x or above. (See steps above, if needed) $ ansible --version If running from a virtual environment, ensure the environment is active. $ . venv/bin/activate (venv) $ ansible --version
  4. Deploy the application.

    ~/employees$ vagrant up
    

    Demo The Application:

    After deployment is complete, point your browser to http://192.168.33.10/ to see the running application.

asciicast