Version 20 (modified by, 5 years ago) (diff)


Title of the Experiment

Image Map

4. Configure and Initialize

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.

  1. Create your Ansible inventory file:

    On your local machine:

    $ readyToLogin MYSLICE --useSliceAggregates --ansible-inventory -o
    $ cat inventory

    Here example output of running these commands:

    $ readyToLogin ansible --useSliceAggregates --ansible-inventory -o
    Host info saved in inventory file: /Users/jdoe/projects/GENI/hellogeni/inventory
    $ cat inventory
    client  ansible_ssh_port=33850
  2. Check to see if your nodes are up and ready.

    This command uses the ping module to ping the specified nodes (in this case all) listed in the inventory file:

    $ ansible all -m ping -i inventory

    Example output showing all of the nodes responding to ping:

    $ ansible all  -m ping -i inventory
    client | success >> {
        "changed": false,
        "ping": "pong"
    server | success >> {
        "changed": false,
        "ping": "pong"
  3. Try using the ping module in Ansible to only ping server or client by replacing all in the above with server or client.

5. Execute Experiment

Tip The following are some example Ansible commands. `-s` tells Ansible to use `sudo` when executing the command.

apt module is used to installed packages:

ansible [-i inventory] [all/server/client] -s -m apt -a "name=apache2 update_cache=yes"

shell module is used to execute an arbitrary shell command:

ansible [-i inventory] [all/server/client]  -s -m shell -a "/usr/sbin/a2enmod status"

file module is used to manipulate files:

ansible [-i inventory] [all/server/client] -s -m file -a "path=/var/www/html state=absent"

synchronize module is an implementation of rsync and is used to efficiently synchronize files between your local machine and the node:

ansible [-i inventory] [all/server/client] -s  -m synchronize \
    -a "src=website/index.html dest=/var/www"

lineinfile module is used to see if an arbitrary line exists in a file:

ansible [-i inventory] [all/server/client] -s  -m lineinfile \
     -a "line='ExtendedStatus On' dest=/etc/apache2/conf.d/extendedstatus create=yes state=present"

service module is used to start/stop/restart/etc services:

ansible [-i inventory] [all/server/client] -s  -m service -a "name=apache2 state=restarted"
  1. Using the above Ansible modules, reproduce the steps in the HelloGENI install script. As you find a command that works, carefully copy it into a text file. We are going to use these commands for the next step.
  2. Now create an Ansible Playbook using the above steps.

6. Analyze Experiment


Next: Finish