What Is Ansible?
Ansible is NO.1 Configuration management tool
Ansible is an Open source IT Automation tool. Mainly used to automate configuration management activities.
If we want to install software/update patches in 1 machine then it is easy and may take 10 minutes to do this task. But think that, we need to do the same activity on 12 Machines, then it would take 2 hours of effort. If we automate the same task using ansible, we will save time and there is no scope of human error and our Infra configuration would be as code. We can modify and can reuse the same.
Using Ansible, we can automate almost all the regular IT tatsks/process.
- Automate daily and repetitive tasks
- Application deployments
- Installation of softwares
- Patching of softwares
- Any configuration changes related to any Application or any softwares.
- To improve security and compliance
Why Ansible is so popular?
- It is an Open source, i.e. free to use
- Easy to learn and automate.
- It is agent less. Hence no headache of maintaining agents.
- Easy to install, anyone can install and start working on ansible within short time compared to its competitors.
- It has great community support, after ansible was acquired by redhat.
How to install Ansible on laptop?
Steps for Mac
Run below command to install it pip curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py $ python get-pip.py --user Run below command to install Ansible $ python -m pip install --user ansible Or install Ansible using brew brew install ansible
Steps for Linux
Below is the command to run on RHEL sudo yum install ansible Below is the command to run on Ubuntu $ sudo apt update $ sudo apt install software-properties-common $ sudo add-apt-repository --yes --update ppa:ansible/ansible $ sudo apt install ansible
Steps for Windows
As of now, Ansible cannot work natively on a Windows host. So there is no direct way to install Ansible on Windows OS. However, there are different ways to use Ansible on Windows for practice purposes.
- Using Cygwin and then installing ansible
- Using a Linux Virtual Machine via Virtual Box and then installing ansible.
What are all the basic commands of Ansible?
- ansible localhost -m ping
- This is to check if the Ansible installation is good.
- This runs single command
- It runs the ping command on the local host
- ansible-playbook playbooks/PLAYBOOK_NAME.yml
- The playbook is a list of plays, with each play performing multiple tasks.
- ansible-playbook playbooks/PLAYBOOK_NAME.yml –tags firsttask
- Used to run only specific tasks.
- In this command it runs all tagged function by firsttask name.
- ansible-playbook playbooks/PLAYBOOK_NAME.yml –skip-tags secondtask
- Used to skip specific tasks.
- This command skip all tagged tasks named secondtask.
Reference urls of Ansible