News
Seven days of Black Friday madness — great deal from Serverspace!
Serverspace Black Friday
DF
September 1, 2023
Updated September 4, 2023

Install Ansible on CentOS

Ansible CentOS

Ansible — tool designed to automate various tasks, such as managing several hosts simultaneously, changing config files, and deploying applications. In this article, we provide guidance in installing Ansible on CentOS and use It's to simplify routine tasks.

Update OS

A prerequisite for deployment Ansible is updating system.
Execute:

sudo yum update Installing EPEL Repository

Having the EPEL repository is required for Ansible installation. Execute this:

sudo yum install epel-release

Ansible Installation

After obtaining the EPEL repository, proceed to deploy:

sudo yum install ansible

Installation check

Check the successful deploying :

ansible --version

An interruption  installation  prompts user.

Configuring Hosts

After installation, configuration files will be created, which are located in the locations:

  • /etc/ansible/hosts — list of hosts to manage
  • /etc/ansible/ansible.cfg — directly ansible settings

Host configurations are first before starting Ansible. It is achievable by creating an special inventory file and list hosts in them hosts.
Listing file snippet:

[mc]
server1
server2
[database]
db1
db2

The next step is the creation of the so-called playbook. Playbook - a file that describes the order of actions to be performed on the hosts.
Playbook file provide details on operations that will be undertaken. Make file called playbook.yml and then insert to him the following code:


- hosts: mc
tasks:
- name: Install mc
yum:
name: mc
state: present
- hosts: database
tasks:
- name: Install postgresql
yum:
name: postgresql-server
state: present

This plays mc installation on all hosts within the group named mc and Postgresql installations within the database group.
Running it:

ansible-playbook -i inventory playbook.yml

Tasks in the playbook will run on every hosts listed within the inventory file.

Conclusion

Ansible may be used in automatic application deployments, managing user groups, copying files, and many other options, which require creating the necessary playbooks and running them on the intended hosts.
Ansible is a potent automation tool, allowing for server management simultaneously. It is easy to install on CentOS and automates various tasks, simplifying server administration.

Vote:
4 out of 5
Аverage rating : 4
Rated by: 1
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300

You might also like...

We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.