Get to Know GENI and SAVI

Hello GENI index Hello GENI index Hello GENI index


Your goal in this tutorial is to fetch a parameterized URL on each node in your experiment:<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 determine the parameters in the above url, 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.

The Ansible playbook that you will need is:

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

  ### (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_hostname }}
    shell: curl
    register: public_ip

  - name: Dump public_ip variable
    debug: var=public_ip

  - name: Run geoiplookup to get latitude
    #shell: geoiplookup -f GeoLiteCity.dat {{ public_ip.stdout }} | awk -F ', ' '{print $7}'
    shell: curl -s | grep loc | sed "s/^.*loc..// " | sed "s/..$//" | sed "s/^.*\"//" | sed "s/,.*$//"
    register: lat

  - name: Dump lat variable
    debug: var=lat

  - name: Run geoiplookup to get longitude
#    shell: geoiplookup -f GeoLiteCity.dat {{ public_ip.stdout }} | awk -F ', ' '{print $8}'
    shell: curl -s | grep loc | sed "s/^.*loc..// " | sed "s/..$//" | sed "s/^.*,//"
    register: long

  - name: Dump long variable
    debug: var=long

  ### (f): Fetch the parameterized URL ###

  - shell: curl "<GENI-Username>&name={{ansible_fqdn}}&ip={{public_ip.stdout }}&local={{ansible_eth0.ipv4.address}}&lat={{lat.stdout}}&lng={{long.stdout}}"
    register: hello

  - debug: var=hello

To download this playbook to your client machine:


Before you run this playbook, replace <GENI-Username> at the end of the script (the last curl command) with your GENI username

2. Run the playbook

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

     ansible-playbook -i ansible-hosts gee-tutorial-solution.yaml

3. Verify that your playbook worked as expected

Once you have completed the tutorial, you can check where you’ve said hello from at:

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

Next: Teardown Experiment

Last modified 6 years ago Last modified on 06/23/15 11:22:41

Attachments (2)

Download all attachments as: .zip