What is Ansible: It is an open source popular IT automation engine that automates tasks that are either cumbersome or repetitive or complex like configuration management, cloud provisioning, software deployment, and orchestration.
It was founded by Michael DeHaan in 2013 and was later acquired by Red Hat in 2015.
It is used for the multi-tier deployments and it models all of IT infrastructure into one deployment instead of handling each one separately. There are no agents (yep, you heard it) and no custom security architecture is required to be used in the Ansible architecture. The deployment is simple plain English like language that is used in Ansible called YAML .
Why Use Ansible?:
It is simple, yet powerful automation tool, that anyone can use as long as you know how to use Linux (at least)
In Ansible the passwords are supported, However, you can use SSH keys with the ssh-agents as one of the methods to work with Ansible. You can create any user account and the root user is required. To configure what machines can access which hosts there is a module called “authorized_key”.
You can add machines to the Ansible in a simple text format and manage your inventory. It can use the inventory and variable information from other sources such as Rackspace, EC2, and Openstack, etc.
If you need to write your code then also you can use Ansible in languages such as Python, Ruby, and Bash, etc which return JSON. You can write your modules, API, and Plugins.
Ansible’s whole architecture is structured around the concept of idem-potency. The core idea here is that you only do things if they are needed and that things are repeatable without side effects.
- The feedback loop is accelerated at a faster rate
- The bugs are found sooner and not wait till the end
- Risk due to lack of sufficient knowledge is mitigated
- The deployments are reliable
- The IT infrastructure is coordinated
- The deployments are faster
- Need for automation
- Version control and configuration management
- Orchestration of the IT Infrastructure.
What are Playbooks in Ansible?
- Its a Plain-text YAML files that describes the desired state of something.
2. Human and Machine readable.
3. Can be used to build entire application environment.
What are Inventories in Ansible?
- Static lines of servers
2. Dynamic list of servers: AWS, Azure, GCP, etc.
4. Other custom things
What are modules in Ansible?
- There are Over 1000 modules provided by Ansible to automate. link
2. Modules are like plugins that do the actual work in Ansible, they are what gets executed in each playbook task.
3. Each module is mostly standalone and can be written in a standard scripting language (such as Python, Perl, Ruby, Bash, etc.)
What are roles in Ansible? & its benefits
- Roles are a way to group tasks together into one container. Its like a template of folders where you can paste your YAML code to keep things tidy in order to later reference or share with your team members.We could have a role for setting up Web Server, MySQL, configuring ip tables.
2. Roles makes it easy to configure hosts. Any role can be performed on any host or group of hosts such as:
- hosts: all
What are variables in Ansible?
There are many different ways to source variables:
3. Inventories (group vars, host vars)
4. Command line Discovered Variables
5. Ansible Tower
How to Run the Ansible Commands?
Ad-Hoc: Ansible <inventory> -m
AD-HOC Commands Examples:
Ansible Tower is a web-based interface for managing Ansible. One of the top items in Ansible users’ wishlist's was an easy-to-use UI for managing quick deployments and monitoring one’s configurations. Ansible management came up with Ansible Tower in response with centralized logging, auto scaling/provisioning call-backs, graphical inventory editing, and more.
- The Ansible Tower dashboard provides a heads-up NOC-style display for everything going on in your Ansible environment.
- Real-Time Job Status Updates : As Ansible automates across your infrastructure, you’ll see plays and tasks complete, broken down by each machine, and each success or failure, complete with output. Easily see the status of your automation, and what’s next in the queue.
- Multi-Playbook WorkFlows :You can build a CI/CD testing workflow that builds an application, deploys it to a test environment, runs tests, and automatically promotes the application based on test results. Set up different playbooks to run in case of success or failure of a prior workflow playbook. & much more benefits you can find here .
Thank you for reading, Please do Clap, Share & feedback as it keeps be motivated to learn and help others in the process.