Changes between Version 7 and Version 8 of GENIExperimenter/Tutorials/GENIExperimentEngine/Execute


Ignore:
Timestamp:
03/11/15 16:09:12 (9 years ago)
Author:
acb@cs.princeton.edu
Comment:

--

Legend:

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

    v7 v8  
    7474The '''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).
    7575
    76 '''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
     76|| [[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. ||
    7777
    7878Now, think about how you are going to solve the problems of this tutorial. 
     
    8989A different approach would be to run '''curl''' against a webserver that maps IP address to latitude and longitude, such as http://ipinfo.io, and parse the output.  '''NOTE:''' this particular website rate-limits the number of requests per node per day, so if you use it, ''make only a single request per node and save the result in a file''… keep in mind that everyone in the tutorial may be hitting this server from the same set of hosts!
    9090
    91 '''Pro Tip:''' Usually in an Ansible playbook you reference a variable by surrounding it in double curly brackets: ''{{ ansible_eth0.ipv4.address }}''
     91|| [[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 }}'' ||
    9292
    93 '''Pro Tip 2:''' 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
    94 ''{{ varname }}'' or, for shell command output, ''{{ varname.stdout }}''
     93|| [[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 }}'' ||
    9594
    96 '''Pro Tip 3:''' The Ansible '''script''' module can be used to run arbitrary scripts in your slicelet.  See: http://docs.ansible.com/script_module.html
     95|| [[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 ||
    9796
    98 '''Pro Tip 4:''' Not all the resources you may need are installed on the nodes!  Part of this tutorial is learning how to install software and configure a node to do what you want.  Step one is to figure out what you need, what you have, and then how to get the rest.  The command which will tell you if something’s installed.  The '''apt''' Ansible module is useful for installing packages; see: http://docs.ansible.com/apt_module.html
     97|| [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''Pro Tip:''' Not all the resources you may need are installed on the nodes!  Part of this tutorial is learning how to install software and configure a node to do what you want.  Step one is to figure out what you need, what you have, and then how to get the rest.  The command which will tell you if something’s installed.  The '''apt''' Ansible module is useful for installing packages; see: http://docs.ansible.com/apt_module.html ||
    9998
    100 '''Pro Tip 5:''' Build your solution a piece at a time.  Each step is, basically:
    101  * run a command
    102  * possibly extract the information from the output and register it in an Ansible variable
     99|| [[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 ||
    103100
    104101At this point, you can flesh out base Ansible playbook to complete the lab.  No need to hurry.  Run the command, look at the output; use Ansible’s debug module to print the value of the variable you’re stuffing it into.  Getting the information may involve a sequence of text-processing steps (get the right line, strip off trailing stuff, strip off leading stuff, etc).  So, do each step, one at a time, and print out the value after each step.  This will help you find errors quickly and get to something working very quickly.