System: CentOS 7, Ansible-2.6.0
Step 1 — Installing Ansible
To begin exploring Ansible as a means of managing our various servers, we need to install the Ansible software on at least one machine.
To get Ansible for CentOS 7, first ensure that the CentOS 7 EPEL repository is installed:
# yum install epel-release
# yum install ansible
Step 2 — Configuring Ansible
Ansible keeps track of all of the servers that it knows about through a “hosts” file. We need to set up this file first before we can begin to communicate with our other computers.
# vi /etc/ansible/hosts
Let’s specifically tell Ansible that it should connect to servers in the “servers” group with the bachem user.
Create a directory in the Ansible configuration structure called group_vars.
# mkdir /etc/ansible/group_vars
Within this folder, we can create YAML-formatted files for each group we want to configure:
# vi /etc/ansible/group_vars/devservers
YAML files start with
"---", so make sure you don’t forget that part.
Add this code to the file: