Managing IT infrastructure is difficult. Imagine you have 100 computers in your environment and you need to install Firefox browser on all the systems. How will you do it? You certainly cannot log in to every system to install Firefox. That’s where Ansible comes in.
In this blog, we will cover the following:
- What is Ansible?
- Who should learn Ansible?
- Why do we need Ansible?
- What is IaC?
- What is Ansible tower?
- Ansible Architecture
- Use cases
- Conclusion
- FAQ
What is Ansible?
Ansible is a simple configuration management and IT automation engine for multi-tier deployments. It automates both cloud and on-premise provisioning & configuration. It automates cloud provisioning. Rather than managing one system at a time, Ansible uses a model that inter-relates the entire IT infrastructure and enables you to manage everything using something called an Infrastructure as Code (IAC) approach. Ansible is secure and agentless. It relies on OpenSSH and the code written in YAML format. Ansible nodes are run on Unix systems but they can be used to configure changes across Unix as well as Windows systems.
Who should learn Ansible?
Ansible is a part of the DevOps stack. Ansible means automation. Ansible seamlessly connects workflow orchestration with configuration management and provisioning deployment. Ansible has various use cases in Provisioning, Configuration Management, Application Deployment, Continuous Deployment, Automation, and Orchestration. So, if you are looking forward to a career in DevOps, IT automation, and managing cloud infrastructure then Ansible is a must-have.
Why do we need Ansible?
- Ansible allows you to write scripts that describe the state of your system. That means once written these scripts are re-usable and reliable.
- Ansible scripts are written in YAML. Ansible uses the same tools that are normally used for administration in Linux systems.
- Ansible gives you the power to manage multi-tier deployments.
- Ansible can be easily introduced to the existing environment.
- Ansible is built for the cloud. Modules included in Ansible help manage deployments across AWS, Azure, and other cloud services.
What is IaC (Infrastructure as Code)?
Infrastructure as Code (IaC) means Idempotency. Meaning, operations called more than once with the same parameters have no additional effect. Some tools that are developed on the IAC approach include Ansible, Terraform, AWS Cloud Formation, ARM templates. Infrastructure as Code IaC can be approached in 2 ways:
- Declarative: Declarative IaC determines the desired state of the system. Resources and properties applied to the resource once the user specifies the desired state. An example of a tool that uses a declarative approach is AWS CloudFormation.
- Imperative: Imperative IaC specifies specific commands needed to achieve the desired configuration. The user specifies the desired commands and the commands are executed to bring the system to the desired state. An example of a tool that uses an Imperative approach to IaC is AWS CLI
What is Ansible Tower?
Ansible Tower allows you to centralize and control the entire IT infrastructure with a visual dashboard. It displays everything going on in your ansible environment in real-time. Features including role-based access control (RBAC), job scheduling, inventory tracking across multiple cloud providers can be easily organized and automated.
Ansible Architecture:
- Modules: Modules are script-like programs written to specify the desired state of the system. These are typically written in a code editor. Modules are written by the developer and executed via SSH. Modules are part of a larger program called Playbook. Ansible module is a standalone script that can be used inside an Ansible Playbook.
- Plugins: Plugins are pieces of code that enhance the core functionality of Ansible. Plugins execute on the control node.
- Inventory: Ansible reads information about the machines you manage from the inventory. Inventory is listed in the file which contains IP addresses, databases, and servers.
- Playbook: Playbooks are files written in YAML. Playbooks describe the tasks to be done by declaring configurations in order to bring a managed node into the desired state.
Also Check: Our blog post on Azure DevOps Environments.
Example of Ansible Playbook:
This playbook ensures a web server is always running an updated version of Apache Webserver.
--- - hosts: webservers vars: http_port: 80 max_clients: 200 remote_user: root tasks: - name: ensure apache is at the latest version yum: name=httpd state=latest - name: write the apache config file template: src=/srv/httpd.j2 dest=/etc/httpd.conf notify: - restart apache - name: ensure apache is running (and enable it at boot) service: name=httpd state=started enabled=yes handlers: - name: restart apache service: name=httpd state=restarted
Check Out: Our blog post on Microsoft DevOps Certification Path.
Ansible Use Cases:
- Provisioning: Provisioning is creating new infrastructure. Ansible allows for application management, deployment, orchestration, and configuration management.
- Continuous Delivery: Ansible provides a simpler way to automatically deploy applications. All required services for a deployment can be configured from a single system. Continuous Integration (CI) tool can be used to run Ansible playbook which can be used to test and automatically deploy the application to production if tests are passed.
- Application Deployment: Ansible provides a simpler way to deploy applications across the infrastructure. Deployment of multi-tier applications can be simplified and the infrastructure can be easily changed over time.
- Ansible for Cloud Computing: Ansible makes it easy to provision instances across all cloud providers. Ansible contains multiple modules and allows to manage of large cloud infrastructure across the public-private and hybrid cloud.
- Ansible for Security and Compliance: You can define security policies in Ansible which will automate security policy across all machines in the network. Security roles once configured in an Ansible node will be embedded across all machines in the network automatically.
Also Check: Our blog post on Azure DevOps Engineer.
Conclusion:
Ansible is an open-source tool for provisioning, application deployment, configuration management. It enables Infrastructure as code (IaC). Ansible runs on Unix systems but it can be used to configure Windows as well as Linux. Ansible scripts are called Playbooks which consist of various modules. Ansible is an excellent tool to save time, money, and effort to automate tasks across multiple servers. Learning how to use Ansible to automate IT tasks is valuable to your Career and Organization.
FAQ:
1) What is Ansible and why it is used?
Ans: Ansible is an automation engine that automates repetitive, cumbersome, and complex tasks such as cloud provisioning, application deployment, and configuration management.
2) What is Ansible & How does it work?
Ans: Ansible works by connecting to other machines (nodes) and executes programs called modules. Modules are small programs that specify the desired state of the system. Ansible removes modules after execution.
3) Is Ansible a DevOps tool?
Ans: Ansible is the DevOps tool used for configuration management, automation, orchestration, and managing IT Infrastructure.
Related/References
- [AZ-400] Azure DevOps Certification Path
- [AZ-400] Roles And Responsibilities As An Azure DevOps Engineer
- [AZ-400] Microsoft Azure DevOps Certification Exam: Everything You Need To Know
- [AZ-400] Microsoft Azure DevOps Training: Step By Step Activity Guides/Hands-On Lab Exercise
- [AZ-400] Azure DevOps Services for Beginners
Next Task For You
If you are considering in-depth learning about Ansible in the coming days, then do join our WAITLIST and don’t miss an opportunity to attend a free class and gain a plethora of insights on the basics of Ansible.
Leave a Reply