Tech insights and news. Best served hot.

2017

May
17

Ansible Cloud Module and Libcloud Integration

Back in November 2016 we introduced our API, which allows you to manage your cloud servers automatically – directly from within your own application or deployment setup. With Ansible and Libcloud this just got even more comfortable: These two important open-source projects now support our API natively.

Ansible Cloud Module

Ansible is a platform for the orchestration and configuration management of applications, servers (especially Unix/Linux) and entire server farms. In addition to numerous other modules, Ansible allows you to interact with different cloud providers with its Cloud Modules – starting with version 2.3.0 it supports managing your servers at cloudscale.ch as well.

Creating a new server is like a walk in the park:

 
   - name: Start cloudscale.ch server
     cloudscale_server:
       name: my-shiny-cloudscale-server
       flavor: flex-4
       image: debian-8
       ssh_keys: ssh-rsa XXXXXXXXXX...XXXX ansible@cloudscale.ch
              

Apache Libcloud

Apache Libcloud is a Python library which abstracts the APIs of different IaaS providers. Libcloud enables you to access the resources of various cloud providers via a uniform Python syntax. Starting with version 1.5.0 Libcloud also includes a driver for the cloudscale.ch API to manage servers on our infrastructure directly from your source code.

Using Python and Libcloud you can create new servers with just a few lines of code:

 
   from libcloud.compute.types import Provider
   from libcloud.compute.providers import get_driver

   cls = get_driver('cloudscale')
   driver = cls(key='XXXXX')

   name = 'my-shiny-cloudscale-server'
   size = [ s for s in driver.list_sizes() if s.id == 'flex-4' ][0]
   image = [ i for i in driver.list_images() if i.id == 'debian-8' ][0]
   ssh_keys = [ open('id_rsa.pub').read().strip() ]

   node = driver.create_node(name=name,
                             size=size,
                             image=image,
                             ex_create_attr={'ssh_keys':ssh_keys})
              

Two tools, different areas of application

Ansible and its so-called playbooks are used to define and execute a sequence of tasks for system management. Therefore, Ansible has cleary defined areas of application: orchestration of IT processes, deployment of applications, or configuration management.

With Ansible and the Cloud Module it is possible to automate the whole process of setting up and operating highly available web services at cloudscale.ch – from creating virtual servers and deploying applications up to non-disruptive maintenance during operating system or application updates.

In contrast, Libcloud is a Python library. With Python as a universal programming language a wide range of applications can be implemented. So, Libcloud comes in handy whenever Python code is used to access cloud services. All of the included cloud providers are supported automatically without the developer having to write code for their specific integration.

Therefore, Libcloud is suitable wherever you use Python already – e.g. when directly integrated into your (web) application for more scalability, or in order to extend existing deployment and monitoring tools.

What the future holds

We are constantly working on new features for our cloud infrastructure and our API. In order to integrate these into Libcloud and Ansible, we are working with the respective open-source communities. For example, an integration into Ansible is planned for the recently introduced "Floating IP" feature.

 

A common advantage of cloud servers is that they can be deployed with just a few clicks. You can go one step further now: automate your server deployment with Ansible or Libcloud – no need to click at all.

Server setup made easy!
Your cloudscale.ch team

 

PS: We believe that an integration of the cloudscale.ch API into Terraform would be valuable as well. What's your take on this?

More news. Further insights.

Try it yourself and launch a Swiss Linux server today!