Here's How We Embedded Python Into Our CLI Download PackagesPosted By: Gil Zellner on September 29, 2016
Installing new apps is fun. You get to play around with a new tool, which to us engineers is like a toy. We always want to try the latest and the greatest, and we love toying around with all the new features. But installation isn’t always a breeze, especially in Linux, where asking you to compile your own tools is rather common, or editing makefiles, etc.
So we tried to make our installation process a little bit easier.
In version 3.4, we introduced Cloudify CLI Packages with embedded Python. Now, it doesn’t matter if your version of Centos 6.5 has Python 2.7 or not, or you use a Golden Image with no compilers. We bring our Python with us, packaged to install on your system with almost no prerequisites.
You don’t have to compile anything!
Join our Kubernetes webinar - Moving Monoliths to Microservices. Go
We used Omnibus to create self-contained packages which you can simply <code>rpm -i</code>, so you can start playing around with Cloudify more easily, instead of having to deal with prerequisites.
We also brought back Debian packages which are tested on Ubuntu. Another neat thing is that, plugins install into this environment so you don’t put things in your system Python which you didn’t intend to.
The next logical step is making Cloudify Manager install more easily via the same system. We built upon the process created in the CLI to make manager packages install more easily. This will be available in the next Cloudify release.
Each component now comes with its own Python environment so that you can install a manager on your own Golden Image, even if it isn’t exactly what we planned for, but you are limited, of course, to Centos 7 / RHEL 7 variants.
So how did we do it?
We started out with a sample Python application on Omnibus.
This is a simple example on how to package a Python application this way. The guide, by the way, from lusis is very amusing as well as effective.
We then started adding our own components as if we were installing a local copy. We do this by adding more modules to the same project.
The Omnibus syntax is rather simple and, for the things you don’t know, you can always use shell encapsulation or Ruby:
Consider this akin to the way many companies are creating immutable AMI’s by simply installing their software the same way they did earlier, but keeping a copy of the new, “clean” install.
We do this for each module in the package:
And put them all together in the project file:
At the end of the process you get something like this:
And you are done! You now have an rpm, or deb, or even pkg of your application, which can run in many places without modification.
Overall, we are making an effort to make Cloudify easier for you to install and use, and this is part of that effort. We also encourage you to read through the code and contribute, since Cloudify is all about open source and community participation.