Changes between Version 1 and Version 2 of GENIExperimenter/Tutorials/GENIExperimentEngine/Execute


Ignore:
Timestamp:
03/10/15 12:00:04 (9 years ago)
Author:
acb@cs.princeton.edu
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GENIExperimenter/Tutorials/GENIExperimentEngine/Execute

    v1 v2  
    3838You can replace ''hostname'' above with any other Linux command.
    3939
     40The '''setup''' module gathers a bunch of information about each node and saves it in variables that you can reference in your Ansible playbooks.  This will be really useful to do the tutorial!   Try it out on a node to see what it collects (replace slice338 with your slicelet’s name):
     41
     42{{{
     43$ ansible slice338.pcvm1-1.instageni.wisc.edu -i ansible-hosts --private-key id_rsa -u root -m setup
     44}}}
     45
    4046== Create an Ansible playbook to achieve the tutorial objective ==
    4147
     48First create a starter Ansible playbook.  Recall that a playbook is a YAML file containing a list of Ansible commands.  Copy the following into a file called lab.yaml:
     49
     50{{{
     51---
     52- hosts: nodes
     53  remote_user: root
     54  tasks:
     55  - debug: var=ansible_hostname
     56}}}
     57
     58Run the playbook as:
     59
     60{{{
     61$ ansible-playbook -i ansible-hosts --private-key id_rsa lab.yaml
     62}}}
     63
     64The '''setup''' module is run automatically at the beginning of a playbook to populate variables for each node.  The above playbook will dump the value of each node’s ''ansible_hostname'' variable.  To run the playbook on a single node, replace ''nodes'' with the name of one of your slice nodes (e.g., slice338.pcvm3-7.instageni.nps.edu).
     65
     66'''Pro Tip:''' Solve the problem on one node in your slice first, then deploy your solution to the remaining nodes.  One thing at a time
     67
     68Now, think about how you are going to solve the problems of this tutorial.  Recall that your goal is to fetch a parameterized URL on each node of your slicelet:
     69
     70  ''!http://www.lively-web.org/nodejs/GEETutorial/helloWorld?slice=<slice name>&name=<container name>&ip=<IP of host>&local=<IP of  container>&lat=<latitude of host>&lng=<longitude of container>''
     71
     72For instance, the IP address visible inside the slicelet (as reported in the variable ''ansible_eth0.ipv4.address'') is a private address -- it is not the control address of the host, which is one piece of information you want.  There are a number of ways that you could discover the control address, including running '''dig +short''' on the host’s name (see if you can find a variable that contains this; HINT: you need it to SSH into the slicelet) or by running '''curl''' against a webserver that reports the client’s externally visible address.
     73
     74Another requirement of the lab is to map the control IP address obtained above to the latitude and longitude for each node.  For instance you can use the '''geoiplookup''' tool, provided by package '''geoip-bin'''.
     75
     76{{{
     77$ geoiplookup -f <data file> <ip address>
     78}}}
     79
     80where ''<data file>'' is the database of IP addresses and locations.  You can find a good one at: http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz, which you’ll have to download to each node and unzip.   
     81A different approach would be to run '''curl''' against a webserver that maps IP address to latitude and longitude, such as http://ipinfo.io, and parse the output.  '''NOTE:''' this particular website rate-limits the number of requests per node per day, so if you use it, make only a single request per node and save the result in a file… keep in mind that everyone in the tutorial may be hitting this server from the same set of hosts!
     82
    4283== Run the playbook ==
    43 
    44 
    45 
    4684= [wiki:GENIExperimenter/Tutorials/GENIExperimentEngine/Finish Next: Teardown Experiment] =