From smoothly automating away hours of IT drudgery to providing configuration management of machines on site or in the cloud, Ansible is a popular platform for modern software deployments.
At the end of our two-part series on OpenStack, we briefly mentioned that Ansible is one of the technologies that can be used to manage OpenStack, in addition to the Python OpenStack APIs and the OpenStackClient (which is written in Python).
Python, as it turns out, is an integral part of Ansible.
What Ansible Does
In a nutshell, Anisble is configuration management and IT automation software which runs on a designated system, called a controlling machine. The controlling machine in turn manages other systems, referred to as nodes. This managing includes:
- Configuration of network interfaces
- Installing and configuring additional software (like service daemons)
- Starting, stopping, adding, removing, and reconfiguring elements of a software stack in the correct order (orchestration)
How Ansible performs this is what sets it apart form simliar software like Chef and Puppet: instead of requiring software (agents) running on the nodes—consuming the node's resources and continuously polling the controlling machine—Ansible is agentless.
How Ansible Uses Python
Instead of having software agents constantly running on the nodes, Ansible pushes packages of executable code to the nodes. Those code packages are called modules and can be written in any language which supports JSON, including Python (and other scripting languages like Ruby and Perl). SSH is used to both push out the modules to the nodes and to transport information from the nodes back to the controlling machine. Thus, Python and SSH are Ansible's only two required dependencies.
Ansible itself is written in Python, as evidenced by it's GitHub repo. Python is also the language used for the APIs which developers can use to extend Ansible's connection types (SSH is the default, but not the only choice) and add new server-side functionality.
When it comes to everyday use, Python mainly works behind the scenes. That's because Ansible doesn't requre users to write any scripts. The modules which do the work are called indirectly from playbooks, the simple files in YAML format which tell the controlling machine what to do the one or more nodes.
Compatibility and Flexibility
Although Ansible controlling machines must be Linux or UNIX systems, the managed nodes can be computers running Windows. In that case, PowerShell remoting is used in place of SSH. Since Python is an interpreted, cross-platform language, Ansible otherwise works the same as it would on UNIX-like systems.
Automating Orchestration
But let's finish where we began: with OpenStack. Ansible's powerful, yet simple orchestration abilities is a perfect match for the complexity which accompanies OpenStack's power. Orchestration is the correct scheduling and synchronizing of critcal tasks like bringing up and tearing down the individual systems, services, and interfaces that comprise a software solution stack. For modern large-scale (read: enterprise) software deployment, this is just as necessary as managing the configuration of those individual pieces.
Ansible relies on Python not just for much of it's own codebase and the modules by which it automates previously time-intensive workflows, but also for enabling a worldwide community of developers to extend is capabilities through various APIs. Python is a big contributor to Ansible's towering presence.
Copyright © Python People