Ansible is easier than ever.
There are a lot of processes you can build with Ansible, which can be used as an automation tool or even a manual playbooks executor. Most of the users implement with Ansible Continuous Deployment/Delivery processes, but you can build practically every process you want to run. Ansible playbooks can be run automatically (e.g. webhooks) or manually, it’s all up to you and your needs.
A quick overview
Ansible is an open-source software provisioning, configuration management, and application-deployment tool. It runs on many Unix-like systems, and can configure both Unix-like systems as well as Microsoft Windows. It includes its own declarative language to describe system configuration. Ansible was written by Michael DeHaan and acquired by Red Hat in 2015. Ansible is agentless, temporarily connecting remotely via SSH or Windows Remote Management (allowing remote PowerShell execution) to do its tasks.
Basic concepts
- Inventory: Ansible works against multiple managed nodes or “hosts” in your infrastructure at the same time, using a list or group of lists know as inventory.
- Modules: Ansible ships with a number of modules (called the ‘module library’) that can be executed directly on remote hosts or through Playbooks. Users can also write their own modules. These modules can control system resources, like services, packages, or files (anything really), or handle executing system commands.
- Playbooks: Playbooks are Ansible’s configuration, deployment, and orchestration language. They can describe a policy you want your remote systems to enforce, or a set of steps in a general IT process.
- Tasks: The goal of a play is to map a group of hosts to some well defined roles, represented by things ansible calls tasks. At a basic level, a task is nothing more than a call to an ansible module.
- Roles: Roles are ways of automatically loading certain vars_files, tasks, and handlers based on a known file structure. Grouping content by roles also allows easy sharing of roles with other users.
- Templates: A template in Ansible is a file which contains all your configuration parameters, but the dynamic values are given as variables. During the playbook execution, depending on the conditions like which cluster you are using, the variables will be replaced with the relevant values.
Examples for Ansible code
- Loop on a list: https://www.devopsnipp.com/snippets/Ansible-loops-on-list
- Tagging: https://www.devopsnipp.com/snippets/Ansible-tags
- Reboot & wait: https://www.devopsnipp.com/snippets/ansible-reboot-and-wait.yaml
- Git clone: https://www.devopsnipp.com/snippets/Ansible-git-clone-task
For more snippets, search “Ansible” in https://DevOpsnipp.com/explore.
Ansible Editor
I’ve created an online editor with a huge modules registry behind, with an automatic sync from Ansible documentation to the editor’s Firebase DB. This editor helps me a lot, so I decided to publish it to the community for Free!
Using Ansible-Editor, you’ll be able to build playbooks easily and quickly, all you need to do is to choose the module you need from the modules list.