Saturday 17 June 2017

Ansible Installation

To work with ansible we require some basic Linux commands. Ansible can be installed on linux based systems. Ansible has different versions.I am using  Ansible 2.3 .We can install Ansible in  different ways.In this tutorial i will tell you installation for linux based systems.

First we need to install a repository  "epel-release" before installing ansible. epel-release is a repository with tuns of packages for yum.Then just see the files in the epel-release repository you can see different files in that.
To install epel-release 


To install ansible

Now the actual step comes in  .It will installs latest version of  ansible in your system. goto ansible directory you will see some files.






In above ansible.cfg is called  main configuration file for anisible and inventory file(hosts) contains info about hosts (Managed Machines Ipaddress, hostname). To open the host file we need give the command as follow.

[root@server1 ansible]# vi hosts

It will display a file with a lot of stuff commented.in that give your managed machine name and ipaddress to work with it.you can give any number of machines and you can group those machines also.
Ansible Inventories:
 Ansible is used for managing multiple servers in the Infrastructure. The collection of hosts is known as “Ansible Inventory”.

[root@server1 ~]# more /etc/ansible/hosts

The inventory file can be in any format , The format for /etc/ansible/hosts like (one of Ansible’s defaults) and looks like below.These are the hostnames of the servers i am working with.To know the hostname of your managed machines type the command hostname .These hostnames should be fully qualified domain name(fqdn) like below.

It is ok to put systems in more than one group, for instance a server could be both a webserver and a dbserver. 

if things are not running on the default port then you can provide port number also as follow:
server3.abc.com:5309
Suppose you have static IPs and want to set up some aliases . You can also describe hosts like this:
server2 ansible_port=5309 ansible_host=192.0.2.50
If you have a lot of hosts having the same patterns you can do this:
[webservers]
server1[01:50].abc.com
Host Variables:
it is easy to assign variables to hosts that will be used later in playbooks.These variables known as host variables.
[webservers]
server2 http_port=80 maxRequestsPerChild=808
server3 http_port=303 maxRequestsPerChild=909
Group Variables:
Variables can also be applied to an entire group at once.
If you face any problem while practicing feel free to comment it and Bookmark this blog for quick reference.We will try to help you.

If you like this share with your friends.Follow us by email for our new posts 

Thanks

Devops Desk Team

No comments:

Post a Comment