Changes between Version 9 and Version 10 of GENIExperimenter/Tutorials/GENIExperimentEngine/DesignSetup


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

--

Legend:

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

    v9 v10  
    4848----
    4949
    50 == 3. Learn basic concepts of Ansible ==
     50== 3. Configure the Ansible controller for your slicelet ==
     51
     52If you already have Ansible installed on your laptop, then you can use it as the controller for this experiment.  Otherwise, you will use one of the nodes in your slicelet as the Ansible controller.  Pick one, log into it, and install ansible using apt-get:
     53
     54{{{
     55$ apt-get update
     56$ apt-get install ansible
     57}}}
     58
     59Then upload your slicelet helper files to that node.  {{{scp}}} can be used for this
     60
     61{{{
     62$ scp -i id_rsa -F ssh-config ansible-hosts slice323.pcvm3-1.instageni.metrodatacenter.com:.
     63$ scp -i id_rsa -F ssh-config id_rsa slice323.pcvm3-1.instageni.metrodatacenter.com:.
     64}}}
     65
     66|| [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''Pro Tip:''' remove your controller node from the '''ansible_hosts''' file after you’ve uploaded. ||
     67
     68----
     69
     70== 4. Learn some basic concepts of Ansible ==
    5171
    5272Ansible (http://docs.ansible.com) is a free, open-source, intuitive IT automation tool that is well-suited to the tasks in this tutorial.  Ansible commands can be run from the command line or put in a YAML file called a ''playbook''.  We will be creating an Ansible playbook to run the parameterized HTTP query described earlier.
     
    7595The task uses the '''apt''' module, and tells Ansible: “Make sure the latest version of package foo is installed”.  There are many other modules which are well-documented at http://docs.ansible.com.
    7696
    77 ----
     97Here are a few Ansible tasks to run, to get some experience with the command-line interface. 
    7898
    79 == 4. Configure the Ansible controller for your slicelet ==
     99=== (a) The ping module ===
    80100
    81 If you already have Ansible installed on your laptop, then you can use it as the controller for this experiment.  Otherwise, you will use one of the nodes in your slicelet as the Ansible controller.  Pick one, log into it, and install ansible using apt-get:
     101The '''ping''' module simply tries to do a SSH login to a node and reports success or failure.  Run the following command on your controller:
    82102
    83103{{{
    84 $ apt-get update
    85 $ apt-get install ansible
     104$ ansible nodes -i ansible-hosts -m ping
    86105}}}
    87106
    88 Then upload your slicelet helper files to that node.  {{{scp}}} can be used for this
     107If you don’t see success everywhere then there is something wrong with your setup.  Ask one of the tutorial leaders for help. 
     108
     109=== (b) The shell module ===
     110
     111The '''shell''' module lets you run arbitrary SSH commands in parallel across a set of hosts.  It’s useful for poking around, or if there is no Ansible module with the functionality you need.  Try it out:
    89112
    90113{{{
    91 $ scp -i id_rsa -F ssh-config ansible-hosts slice323.pcvm3-1.instageni.metrodatacenter.com:.
    92 $ scp -i id_rsa -F ssh-config id_rsa slice323.pcvm3-1.instageni.metrodatacenter.com:.
     114$ ansible nodes -i ansible-hosts -m shell -a "hostname"
    93115}}}
    94116
    95 || [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''Pro Tip:''' remove your controller node from the '''ansible_hosts''' file after you’ve uploaded. ||
     117You can replace ''hostname'' above with any other Linux command.
     118
     119=== (c) The setup module ===
     120
     121The '''setup''' module gathers a bunch of information about each node and saves it in variables that you can reference in your Ansible playbooks.  This will be really useful to do the tutorial!   Try it out on a node to see what it collects (replace `<your-slicelet>` with your slicelet’s name):
     122
     123{{{
     124$ ansible <your-slicelet>.pcvm1-1.instageni.wisc.edu -i ansible-hosts -m setup
     125}}}
     126
     127=== (d) A simple playbook ===
     128
     129Next, we will look at a simple Ansible playbook.  An Ansible playbook is a YAML file containing a list of Ansible tasks.  Copy the playbook below into a file called test.yaml:
     130
     131{{{
     132#!python
     133---
     134- hosts: nodes
     135  remote_user: root
     136  tasks:
     137  - name: An example of a debug statement
     138    debug: var=ansible_hostname
     139}}}
     140
     141Run the playbook as:
     142
     143{{{
     144$ ansible-playbook -i ansible-hosts test.yaml
     145}}}
     146
     147The '''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).
     148
    96149
    97150----