Changes between Version 15 and Version 16 of GENIExperimenter/Tutorials/GENIExperimentEngine/Execute
- Timestamp:
- 03/16/15 12:19:33 (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GENIExperimenter/Tutorials/GENIExperimentEngine/Execute
v15 v16 34 34 == 1. Experiment with various Ansible modules: ping, shell, setup == 35 35 36 We will first get familiar with some basic Ansible commands using the command-line interface.36 We will first get familiar with some basic Ansible tasks using the command-line interface. 37 37 38 38 === (a) The ping module === … … 94 94 === (b) Get the container name === 95 95 96 Look at the variables collected by Ansible's setup module (step 1(c) above). Find one that holds the container name. Add a debug statementto your playbook, like the one in the starter playbook, to print out its value.96 Look at the variables collected by Ansible's setup module (step 1(c) above). Find one that holds the container name. Add a debug task to your playbook, like the one in the starter playbook, to print out its value. 97 97 98 98 === (c) Get the container IP address === 99 99 100 Look at the variables collected by Ansible's setup module (step 1(c) above). Find one that holds the container IP address. Add a debug statementto your playbook, like the one in the starter playbook, to print out its value.100 Look at the variables collected by Ansible's setup module (step 1(c) above). Find one that holds the container IP address. Add a debug task to your playbook, like the one in the starter playbook, to print out its value. 101 101 102 102 === (d) Get the host's public IP address === … … 104 104 This is a bit trickier: how to get the host's IP address? The IP address visible inside the slicelet (as reported in the variable ''ansible_eth0.ipv4.address'') is a private address -- it is not the control address of the host. There are a number of ways that you could discover the control address, including running '''dig +short''' on the host’s name (see if you can find a variable that contains the host's name; HINT: you need it to SSH into the slicelet) or by running '''curl''' against a webserver that reports the client’s externally visible address. 105 105 106 || [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''Pro Tip:''' The '''ansible''' command-line tool is a good way to try out Ansible commands before putting them in your playbook. Look at the examples in part 1 above. ||106 || [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''Pro Tip:''' The '''ansible''' command-line tool is a good way to try out Ansible tasks before putting them in your playbook. Look at the examples in part 1 above. || 107 107 108 || [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''Pro Tip:''' Usually in an Ansible playbook you reference a variable by surrounding it in double curly brackets: ''{{ ansible_eth0.ipv4.address }}'' ||108 || [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''Pro Tip:''' Usually in an Ansible playbook you reference a variable by surrounding it in double curly brackets: ''{{ ansible_eth0.ipv4.address }}''. You can see a couple of examples of how variables are referenced in tasks in [https://github.com/ansible/ansible-examples/blob/master/language_features/get_url.yml this playbook]. || 109 109 110 || [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''Pro Tip:''' 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 ''{{ varname }}'' or, for shell command output, ''{{ varname.stdout }}'' ||110 || [[Image(wiki:GENIExperimenter/Tutorials/Graphics:tip.png, nolink, 50px, bottom)]] || '''Pro Tip:''' 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 ''{{ varname }}'' or, for shell command output, ''{{ varname.stdout }}''. You can see an example of how to register a variable in [https://github.com/ansible/ansible-examples/blob/master/language_features/register_logic.yml this playbook]. || 111 111 112 112 === (e) Get the latitude and longitude for each node ===