Sometimes, getting started with a technology solution can be a bit daunting. I have to say that starting out with Ansible felt like that, however once you get started you realise how well thought out the solution is. Given half a day you can get up and running. Don’t get me wrong – you won’t be an expert in half a day! That takes a while longer! Below I have detailed a quick guide to getting up and running with Ansible. You will deploy a single Ansible server on Centos7 and a secondary Centos7 server that you will use to test ansible commands and playbooks against.
Caveat: The following guide is to get you up and running quickly in a lab environment. I would not recommend this process for a Production ready deployment
Note: Throughout this guide, I am running as ‘root’ on both servers
Prerequisites
- Ideally you will have a DNS server, with entry records for the Ansible Controller and the Test Server. Failing that, ensure you setup local records on each of the servers allowing for name resolution
- Create two virtual machines as follows
Note: Ensure they can communicate with each other, by IP address and by name. Of course, you can use whichever names and IP information for each server you want, but for completeness I have included mine below
Item | Value |
---|---|
Role | Ansible Controller |
OS | Centos7 |
Name | snrans01.sonar.lan |
IP Information | 10.0.100.180 255.255.255.0 |
vCPU | 1 |
Memory | 8GB |
Hard Disk | 72GB |
NICs | 1 |
Item | Value |
---|---|
Role | Ansible Test Server |
OS | Centos7 |
Name | snransl01.sonar.lan |
IP Information | 10.0.100.182 255.255.255.0 |
vCPU | 1 |
Memory | 8GB |
Hard Disk | 72GB |
NICs | 1 |
Preparing The Ansible Controller and Test Server
Before we install Ansible, we should ensure that our OS is up to date. Additionally, we need to install a few packages to make our life (sic. my life) easier. All but one package I have installed on both servers as below.
Item | Comment | Target |
---|---|---|
epel-release | Enterprise Release Package | snrans01 |
nano | For editing files (I'm not a VI guy!) | snrans01 & snransl01 |
net-tools | I like to use ifconfig | snrans01 & snransl01 |
tree | Very handy for getting a layout of directory structures | snrans01 & snransl01 |
You can accomplish this by running the following commands on the Test Server (snransl01.sonar.lan)
Sudo yum update -y Sudo yum install tree nano net-tools -y
On the Ansible Controller (snrans01.sonar.lan) we run the same commands, but include the Enterprise Release pack for installation
Sudo yum update -y Sudo yum install tree nano net-tools epel-release -y
Installing The Ansible Controller
Ansible has a number of prerequisite packages (such as Python) that are required to ensure Ansible works properly (and in some cases even installs properly). Thankfully, the Ansible package install takes care of this for us, so installing Ansible is as simple as entering a single command on our Ansible Controller server
Sudo yum install ansible -y
Ensure Ansible Is Installed Correctly
Once the installation has completed we can check that Ansible is installed correclty and working by simply checking the version. Assuming everything has been installed and configured correctly, you will be provided an output of version information once you have executed the following command.
ansible --version