wiki:GENIExperimenter/Tutorials/GENI-SAVI/Execute

Version 8 (modified by Vic Thomas, 5 years ago) (diff)

--

Get to Know GENI and SAVI

Hello GENI index Hello GENI index Hello GENI index

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>&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.

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. Three of these (the slice name, container name, and local IP) can be found from Ansible variables. Running a setup command, as on the previous page, will show you the Ansible variables. Note that setup is run automatically by Ansible, so when executing a playbook on a node that information is available. Look through the output from setup, and you can identify the variables you'll need. You then need to fetch a custom URL containing this information from each host.

Below is the Ansible playbook that you will need. To download this playbook to your client machine:

 wget http://groups.geni.net/geni/attachment/wiki/GENIExperimenter/Tutorials/GENI-SAVI/Execute/gee-tutorial-solution.yaml

The ansible playbook:

---
- hosts: nodes
  remote_user: "{{ ansible_ssh_user }}"
  sudo: yes
  tasks:

  ### (a): Get the container's FQDN ###
  - name: Dump container name
    debug: var=ansible_fqdn


  ### (b):  Get the container IP address ###
  - name: Dump container IP address
    debug: var=ansible_eth0.ipv4.address


  ### (c): Get the control host name ###
  - name: Dump control host name
    debug: var=ansible_ssh_host


  ### (d): Get the host's public IP address ###
  - name: Get my public IP
    shell: dig +short {{ ansible_ssh_host }}
    register: public_ip

  - name: Dump public_ip variable
    debug: var=public_ip


  ### (e): Get the latitude and longitude for each node ###
  - name: Download GeoLiteCity DB
    get_url: url=http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
      dest=/tmp

  - name: Unzip GeoLiteCity.dat.gz
    shell: gunzip -f /tmp/GeoLiteCity.dat.gz
      creates=GeoLiteCity.dat

  - name: Run geoiplookup to get latitude
    shell: geoiplookup -f /tmp/GeoLiteCity.dat {{ public_ip.stdout }} | awk -F ', ' '{print $7}'
    register: lat

  - name: Dump lat variable
    debug: var=lat

  - name: Run geoiplookup to get longitude
    shell: geoiplookup -f /tmp/GeoLiteCity.dat {{ public_ip.stdout }} | awk -F ', ' '{print $8}'
    register: long

  - name: Dump long variable
    debug: var=long


  ### (f): Fetch the parameterized URL ###
  - debug: msg="http://www.lively-web.org/nodejs/GEETutorial/helloWorld?slice={{ ansible_hostname }}&name={{ ansible_fqdn }}&ip={{ public_ip.stdout }}&local={{ ansible_eth0.ipv4.address }}&lat={{ lat.stdout }}&lng={{ long.stdout }}"

  - shell: curl "http://www.lively-web.org/nodejs/GEETutorial/helloWorld?slice={{ ansible_hostname }}&name={{ ansible_fqdn }}&ip={{ public_ip.stdout }}&local={{ ansible_eth0.ipv4.address }}&lat={{ lat.stdout }}&lng={{ long.stdout }}"

2. Run the playbook

Once you have finished with Step 1, run your playbook against all the nodes in your slice!


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://lively-web.org/users/rick/GEETutorialMap.html

Choose your slicelet name from the drop-down and you should see pins in the map at the coordinates reported by the nodes!


Next: Teardown Experiment

Attachments (2)

Download all attachments as: .zip