Welcome to Ansible Learning. In this post we shall know how to install and setup Ansible along with some basic understanding about ansible and its working.
Firstly let us get answers to few questions about Ansible.
- What is Ansible?
- Why do we need to learn Ansible?
- How does Ansible works?
What is Ansible?
Ansible is a configuration management tool. It can do more than just configuration management. It can do application deployment, software provisioning and lot more. It can do IT orchestration and provide scalability at ease.
Why do we need to learn Ansible?
Since ansible can do a lot of things like deployment, management it is the ideal choice for whoever want to learn tools related to deployment. It would be really helpful to do Continuous deployment.
- Its agentless
- Parallel Execution
- Easy to Use
- Modular
How does Ansible Work?
Ansible basically works by doing SSH to the machines. In ansible we use playbooks which does the job for us. Playbook is nothing but a YAML file which is fed to Ansible to do the job we need ansible to do. It is through this playbook (YAML file) we communicate with ansible. We also have ansible command line but as we go for complex tasks we use playbooks.
To get started we need to install Ansible on a control node (which could easily be a laptop) and it can manage an entire fleet of remote machines from that central point.
Control Node is like the machine from where we intend to manage all the machines (target machines or hostmachines). We need ansible in control node.
Note: Ansible need not be installed on the machines that we intend to manage( target machines or hosts). It needs to be installed on the control node only. Windows machine as control node is not supported.
Installation Guide
On Fedora:
$ sudo dnf install ansible
On RHEL and CentOS:
$ sudo yum install ansible
RPMs for RHEL 7 and RHEL 8 are available from the Ansible Engine repository.
To enable the Ansible Engine repository for RHEL 8, run the following command:
$ sudo subscription-manager repos --enable ansible-2.9-for-rhel-8-x86_64-rpms
To enable the Ansible Engine repository for RHEL 7, run the following command:
$ sudo subscription-manager repos --enable rhel-7-server-ansible-2.9 rpms
RPMs for currently supported versions of RHEL, CentOS, and Fedora are available from EPEL as well as releases.ansible.com.
You can make an RPM from source by using make rpm
command. You can distribute and install.
$ git clone https://github.com/ansible/ansible.git
$ cd ./ansible
$ make rpm
$ sudo rpm -Uvh ./rpm-build/ansible-*.noarch.rpm
On Ubuntu you can install by apt
Ubuntu builds are available in a PPA here.
To configure the PPA on your machine and install ansible run these commands:
$ sudo apt update
$ sudo apt install software-properties-common
$ sudo apt-add-repository --yes --update ppa:ansible/ansible
$ sudo apt install ansible
We need Python to run Ansible. Ansible can be installed through PIP by running the below command
$ pip install ansible
This will install all the dependent packages as well. If you don’t have Python you can install it from here.
Once the installation is completed you can check the installation by running the command ansible --version