Introduction To Ansible Tutorial

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/introduction-to-ansible-tutorial/
PINTEREST
PINTEREST
INSTAGRAM

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 agent-less. Yes you read it right it is client-less 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

Ubuntu, Debian, Mint, Kali

Ubuntu, Debian, Mint, Kali
Ubuntu, Debian, Mint, Kali

Fedora, CentOS, RHEL

Password-less Connection

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

Password-less Connection
Password-less Connection

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.

Inventory and Hosts

Ansible uses its hosts file which is named as Inventory to get information about remote systems. We can group hosts in this inventory file.

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

LEARN MORE  How To Specify Host, Port and Protocol For Tcpdump?

Inventory and Hosts
Inventory and Hosts

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.

Ping Hosts and Check Connectivity
Ping Hosts and Check Connectivity

Run Ad Hoc Command

We can specify pure commands to run on remote system with -a option. Ad Hoc command provides us the ability to run a command on the remote systems. In this example we will print the passwd file with cat command.

Run Ad Hoc Command
Run Ad Hoc Command

Debug Ansible and Verbose Output

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.

Debug Ansible and Verbose Output
Debug Ansible and Verbose Output

Run Sudo On Remote System

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

Ansible Configuration

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

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

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/introduction-to-ansible-tutorial/
PINTEREST
PINTEREST
INSTAGRAM