Changes between Version 3 and Version 4 of GENIExperimenter/Tutorials/GENIExperimentEngine/Execute


Ignore:
Timestamp:
03/10/15 12:15:25 (10 years ago)
Author:
acb@cs.princeton.edu
Comment:

--

Legend:

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

    v3 v4  
    8383'''Pro Tip:''' Usually in an Ansible playbook you reference a variable by surrounding it in double curly brackets: ''{{ ansible_eth0.ipv4.address }}''
    8484
    85 '''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
     85'''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
    8686''{{ varname }}'' or, for shell command output, ''{{ varname.stdout }}''
    8787
    88 '''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
     88'''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
    8989
    90 '''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
     90'''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
    9191
    92 '''Pro Tip #5:''' Build your solution a piece at a time.  Each step is, basically:
    93 - run a command
    94 - possibly extract the information from the output and register it in an Ansible variable
     92'''Pro Tip 5:''' Build your solution a piece at a time.  Each step is, basically:
     93 * run a command
     94 * possibly extract the information from the output and register it in an Ansible variable
    9595
    96 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.
     96At 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.
    9797
    9898== Run the playbook ==
    9999
     100Once you have finished your playbook, run it against all the nodes!
     101
     102{{{
     103$ ansible-playbook -i ansible-hosts --private-key id_rsa lab.yaml
     104}}}
     105
    100106= [wiki:GENIExperimenter/Tutorials/GENIExperimentEngine/Finish Next: Teardown Experiment] =