Version 38 (modified by 10 years ago) (diff) | ,
---|
Get to Know the GENI Experiment Engine
STEPS FOR EXECUTING EXERCISE
Your goal in this tutorial is to fetch a parameterized URL on each node of your slicelet:
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>
This page will log each of your queries, and you can check that all your nodes were successfully able to run the query.
You will use Ansible to do this. Below is a skeleton Ansible file that you use to work through the tutorial (download). You will need to fill in the bits marked # INSERT ARGUMENTS HERE
based on the instructions in the following section.
--- - hosts: nodes remote_user: root tasks: - name: Update apt cache shell: apt-get update - name: Install python-apt (to work around an Ansible bug) shell: apt-get -y install python-apt ### (a): Get the container's FQDN ### - name: Dump container FQDN debug: # INSERT ARGUMENTS HERE ### (b): Get the container IP address ### - name: Dump container IP address debug: # INSERT ARGUMENTS HERE ### (c): Get the control host name ### - name: Dump control host name debug: # INSERT ARGUMENTS HERE ### (d): Get the host's public IP address ### - name: Install dnsutils (for dig) apt: # INSERT ARGUMENTS HERE - name: Get my public IP using 'dig +short' shell: # INSERT ARGUMENTS HERE register: public_ip - name: Dump public_ip variable debug: var=public_ip ### (e): Get the latitude and longitude for each node ### - name: Install geoip-bin (for geoiplookup) apt: # INSERT ARGUMENTS HERE - name: Download GeoLiteCity DB get_url: # INSERT ARGUMENTS HERE - name: Unzip GeoLiteCity.dat.gz shell: gunzip -f GeoLiteCity.dat.gz - name: Run geoiplookup to get latitude shell: # INSERT ARGUMENTS HERE register: latitude - name: Dump latitude variable debug: var=latitude - name: Run geoiplookup to get longitude shell: # INSERT ARGUMENTS HERE register: longitude - name: Dump longitude variable debug: var=longitude ### (f): Fetch the parameterized URL ### - name: Dump the full URL, to make sure it looks OK debug: msg="http://www.lively-web.org/nodejs/GEETutorial/helloWorld?slice=# INSERT ARGUMENTS HERE" - name: Fetch the full URL shell: curl "http://www.lively-web.org/nodejs/GEETutorial/helloWorld?slice=# INSERT ARGUMENTS HERE"
1. Create an Ansible playbook to download a parameterized URL from each node
To solve the problems of this tutorial, you need to collect several pieces of information on each node: the container name, the IP of the host (i.e., the VM hosting the container), the IP of the container, and the latitude and longitude of the host. You then need to fetch a custom URL containing this information from each host. The following subsections provide guidance on how to complete each step.
(a) Get the container's FQDN
Look at the variables collected by Ansible's setup module. Find one that holds the container's fully-qualified domain name (e.g., slice347.pcvm1-1.instageni.iu.edu) and dump it using a debug task.
(b) Get the container IP address
Look at the variables collected by Ansible's setup module. Find one that holds the container IP address and dump it using a debug task.
(c) Get the control host name
Look at the variables collected by Ansible's setup module. Find one that holds the control host's FQDN (HINT: it begins with pcvm) and dump it using a debug task. You'll need this for the next step.
(d) Get the host's public IP address
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. To discover the public IP address of the node, run dig +short <control host name>.
Pro Tip: The ansible command-line tool is a good way to try out Ansible tasks before putting them in your playbook. Look at the examples in part 1 above. |
Pro Tip: Usually in an Ansible playbook you reference a variable by surrounding it in double curly brackets: {{ ansible_eth0.ipv4.address }}. You can see examples of how variables are referenced in tasks in this playbook. |
Pro Tip: When you run an Ansible command in a playbook, you can save the output into a new variable using register: varname Then you can retrieve the value later in the playbook using {{ varname }} or, for shell command output, {{ varname.stdout }}. You can see an example of how to register a variable in this playbook. |
(e) Get the latitude and longitude for each node
To map the host's control IP address obtained in the previous step to the latitude and longitude for each node, use the geoiplookup tool, provided by package geoip-bin.
$ geoiplookup -f <data file> <ip address>
where <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.
Note that geoiolookup returns a bunch of comma-separated fields. The latitude and longitude are in fields 7 and 8. You'll need to extract these -- perhaps by piping the output of geoiplookup into awk.
Pro Tip: You can also use the Ansible script module to run arbitrary scripts in your slicelet, if that helps. See: http://docs.ansible.com/script_module.html |
(f) Fetch the parameterized URL
At this point, you should have enough information to fetch the parameterized URL in the playbook. You should first use a debug task to print out the URL to make sure that it's formatted correctly.
Pro Tip: Solve the problem on one node in your slice first, then deploy your solution to the remaining nodes. |
Pro Tip: Build your solution a piece at a time. Get each step working before continuing to the next step. |
2. Run the playbook
Once you have finished your playbook, run it against all the nodes!
As a data point, our Ansible playbook contained six commands (not including debug commands) and used the apt, shell, and get_url modules.
3. Verify that your playbook worked as expected
Once you have completed the tutorial, you can check where you’ve said hello from at:
http://www.lively-web.org/nodejs/GEETutorial/show_hellos?slice=<your slice>
You should see an entry for each node in your slicelet.
Next: Teardown Experiment
Attachments (2)
-
gee-tutorial.yaml (1.4 KB) - added by 10 years ago.
Ansible playbook skeleton for fetching the parameterized URL
-
gee-tutorial-solution.yaml (1.8 KB) - added by 10 years ago.
Ansible playbook solution for fetching the parameterized URL
Download all attachments as: .zip