Changes between Version 34 and Version 35 of GENIExperimenter/Tutorials/GENIExperimentEngine/Execute
- Timestamp:
- 03/17/15 10:55:45 (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GENIExperimenter/Tutorials/GENIExperimentEngine/Execute
v34 v35 36 36 == 1. Experiment with Ansible == 37 37 38 We will first get familiar with some basic Ansible tasks using the command-line interface.39 40 === (a) The ping module ===41 42 The '''ping''' module simply tries to do a SSH login to a node and reports success or failure. Run the following command on your controller:43 44 {{{45 $ ansible nodes -i ansible-hosts -m ping46 }}}47 48 If you don’t see success everywhere then there is something wrong with your setup. Ask one of the tutorial leaders for help. Note that you will be prompted to accept each node as you log into it; this happens only once per node, the first time you log in.49 50 === (b) The shell module ===51 52 The '''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:53 54 {{{55 $ ansible nodes -i ansible-hosts -m shell -a "hostname"56 }}}57 58 You can replace ''hostname'' above with any other Linux command.59 60 === (c) The setup module ===61 62 The '''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):63 64 {{{65 $ ansible <your-slicelet>.pcvm1-1.instageni.wisc.edu -i ansible-hosts -m setup66 }}}67 68 === (d) A simple playbook ===69 70 Next, 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:71 72 {{{73 #!python74 ---75 - hosts: nodes76 remote_user: root77 tasks:78 - name: An example of a debug statement79 debug: var=ansible_hostname80 }}}81 82 Run the playbook as:83 84 {{{85 $ ansible-playbook -i ansible-hosts test.yaml86 }}}87 88 The '''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).89 38 90 39 ----- 91 40 92 == 2. Create an Ansible playbook to download a parameterized URL from each node ==41 == 1. Create an Ansible playbook to download a parameterized URL from each node == 93 42 94 43 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. … … 151 100 152 101 153 ### 2(a): Get the container's FQDN ###102 ### (a): Get the container's FQDN ### 154 103 - name: Dump container FQDN 155 104 debug: # INSERT ARGUMENTS HERE 156 105 157 106 158 ### 2(b): Get the container IP address ###107 ### (b): Get the container IP address ### 159 108 - name: Dump container IP address 160 109 debug: # INSERT ARGUMENTS HERE 161 110 162 111 163 ### 2(c): Get the control host name ###112 ### (c): Get the control host name ### 164 113 - name: Dump control host name 165 114 debug: # INSERT ARGUMENTS HERE 166 115 167 116 168 ### 2(d): Get the host's public IP address ###117 ### (d): Get the host's public IP address ### 169 118 - name: Install dnsutils (for dig) 170 119 apt: # INSERT ARGUMENTS HERE … … 178 127 179 128 180 ### 2(e): Get the latitude and longitude for each node ###129 ### (e): Get the latitude and longitude for each node ### 181 130 - name: Install geoip-bin (for geoiplookup) 182 131 apt: # INSERT ARGUMENTS HERE … … 203 152 204 153 205 ### 2(f): Fetch the parameterized URL ###206 - name: Dump the full URL 154 ### (f): Fetch the parameterized URL ### 155 - name: Dump the full URL, to make sure it looks OK 207 156 debug: msg="http://www.lively-web.org/nodejs/GEETutorial/helloWorld?slice=# INSERT ARGUMENTS HERE" 208 157 … … 216 165 ---- 217 166 218 == 3. Run the playbook ==167 == 2. Run the playbook == 219 168 220 169 Once you have finished your playbook, run it against all the nodes! … … 224 173 ---- 225 174 226 == 4. Verify that your playbook worked as expected ==175 == 3. Verify that your playbook worked as expected == 227 176 228 177 Once you have completed the tutorial, you can check where you’ve said hello from at: