Changes between Version 3 and Version 4 of GENIExperimenter/Tutorials/GENIExperimentEngine/Execute
- Timestamp:
- 03/10/15 12:15:25 (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GENIExperimenter/Tutorials/GENIExperimentEngine/Execute
v3 v4 83 83 '''Pro Tip:''' Usually in an Ansible playbook you reference a variable by surrounding it in double curly brackets: ''{{ ansible_eth0.ipv4.address }}'' 84 84 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 using85 '''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 86 86 ''{{ varname }}'' or, for shell command output, ''{{ varname.stdout }}'' 87 87 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.html88 '''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 89 89 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.html90 '''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 91 91 92 '''Pro Tip #5:''' Build your solution a piece at a time. Each step is, basically:93 -run a command94 -possibly extract the information from the output and register it in an Ansible variable92 '''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 95 95 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.96 At 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. 97 97 98 98 == Run the playbook == 99 99 100 Once 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 100 106 = [wiki:GENIExperimenter/Tutorials/GENIExperimentEngine/Finish Next: Teardown Experiment] =