Changes between Version 36 and Version 37 of GENIExperimenter/Tutorials/GENIExperimentEngine/Execute


Ignore:
Timestamp:
03/17/15 11:41:27 (9 years ago)
Author:
acb@cs.princeton.edu
Comment:

--

Legend:

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

    v36 v37  
    3030'''This page will log each of your queries, and you can check that all your nodes were successfully able to run the query.'''
    3131
    32 We will work up to this goal through hands-on learning with Ansible.
    33 
    34 -----
    35 
    36 == 1. Create an Ansible playbook to download a parameterized URL from each node ==
    37 
    38 Think about how you are going 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.
    39 
    40 The following subsections provide more information on each step in this process.
    41 
    42 === (a) Get the container's FQDN ===
    43 
    44 Look at the variables collected by Ansible's setup module (step 1(c) above).  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. 
    45 
    46 === (b) Get the container IP address ===
    47 
    48 Look at the variables collected by Ansible's setup module (step 1(c) above).  Find one that holds the container IP address and dump it using a '''debug''' task.
    49 
    50 === (c) Get the control host name ===
    51 
    52 Look at the variables collected by Ansible's setup module (step 1(c) above).  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.
    53 
    54 === (d) Get the host's public IP address ===
    55 
    56 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>'''.
    57 
    58 || [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''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. ||
    59 
    60 || [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''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 [https://github.com/ansible/ansible-examples/blob/master/language_features/get_url.yml this playbook]. ||
    61 
    62 || [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''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 [https://github.com/ansible/ansible-examples/blob/master/language_features/register_logic.yml this playbook]. ||
    63 
    64 === (e) Get the latitude and longitude for each node ===
    65 
    66 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'''.
    67 
    68 {{{
    69 $ geoiplookup -f <data file> <ip address>
    70 }}}
    71 
    72 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.   
    73 
    74 || [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''Pro Tip:''' The Ansible '''script''' module can be used to run arbitrary scripts in your slicelet.  See: http://docs.ansible.com/script_module.html ||
    75 
    76 || [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''Pro Tip:''' Not all the resources you may need are installed on the nodes!  The '''apt''' Ansible module is useful for installing packages; see: http://docs.ansible.com/apt_module.html ||
    77 
    78 === (f) Fetch the parameterized URL ===
    79 
    80 At this point, you should have enough information to fetch the parameterized URL in the playbook.
    81 
    82 Here is an Ansible playbook skeleton to complete.  Copy it to a file name ''gee-tutorial.yaml'' and fill in the bits marked `# INSERT ARGUMENTS HERE` based on the instructions in the following subsections.
     32You will use Ansible to do this.  Below is a skeleton Ansible file that you use to work through the tutorial.  Copy it to a file name ''gee-tutorial.yaml'' and fill in the bits marked `# INSERT ARGUMENTS HERE` based on the instructions in the following section.
    8333
    8434{{{
     
    155105}}}
    156106
     107
     108-----
     109
     110== 1. Create an Ansible playbook to download a parameterized URL from each node ==
     111
     112To 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.
     113
     114=== (a) Get the container's FQDN ===
     115
     116Look 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. 
     117
     118=== (b) Get the container IP address ===
     119
     120Look at the variables collected by Ansible's setup module.  Find one that holds the container IP address and dump it using a '''debug''' task.
     121
     122=== (c) Get the control host name ===
     123
     124Look 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.
     125
     126=== (d) Get the host's public IP address ===
     127
     128The 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>'''.
     129
     130|| [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''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. ||
     131
     132|| [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''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 [https://github.com/ansible/ansible-examples/blob/master/language_features/get_url.yml this playbook]. ||
     133
     134|| [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''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 [https://github.com/ansible/ansible-examples/blob/master/language_features/register_logic.yml this playbook]. ||
     135
     136=== (e) Get the latitude and longitude for each node ===
     137
     138To 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'''.
     139
     140{{{
     141$ geoiplookup -f <data file> <ip address>
     142}}}
     143
     144where ''<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.   
     145
     146Note 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'''.
     147
     148|| [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''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 ||
     149
     150=== (f) Fetch the parameterized URL ===
     151
     152At 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.
     153
     154
    157155|| [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''Pro Tip:''' Solve the problem on one node in your slice first, then deploy your solution to the remaining nodes.  ||
    158156