Configuring "httpd" webserver on docker container through Ansible Automation Tool :
Task Description :
1 . Writing An Ansible Playbook that does the following tasks in the managed nodes :
* Configure Docker
* Start and enable Docker services
* Pull the httpd server image from the Docker Hub
* Run the docker container and expose it to the public
* copy the html code in /var/www/html directory and start the web server.
Introduction :
What is Ansible ?
Ansible is an open source automation platform. It is very, very simple to setup and yet powerful. Ansible can help you with configuration management, application deployment, task automation. It can also do IT orchestration, where you have to run tasks in sequence and create a chain of events which must happen on several different servers or devices. Ansible is rapidly rising to the top in the world of automation tools. Let’s look at some of the reasons for Ansible’s popularity.
How Ansible Works ?
Ansible works by connecting the server of the user through the SSH keys and pushing the small programs out. With the use of modules, the playbooks help the ansible clients in performing all the specific tasks. The particular functions can include the service of restarting, installing packages, rebooting servers, and much more. With the use of Ansible, a lot of things can be performed.
1. Setting the Architecture
2. SSH Keys
3. Managing Inventory
4. Using Ansible
5. Ansible Playbooks
Ansible Architecture
* The steps we need to follow to configure Apache webserver on top of Docker using Ansible Automation tool are as follows:
Step 1: The first and the most important step in Ansible is to setup Control node and for that first we need to install ansible in control node.
Check whether ansible installed successfully or not .
Step 2: Create inventory file and add details of all the target nodes in that inventory file.
[root@localhost ~] #vim ip.txt
Step 3: Create configuration file for ansible and include inventory in configuration file.
Step 4: Now create playbook to configure apache webserver on docker.
[root@localhost ~]# vim docker.yml
Step 5: Run the playbook and check whether its working properly or not.
[root@localhost ~]# ansible-playbook docker.yml
Let's check whether all the steps have been successfully done or not on Managed Node.
Docker repository configured successfully.
Docker installed and service started and enabled successfully.
Pulled docker httpd image successfully.
Launched docker httpd container successfully.
We have successfully configured Apache Webserver on Docker Container using Ansible Automation Tool.