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.
A prerequisite for deployment Ansible is updating system.
sudo yum update Installing EPEL Repository
Having the EPEL repository is required for Ansible installation. Execute this:
sudo yum install epel-release
After obtaining the EPEL repository, proceed to deploy:
sudo yum install ansible
Check the successful deploying :
An interruption installation prompts user.
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:
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
- name: Install mc
- hosts: database
- name: Install postgresql
This plays mc installation on all hosts within the group named mc and Postgresql installations within the database group.
ansible-playbook -i inventory playbook.yml
Tasks in the playbook will run on every hosts listed within the inventory file.
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.