Skip to content

auth-it-center/synnefo-ansible

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

synnefo-ansible

A (soon-to-be) set of Ansible modules to manage vm/storage/networks on Synnefo-based infrastructures.

Currently includes:

  • synnefo_compute: Ansible module to interact with the compute service ('Cyclades')

synnefo_compute

An Ansible module that lets you manage Virtual Machine instances on Synnefo-based infrastructures

installation

Module requires Kamaki client be installed. Kamaki is the official ~okeanos command line client.

You can download kamaki from the project homepage

Download synnefo_compute source file from here and place it inside ansible/library directory

a first example

Here's how creating a new VM using synnefo_compute module, looks like:

---
# Sample Ansible Playbook 
# Create a new VM using ansible module: synnefo_compute

 - hosts: example_host 
   user: example_user  
   sudo: no
   gather_facts: no

   tasks:

     - name: Ensure a VM is STOPPED - Shut it down if active
       delegate_to: 127.0.0.1
       synnefo_compute:
          name=my_brand_new_vm
          state=present
          wait=yes
          flavor_id=4
          image='Fedora'
          token='myApIaCcEssToKen'
          auth_url='https://accounts.okeanos.grnet.gr/identity/v2.0'


Playbooks that use synnefo_compute module can be executed locally. In order to execute a task locally use the parameter delegate_to: 127.0.0.1 (ref. example above).

Let's take a close look at each argument:

#####name

Refers to the VM's name. It can also refer to the desired name of a new VM to be created.

#####state Refers to the desired state that the module execution must lead. As far as VMs are concerned this can mean:

  • state=present ensure that the specified VM will be present after execution. If not already present, create it.
  • state=absent ensure that the specified VM will be absent after execution. If not already absent, delete it.
  • state=active ensure that the specified VM will be active after execution. If not already active, start it.
  • state=stopped ensure that the specified VM will be stopped after execution. If not already stopped, shut it down.

#####wait If set to true, module will pause & wait for the VM operation to be completed

#####flavor_id integer referring to a specific flavor that's used to describe the VM (e.g. num of vcpus, ram etc.).

#####image name of a specific image used to boot the VM

#####auth_url api authentication url of desired Synnefo infrastructure. The value defaults to ~okeanos service api authentication url

#####token user's authentication token

###more arguments...

#####id Refer to a specific VM by id, instead of using name

#####image_id Refer to a specific image by id, instead of using image

#####flavor Refer to a specific flavor by name, instead of using flavor_id #####ssh_key Filename of ssh key to be injected during VM's creation process

#####public_network During VM creation you can specify a public network in which your VM will try to automatically attach and obtain a floating ip.

  • public_network=network_id - specify a public network by using it's id integer
  • public_network=network_cidr - specify a public network by using it's subnet cidr
  • public_network=any - choose automatically an available network

query a flavor by specs

Instead of remembering a specific name or id for a flavor, user can provide the following specs as arguments during VM's creation process:

  • vcpus : number of virtual cores
  • ram: amount of ram
  • disk: amount of disk in GB
  • dtype: type of virtual disk to be used (default='drdb')

After all above arguments are specified, synnefo_compute will query infrastructure to find a matching flavor

more examples....

# Shutdown a VM

   synnefo_compute:
      name=my_running_vm
      state=stopped
      wait=yes
      auth_url='https://accounts.myexamplecloud.local/identity/v2.0'
      token='myApIaCcEssToKen'

# Start a VM

   synnefo_compute:
      name=my_stopped_vm
      state=active
      wait=yes
      auth_url='https://accounts.myexamplecloud.local/identity/v2.0'
      token='myApIaCcEssToKen'

# Delete a VM

   synnefo_compute:
      name=my_loved_vm
      state=absent
      wait=yes
      auth_url='https://accounts.myexamplecloud.local/identity/v2.0'
      token='myApIaCcEssToKen'

# Create a VM and provide specs

   synnefo_compute:
      name=vm_with_specs
      state=present
      image='Ubuntu Server'
      vcpus=1
      ram=1024
      disk=20
      dtype=drdb
      wait=yes
      auth_url='https://accounts.myexamplecloud.local/identity/v2.0'
      token='myApIaCcEssToKen'

#Create a VM and attach it to public network with id:555

synnefo_compute:
      name=testing_vm_1
      state=present
      wait=yes
      vcpus=1
      ram=1024
      disk=20
      dtype=drbd
      image='Ubuntu Server'
      token='myApIaCcEssToKen'
      auth_url='https://accounts.okeanos.grnet.gr/identity/v2.0'
      public_network='555'

dont forget to...

check out the exceptional documentation of Synnefo project and Ansible

About

Ansible Module to manage VMs in synnefo-based clouds

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages