In this basic tutorial, we’ll set up a simple apache webserver using ansible-playbook, a familiar DevOps tool for an IT automation. Ansible is an open source to automate IT with simplest way sponsored by Red Hat. It’s the only automation language that can be used to support our digitization efforts because automation plays a huge role in our digital transformations.
Before we start the tutorial, I assume you have a basic knowledge about server and networking concepts and understand how Ansible works with. For the further information about Ansible, kindly you’d like to read it here.
This tutorial will have the following features:
⦁ User will be able to create a simple playbook with YAML syntax
⦁ User will be able to set up an apache webserver
This tutorial assumes you have, to begin with, the following dependencies installed:
⦁ CentOS 7
⦁ MobaXterm (optional)
Ready? Here we go…
First of all, let’s check an IP address on your CentOS with the following command:
ip addr show
So, the IP address is the number that I give a yellow highlight; 192.168.43.114/24 (yours maybe different).
We’ll then open a MobaXterm app and create an SSH connection. Input your IP address into Remote host and specify username as a root (yours maybe different), click OK.
After setting you’ll see the result below:
Enter your password!
Now, write a playbook with YAML syntax. It contains some tasks that we’ll be run and execute with ansible-playbook. If you are not familiar with YAML, look at an overview of YAML syntax.
Good job! Now you have a playbook. Then, run ansible-playbook using this command:
You see it doesn’t work properly. It because we missed another step. Don’t forget to run an sshkeygen command before execute ansible-playbook:
ssh-copy-id [email protected]
Then re-run ansible-playbook command. Voila! It works properly now.
Last, we can test it by opening our IP address on the browser.
We successfully building a http server using ansible-playbook.