Changes between Initial Version and Version 1 of GENIExperimenter/Tutorials/SystematicExperimentationAnsible/Execute


Ignore:
Timestamp:
09/17/15 16:32:30 (9 years ago)
Author:
sedwards@bbn.com
Comment:

--

Legend:

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

    v1 v1  
     1= [..  Systematic Experimentation (with Ansible)] =
     2{{{
     3#!html
     4
     5<div style="text-align:center; width:495px; margin-left:auto; margin-right:auto;">
     6<img id="Image-Maps_5201305222028436" src="http://groups.geni.net/geni/attachment/wiki/GENIExperimenter/Tutorials/Graphics/Execute.jpg?format=raw" usemap="#Image-Maps_5201305222028436" border="0" width="495" height="138" alt="" />
     7<map id="_Image-Maps_5201305222028436" name="Image-Maps_5201305222028436">
     8<area shape="rect" coords="18,18,135,110" href="./Design" alt="" title=""    />
     9<area shape="rect" coords="180,18,297,111" href="./Execute" alt="" title=""    />
     10<area shape="rect" coords="344,17,460,110" href="./Finish" alt="" title=""    />
     11<area shape="rect" coords="493,136,495,138" href="http://www.image-maps.com/index.php?aff=mapped_users_5201305222028436" alt="Image Map" title="Image Map" />
     12</map>
     13<!-- Image map text links - End - -->
     14
     15</div>
     16}}}
     17
     18
     19== 4.  Configure and Initialize ==
     20
     21=== 4.1.  Download the Ansible playbook ===
     22   a. Download the Ansible playbook, webpages, etc needed to configure the nodes.
     23{{{
     24#!div style="background: #ffd; border: 3px ridge; width: 800px;"
     25Use `wget` to download the tarball of files onto your local machine and use `tar` to uncompress it:
     26   {{{
     27#!sh
     28mkdir ansible
     29cd ansible
     30wget http://www.gpolab.bbn.com/exp/scalingup/ansible/ansible.tar.gz
     31tar zxvf ansible.tar.gz
     32   }}}
     33}}}
     34
     35
     36=== 4.2.  Create the Ansible inventory file ===
     37
     38`omni` comes with a script, `readyToLogin` which finds the login information for nodes in your slice.  As of `omni` version 2.8, `readyToLogin` has an `--ansible-inventory` flag which generates the Ansible inventory, which is a flat file which tells Ansible the name and login information for your nodes.
     39
     40 a. Create your Ansible inventory file:
     41{{{
     42#!div style="background: #ffd; border: 3px ridge; width: 800px;"
     43On your local machine:
     44
     45   {{{
     46#!sh
     47$ readyToLogin MYSLICE --useSliceAggregates --ansible-inventory -o
     48$ cat inventory
     49   }}}
     50
     51Example output of running these commands:
     52   {{{
     53#!sh
     54$ readyToLogin MYSLICE --useSliceAggregates --ansible-inventory -o
     55Host info saved in inventory file: /Users/jdoe/projects/GENI/hellogeni/inventory
     56
     57$ cat inventory
     58host-2  ansible_ssh_host=pc2.instageni.stanford.edu  ansible_ssh_port=31291
     59host-1  ansible_ssh_host=pc2.instageni.stanford.edu  ansible_ssh_port=31290
     60server-1  ansible_ssh_host=pcvm2-33.instageni.stanford.edu
     61rt-1  ansible_ssh_host=pc2.instageni.stanford.edu  ansible_ssh_port=31292
     62   }}}
     63}}}
     64{{{
     65#!div style="background: #fdd; border: 3px ridge; width: 800px;"
     66
     67{{{
     68#!html
     69
     70<table id="Table_03" border="0" cellpadding="5" cellspacing="0">
     71        <tr>
     72                <td>
     73                        <img src="http://groups.geni.net/geni/attachment/wiki/GENIExperimenter/Tutorials/Graphics/Symbols-Tips-icon.png?format=raw" width="50" height="50" alt="Tip">
     74               </td>
     75               <td>
     76                   Windows users should copy their 'inventory' file onto their node running the ansible client.
     77               </td>
     78        </tr>
     79</table>
     80}}}
     81}}} 
     82 b. Be sure your private key has been added to your SSH agent:
     83{{{
     84#!div style="background: #ffd; border: 3px ridge; width: 800px;"
     85   {{{
     86ssh-add /path/to/your/private/key
     87   }}}
     88}}}
     89 c. Check to see if your nodes are up and ready.
     90{{{
     91#!div style="background: #ffd; border: 3px ridge; width: 800px;"
     92This command uses the `ping` module to ping the specified nodes (in this case `all`) listed in the inventory file:
     93   {{{
     94#!sh
     95$ ansible -i inventory all -m ping
     96   }}}
     97
     98Example output showing all of the nodes responding to ping:
     99   {{{
     100#!sh
     101$ ansible -i inventory all -m ping
     102server-1 | success >> {
     103    "changed": false,
     104    "ping": "pong"
     105}
     106
     107host-1 | success >> {
     108    "changed": false,
     109    "ping": "pong"
     110}
     111
     112rt-1 | success >> {
     113    "changed": false,
     114    "ping": "pong"
     115}
     116
     117host-2 | success >> {
     118    "changed": false,
     119    "ping": "pong"
     120}
     121}}}
     122}}}
     123 c. Try using the ping module in Ansible to only ping `server-1` or `host-1` by replacing `all` in the above with `server-1` or `host-1`.
     124
     125
     126
     127=== 4.3. Configure the nodes ===
     128
     129{{{
     130#!div style="background: #ffd; border: 3px ridge; width: 800px;"
     131
     132{{{
     133#!html
     134
     135<table id="Table_03" border="0" cellpadding="5" cellspacing="0">
     136        <tr>
     137                <td>
     138                        <img src="http://groups.geni.net/geni/attachment/wiki/GENIExperimenter/Tutorials/Graphics/Symbols-Tips-icon.png?format=raw" width="50" height="50" alt="Tip">
     139               </td>
     140               <td>
     141                   Ansible commands can be collected into files called <i>Playbooks</i>.  Playbooks are in a configuration file format called <i>YAML</i> which is very straightforward.   In particular, Ansible Ad Hoc commands easily map to commands used in an Ansible Playbook. 
     142               </td>
     143        </tr>
     144</table>
     145}}}
     146The Playbook to configure the `server` node is in `server.yml`.  It links to other files.  For example, the code to tell the `server` node to run an `nmap` scan and post the results is in `roles/nmap/tasks/map.yml` and looks as follows:
     147
     148   {{{
     149#!python
     150---
     151   - name: map network using nmap
     152     command: nmap -sP -oX {{ nmap_xml_file }} {{ address_range }}
     153   - name: convert nmap xml to html
     154     shell:  xsltproc /usr/share/nmap/nmap.xsl {{ nmap_xml_file }} > {{ nmap_html_file }}
     155   - name: create directory for nmap logs in WEB_ROOT/nmaplogs with permissions of 755
     156     file: >
     157        dest={{ WEB_ROOT }}/{{ nmap_dir }}
     158        state=directory
     159        mode=755
     160   - name: copy nmap html file to a public place
     161     command: mv {{ nmap_html_file }} {{ WEB_ROOT }}/{{ nmap_dir }}/nmap.html removes={{ nmap_html_file }}
     162    }}}
     163
     164''Do these commands look like the Ad Hoc command (`ping`) from the previous step?''
     165
     166Run the playbook to configure the `server` with the following command on the local machine:
     167
     168   {{{
     169#!python
     170ansible-playbook server.yml -i inventory
     171   }}}
     172}}}
     173 a. Browse to hostname of the server node in your browser.  Click on the `nmap` link.
     174
     175=== 4.4. Update a portion of the configuration ===
     176 a. After some of your neighbors have brought up their nodes, run the following command to only update the `nmap` portion of the `server` configuration:
     177   {{{
     178#!python
     179ansible-playbook update-map.yml -i inventory
     180   }}}
     181 a. If you repeatedly run the above command over time you should see more nodes found by the `nmap` scan. 
     182 a. Feel free to change the value of `address_range` in `groups_vars/all.yml` and rerun `update-map.yml` to search for more nodes.
     183
     184
     185== 5. Execute Experiment ==
     186
     187----
     188
     189= [wiki:GENIExperimenter/Tutorials/SystematicExperimentationAnsible/DesignSetup Setup] =
     190= [wiki:GENIExperimenter/Tutorials/SystematicExperimentationAnsible/Finish Next:  Finish] =