Version 15 (modified by, 4 years ago) (diff)


Appendix: Installing software using the Ansible Configuration Management tool


To run this exercise, you will need two pieces of software. If you haven't already, get or install these now:

  1. omni installed on your local machine (instructions), and
  2. ansible installed on your local machine (find the instructions for your package manager here).



2. Establish the Environment

  1. To run this exercise, you will need an account and two pieces of software. If you haven't already, get or install these now:
    1. a GENI Portal account (instructions),
    2. omni installed and configured on your local machine (instructions), and
    3. ansible installed on your local machine (find the instructions for your package manager here).

      Windows users should do the following steps

      Tip Before reserving their resources, Windows users should have followed the instructions for setting up a separate GENI node for running Ansible.
  2. Download the Ansible playbook, webpages, etc needed to configure the nodes.

    Use wget to download the tarball of files onto your local machine and use tar to uncompress it:

    tar zxvf XXXXXX.tar.gz

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

    Example output of running these commands:

    $ readyToLogin MYSLICE --useSliceAggregates --ansible-inventory -o
    Host info saved in inventory file: /Users/jdoe/projects/GENI/hellogeni/inventory
    $ cat inventory
    host-2  ansible_ssh_port=31291
    host-1  ansible_ssh_port=31290
    rt-1  ansible_ssh_port=31292
    Tip Windows users should copy their 'inventory' file onto their node running the ansible client.
  2. Be sure your private key has been added to your SSH agent:
    ssh-add /path/to/your/private/key
  3. 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 -i inventory all -m ping 

    Example output showing all of the nodes responding to ping:

    $ ansible -i inventory all -m ping 
    server-1 | success >> {
        "changed": false,
        "ping": "pong"
    host-1 | success >> {
        "changed": false,
        "ping": "pong"
    rt-1 | success >> {
        "changed": false,
        "ping": "pong"
    host-2 | success >> {
        "changed": false,
        "ping": "pong"
  4. 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.
Tip Ansible commands can be collected into files called Playbooks. Playbooks are in a configuration file format called YAML which is very straightforward. In particular, Ansible Ad Hoc commands easily map to commands used in an Ansible Playbook.

The Playbook to configure the server node is as follows:

- name: Configure client
  hosts: client
  sudo: True
   - name: install apache2
     apt: name=apache2 update_cache=yes
   - name: install iperf
     apt: name=iperf update_cache=yes
   - name: copy scripts into /local with permissions 755
     synchronize: src=scripts dest=/local mode=755

Do these commands look like the Ad Hoc commands you came up with in the previous step?

Put the above content in a file called server.yml.

Run the playbook with the following command on the local machine:

ansible-playbook server.yml -i inventory
  1. Browse to the server node. Click on the nmap link.
  2. After some of your neighbors have brought up their nodes, run the following command:
    ansible-playbook update-map.yml -i inventory
  3. You should see more nodes found by the nmap scan.