<commit_before>How to run the Ansible playbook
---

This Ansible playbook has two distinct roles: 
 - yarn. Install and configure hadoop-2.5.2 yarn on ~okeanos cluster.
 - webserver. Install and setup a Django webserver running our ember application on a ~okeanos virtual machine.

and one common for all hosts:
 - commons. Install sudo and fix missing locale for every host.

How to run yarn role
--
Before running an Ansible playbook for a bare vm in ~okeanos, following commands must be executed in the bare vm:

    apt-get update
    apt-get install -y python
Choice of role must be given as argument from command line or else playbook wont run. For example

    ansible-playbook -i [path/ansible_hosts] [path/ansible/site.yml] -e "choose_role=yarn"

will run the playbook role yarn. As a default, it wont start its daemons or format the cluster.

If these functions are wanted, it can be enabled with variable [start_yarn=True]. Also, if it is run
for the first time, the yarn cluster needs formating so the variable format should be  [format=True].

For example, 

    ansible-playbook -i [path/ansible_hosts] [path/ansible/site.yml] -e "choose_role=yarn start_yarn=True format=True"
will install and configure yarn cluster,format it and start its daemons.

We can change the hadoop yarn version the playbook installs
by giving a different value to variable [yarn_version]. Default value is hadoop-2.5.2.

How to run webserver role
--

This role can be executed as:

    ansible-playbook -i [path/ansible_hosts] [path/ansible/site.yml] -e "choose_role=webserver create_orka_admin=True"

The [create_orka_admin=True] is needed the first time we run webserver role because it creates the orka_admin user that is needed in
install and setup of the Django webserver.

Giving values to other webserver variables is optional but necessary. Especially the following Webserver role variables 

    [db_password, db_user, db_name, django_admin_name, django_admin_password, orka_admin_password, ansible_sudo_pass] 
    
should always be given from command line or in the all.yml and webserver.yml files in group_vars folder. 

If not given, the playbook will run with the default settings which is not recommended.
The [orka_admin_password] encrypted value is created by the user with 

    [python -c 'import crypt; print crypt.crypt("mypassword", <PASSWORD>$")'] 

and the ansible_sudo_pass is the unecrypted [orka_admin_password] value.

So, the optimal execution of webserver role for the first time from the command line would be:

    ansible-playbook -i [path/ansible_hosts] [path/ansible/site.yml] -e "db_password=<PASSWORD> db_user=xxxxx db_name=xxxxx django_admin_name=xxxxx django_admin_password=<PASSWORD> choose_role=webserver create_orka_admin=True orka_admin_password=encrypted(orka_admin_password) ansible_sudo_pass=<PASSWORD>"

It is easier though to change the default values in the ansible/group_vars/all.yml and ansible/group_vars/webserver.yml and run 

    ansible-playbook -i [path/ansible_hosts] [path/ansible/site.yml] -e "choose_role=webserver create_orka_admin=True"

Also, the variables [my_project_dir] [my_project_name] are the directory name where django projects will be created and a django project name and can be changed from their default values.

Other useful variables are :
- [escience_repo], which is the github repo from where webserver role will clone the django project. Default is gtzelepis.

- [path_to_folder_to_minify], which is the path of the app folder to minify/uglify the .js files.

- [path_to_folder_to_removelogging], which is the path of the app folder to removelogging the .js files	
<commit_msg>Update README.md for the Ansible - Backend<commit_after># Ansible playbooks

Below are available in tables, the ansible files and folders with their corresponding description:

|    File     | Description
|------------ |:---
|  group_vars |  It includes constants used by ansible playbooks
|  roles      |  It includes the Ansible roles: yarn, cloudera, commons
|  site.yml   |  It is the entry point of Ansible and shares the Ansible tasks
|  rollback_scale_cluster    | It is called when the cluster scaling fails, so as to rollback the procedure
|  scale_cluster_add_node    | It is called in order to add a node to the Hadoop cluster
|  scale_cluster_remove_node | It is called in order to remove a node from the Hadoop cluster
|  start_cloudera | It is called so as to start or stop the cloudera services
|  start_yarn     | It is called so as to start or stop the yarn or/and ecosystem services

Every Ansible role is in a separate subfolder. In the cases of *yarn* and *cloudera* roles, there are three subfolders, whose description is common and is available below:

|    File     | Description
|------------ |:---
|    files    |  It includes the files that are necessary for the execution of specific services. They are transferred unchanged to the remote machine where commands from the ansible playbooks are executed
|    tasks    |  In case of yarn it installs and configures apache hadoop distribution on the cluster. In case of cloudera it installs and configures, from the cloudera repositories, the cloudera distribution on the cluster
|  templates  |  It includes files with variables, which offers dynamic content. These files are transferred, with the appropriate additions, to the remote machine where commands from the ansible playbooks are executed

In case of *commons* role there is a subfolder whose description is available below:

|    File     | Description
|------------ |:---
|    tasks    | Installs sudo and fixes missing locale for every host.

{'fraction_non_alphanumeric': 0.060056858564321254, 'fraction_numerical': 0.0010660980810234541, 'mean_word_length': 4.168962350780532, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '647623', 'n_tokens_mistral': 1634, 'n_tokens_neox': 1551, 'n_words': 735}