Changes between Version 24 and Version 25 of GENIExperimenter/Tutorials/GENIExperimentEngine/Execute


Ignore:
Timestamp:
03/16/15 17:47:22 (9 years ago)
Author:
acb@cs.princeton.edu
Comment:

--

Legend:

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

    v24 v25  
    6464}}}
    6565
    66 == 2. Create an Ansible playbook to download a parameterized URL from each node ==
    67 
    68 === (a) Create a starter Ansible playbook ===
    69 
    70 A playbook is a YAML file containing a list of Ansible tasks.  To get started creating your Ansible playbook, copy the following into a file called test.yaml:
     66=== (d) A simple playbook ===
     67
     68An Ansible playbook is a YAML file containing a list of Ansible tasks.  Here is a simple playbook; copy it into a file called test.yaml:
    7169
    7270{{{
     
    8785The '''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).
    8886
    89 Now, 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.
     87
     88== 2. Create an Ansible playbook to download a parameterized URL from each node ==
     89
     90Think 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.
    9091
    9192|| [[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.  One thing at a time. ||
     
    9394|| [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''Pro Tip:''' Build your solution a piece at a time.  Each step is, basically: (1) run a command, (2) possibly extract the information from the output and register it in an Ansible variable ||
    9495
    95 || [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''Pro Tip:''' Starting an task in an Ansible playbook with "`- name:`", as in the example above, prints out the string following name at the beginning of the task.  This is useful for keeping track of where you are in a playbook run. ||
    96 
    97 Here is an Ansible playbook skeleton that you can use to complete the tutorial. 
     96Here is an Ansible playbook skeleton that you will use to complete the tutorial.  Copy it to a file and fill in the bits marked `# INSERT ARGUMENTS HERE` based on the instructions in the following subsections.
    9897
    9998{{{
     
    158157
    159158
    160 === (b) Get the container's FQDN ===
    161 
    162 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). 
    163 
    164 === (c) Get the container IP address ===
    165 
    166 Look at the variables collected by Ansible's setup module (step 1(c) above).  Find one that holds the container IP address.  Add a debug task to your playbook, like the one in the starter playbook, to print out its value.  Complete the following task and add it to your playbook
    167 
    168 {{{
    169    - name: Print container IP address
    170      debug: var=
    171 }}}
     159=== (a) Get the container's FQDN ===
     160
     161Look 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. 
     162
     163=== (b) Get the container IP address ===
     164
     165Look 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.
     166
     167=== (c) Get the control host name ===
     168
     169Look 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.
    172170
    173171=== (d) Get the host's public IP address ===
    174172
    175 This is a bit trickier: how to get the host's 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.  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 the host's name; HINT: you need it to SSH into the slicelet) or by running '''curl''' against a webserver that reports the client’s externally visible address.
     173The 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>'''.
    176174
    177175|| [[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. ||
     
    181179|| [[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]. ||
    182180
    183 === (e) Get the latitude and longitude for each node ===
     181=== (d) Get the latitude and longitude for each node ===
    184182
    185183Another requirement of the lab is to map the host's control IP address obtained in the previous step to the latitude and longitude for each node.  One way to do this is to use the '''geoiplookup''' tool, provided by package '''geoip-bin'''.