Image OpenLogic Blog Ansible Architectures and Ansible Orchestrations
December 11, 2019

Overview of Ansible Architecture and Ansible Orchestrations


Ansible is an open source technology popular among DevOps teams looking to improve productivity and automate IT processes. Ansible architecture is configured to work as an automation engine between inputs and outputs, and Ansible orchestration allows you to create and automate a playbook for orchestration. 

In this blog, we share an overview of Ansible architecture and how Ansible orchestrations work.

Back to top

What Is Ansible and How Does It Work?

Ansible is an open source orchestration engine that automates cloud provisioning, configuration management, application deployment, intra-service orchestration, and many other IT needs. Ansible works by connecting your nodes and pushing out smaller programs called Ansible modules.

Back to top

What Is Ansible Architecture?

Ansible architecture is set up to work as an automation engine between inputs and outputs. The inputs are CMDS, users, private/public cloud, and the Ansible playbook. The outputs are hosts and network.

Here’s a high-level illustration of an Ansible architecture:

Image showing Ansible architecture example
Back to top

What Is Ansible Orchestration?

Ansible orchestration allows you to create and automate a playbook for orchestration. Then you can use the playbooks to deploy your Ansible orchestration. 

Real-world app-deployment stacks involve lots of different classes of systems and environments, all working in concert. To really deliver seamless orchestration, you need an outstanding workflow engine that also provides tools for managing application configuration and deployments. 

At a very high level, here’s how the Ansible orchestration engine works:

  • You use the simple YAML language to write a playbook, which maps out the steps in your orchestration.
  • The Ansible open source orchestration engine automates your playbook.

Your playbooks, which are managed by the Ansible orchestration engine, can:

  • Specify the inventory or the machines involved in your orchestrations.
  • Use APIs written in Python to enable additional connection types, callbacks, and server behaviors.
  • Include ready-to-go modules for integrating with hundreds of technologies and services, as well as those that you write in any language that can return JSON.
  • Use plugins to enable automation steps such as actions, tests, and connections with caches and inventories.

And as it orchestrates playbooks, Ansible connects with networks and hosts.

Benefits of Ansible Orchestration

Learn why and how to use Ansible for DevOps — and maximize the benefits of an Ansible orchestration.


Back to top

Ansible Use Cases

Below are some real-world examples of how Ansible can be used in enterprise settings.

Integrating Testing With Rolling Upgrades

The key to learning how to use Ansible properly is to study the requirements of its design-principle needs for seamless orchestration. One of the key design goals of a seamless orchestration is ensuring rolling upgrades with zero downtime. And to do this, you’re going to need to integrate testing with your rolling upgrades.

As we see in the following code-snippet sample, it is possible to define pre_tasks and post_tasks for testing checks for managing LB pool entries.

--- - hosts: webservers serial: 5 pre_tasks: - name: take out of load balancer pool command: /usr/bin/take_out_of_pool {{ inventory_hostname }} delegate_to: roles: - common - webserver tasks: - script: /srv/qa_team/ --server {{ inventory_hostname }} delegate_to: testing_server post_tasks: - name: add back to load balancer pool command: /usr/bin/add_back_to_pool {{ inventory_hostname }} delegate_to: 

Dynamic Inventory at Scale

You can use Ansible to maintain control over dynamic inventories with an open source cloud platform. Here is an example of inventory orchestration with Openstack: wget py chmod +x --verify near real-time with ansible -i all -m ping sudo cp /etc/ansible/hosts Download the sample configuration file, modify it to suit your needs and copy it to /etc/ansible/openstack.yml wget vi openstack.yml sudo cp openstack.yml /etc/ansible/ --test /etc/ansible/hosts --list --refresh the inventory or clear cache to minimize repeated REST/api calls ./ --refresh --list

Hybrid-Cloud Orchestration

With Ansible, you can create hybrid-cloud orchestrations that function seamlessly! That’s because Ansible can use multiple inventory sources from multiple cloud providers at the same time. And you can mix both dynamic and statically managed inventory sources in the same Ansible run.

Related Reading: What Is Enterprise Cloud?


So how do you know whether your orchestrations are working? Take advantage of Ansible’s automated notification options. You can configure  real-time notifications that alert you about the success and failure of tasks via Slack, email, and even IoT devices. 

For example, here is a sample of how simple the code is to set up notifications via Slack:

- name: Send notification message via Slack all options slack: token: thetoken/generatedby/slack msg: '{{ inventory_hostname }} completed' channel: '#ansible' thread_id: 1539917263.000100 username: 'Ansible on {{ inventory_hostname }}' icon_url: link_names: 0 parse: 'none' delegate_to: localhost

Here is sample code that sets up notifications using old-fashioned emails:

- name: Sending an e-mail using Legacy SSL to the remote machine mail: host: localhost port: 25 to: John Smith <> subject: Ansible-report body: System {{ ansible_hostname }} has been successfully provisioned. secure: always

This code sends alerts via IoT devices:

- mqtt: topic: 'service/ansible/{{ ansible_hostname }}' payload: 'Perforce it at {{ ansible_date_time.iso8601 }}' qos: 0 retain: False client_id: ans001 delegate_to: localhost

Continuous Integration

Now that you have an automated way to deploy updates to your application, how do you tie it all together? A lot of organizations use a continuous integration tool like Jenkins or Atlassian Bamboo to connect development, test, release, and deploy steps. You may also want to use a tool like Gerrit to add a code review step to commits to either the application code itself, or to your Ansible playbooks, or both.

Back to top

How to Create an Ansible Module and Command Set

Once you have mastered the key Ansible concepts, you might feel encouraged to create your own module and command set. Just be sure to check the new Ansible module repository on GitHub first, because your idea might already exist.

And remember to have the proper include within your module, as shown!

import ansible.module_utils.basic and execute! run_command(args, check_rc=False, close_fds=True, executable=None, data=None, binary_data=False, path_prefix=None, cwd=None, use_unsafe_shell=False, prompt_regex=None, environ_update=None, umask=None, encoding='utf-8', errors='surrogate_or_strict', expand_user_and_vars=True, pass_fds=None, before_communicate_callback=None)

Ansible Playbooks Backed by Support

Want to save time with Ansible architecture and orchestration? Leverage OpenLogic's Ansible playbooks. Our team of experts can help you configure, deploy, and provision your solution using our proven playbooks.

Get Support for Ansible

Additional Resources

Back to top