Ansible Tutorial


Hi today we will look to a system management automation tool named ansible. There is a lot of tool in this category but ansible is different with being agentless. Yes you read it right it is clientless and developed in python  language. Ansible architecture is very simple which made by a manager which must be linux and the systems managed which may be linux, bsd or windows. There are some differences in windows but it is not a problem after setup ansible. All systems managed by the same way. In linux and bsd connection made over ssh but in windows rmi protocol. This is enough lets start typing commands.

Install Ansible

Firstly we use fedora for manager and we should install ansible only on this system. Below command install ansible on the manager

Passwordless Connection

And then create ssh-id if it doesn’t exist. We can skip key generation questions with enter without giving any value.

Than we will install the keys to the remote managed system with ssh-id-copy command. Now we are ready to use ansible in simple way.

LEARN MORE  Linux Su Command Tutorial With Examples

Inventory and Hosts

Add this host ( to the ansible host inventory . Here myex is group name which covers hosts listed below. For now I just add one host

Ping Hosts and Check Connectivity

Now we can use ansible. We use ping module with -m option ans by specifying group name. We can use all for all inventory hosts.

Run Ad Hoc Command

We can specify pure commands to run on remote system with -a option.

If we need to debug ansible work we can use -vvv flags where count of v decides the debug level. As you can see below connection username and remote module is specified and than ssh connection is made with specified parameters if you have a problem with ssh connection you can find detailed info about the problem here. There is ansible verbs EXEC, PUT etc.

We can use sudo privileges on remote system with –sudo and specify sudo user with –sudo-user .

LEARN MORE  How To Get Ubuntu, Debian, Kali Release Version?

Ansible Configuration

Because ansible use ssh we can disable ssh host key checking by uncommenting below line

LEARN MORE  Introduction To Squid

Sometimes there are a lot of systems to manage and run commands. We can make ansible work parallel with -f option

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)