Ansible Installation & Configuration on CentOS-7/8

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

What is Ansible ?

Ansible is a radically simple IT automation engine that automates cloud provisioningconfiguration managementapplication deploymentintra-service orchestration, and many other IT needs.

It is an agentless management tool and it doesn’t require any other agent to be installed on remote hosts, which makes it different from other similar tools like Puppet & Chef, both these tools need agent to be installed on remote host to manage them. Ansible communicates with their hosts by using SSH to manage them.

Ansible Architecture Diagram

Ansible Architecture Diagram

Ansible Terminology

Ansible Master Node: It is a Linux machine where we will be install Ansible tool to manage all other Linux servers centrally. This is also called as controller Node

Remote Host Inventory: It is a file in ansible master node, where we made entry of all the remote servers/devices which need to me managed by Ansible master node for deployment of application and services.

Playbook: These are basically Ansible script which are written in “YAML” language. We can write different playbooks as per our requirements. Playbooks contains

Installing Ansible on CentOS-7 and RHEL-7

To get Ansible for CentOS 7, first ensure that the CentOS 7 EPEL repository is install

$ sudo yum install epel-release

Once the repository is installed, install Ansible with yum:

$ sudo yum install ansible

Configuring Ansible Hosts

Step 1:  Add all the Linux boxes in “/etc/Ansible/hosts” hosts inventory file

Ansible hosts inventory
  • [testans] is Group name of remote hosts on which we need to manage
  • In Group testans we have 3 servers mentioned, we can add many more servers

Step 2: Copy “ssh-key” to all the remote hosts mentioned in host inventory file by using below command, we have to copy “ssh key” to all the host server we need to install.

# ssh-copy-id qorblvsitestvm3

Step3: Verify if all the host servers mentioned in Host Inventory file is pinging using below command

# ansible testans -m ping

Ansible Ping result

Below is example of playbook which will install VMtool on Linux virtual machines in Vcenter.

---
- hosts: VMtool

  remote_user: root

  tasks:
  - name: Install dependencies from repository
    yum: name={{ item }} state=present
    with_items:
      - open-vm-tools
  - name: Enabling vmtoolsd 
    service: 
      name: vmtoolsd 
      enabled: yes
  - name: Starting vmtoolsd
    service:
      name: vmtoolsd
      state: restarted

Run the Ansible Playbook to update/install VM Tools

Step 1: Ansible Playbook is saved in /root directory “vm_tools.yml 

Step 2: Run the Playbook with below command  

# ansible-playbook vm_tools.yml 

Step 3: Once the playbook executed successfully you can verify if VM Tool is installed and running from VMware Client 

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Mel
Melhttps://unixcop.com
Unix/Linux Guru and FOSS supporter

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook