A (soon-to-be) set of Ansible modules to manage vm/storage/networks on Synnefo-based infrastructures.
- synnefo_compute: Ansible module to interact with the compute service ('Cyclades')
An Ansible module that lets you manage Virtual Machine instances on Synnefo-based infrastructures
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
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:
Refers to the VM's name. It can also refer to the desired name of a new VM to be created.
Refers to the desired state that the module execution must lead. As far as VMs are concerned this can mean:
state=presentensure that the specified VM will be present after execution. If not already present, create it.
state=absentensure that the specified VM will be absent after execution. If not already absent, delete it.
state=activeensure that the specified VM will be active after execution. If not already active, start it.
state=stoppedensure that the specified VM will be stopped after execution. If not already stopped, shut it down.
If set to true, module will pause & wait for the VM operation to be completed
integer referring to a specific flavor that's used to describe the VM (e.g. num of vcpus, ram etc.).
name of a specific image used to boot the VM
user's authentication token
Refer to a specific VM by id, instead of using
Refer to a specific image by id, instead of using
Refer to a specific flavor by name, instead of using
Filename of ssh key to be injected during VM's creation process
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
# 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'